#!/bin/bash
while read client
do
IP="$(echo $client | cut --delimiter " " --fields 1)"
sudo sqlite3 /etc/pihole/gravity.db "insert or ignore into client (ip) values (\"$IP\");"
done < /etc/localdns.list
I would like to be able to run an SQLite update query, based on the comment field. My IPv6 addresses changes whenever my provider resets my modem, running an update query on a device name (the optional comment) is easier than running this on the previous IP address.
An additional IP type type (v4 or v6) might make the update query even simpeler, when using the same comment (device name - see example table).
@DL6ER: optionally, if the developers don't like this request, would it be harmful to pihole-FTL, if I just add the additional fields to the table myself (unsupported database modification)?
FTL should not have any issues with it as I was always very specific about database actions, intentionally not assuming a particular database structure (except, of course, that no fields are missing). Additional fields should not hurt FTL.
However, additional fields would likely hurt gravity as the new gravity database (the TEMP one) will be created without any extra fields and copying the data from left to right (old to new) will very likely cause issues as the number of table rows will be different. So you'd also need to adapt
However, I agree that we might want to add this field and only if it is to have the same structure as with domains and adlists. There is no real reason to have this one table look differently. This would also add the "created" and "last modified" timestamps.
I just setup a new beta5 system (pihole v4.3.2 -> beta5) because I was experiencing some strange behavior and wanted to ensure I wasn't reporting issues, that occurred only on my system.
Because getting support, or reporting issues on a modified system, isn't really appreciated by the developers, I'm currently NOT going to try this experiment (modifying the database). I pissed of some developers more than enough, I think they start to hate me, so I will be silent for a while.
Thanks anyway for all the great work, updates and modifications, you all have been adding over the last week.
when running pihole -g, after the upgrade, I got the following error:
[i] Swapping databases...
[✗] Unable to copy data from /etc/pihole/gravity.db to /etc/pihole/gravity_temp.db
Error: near line 18: table client has 2 columns but 5 values were supplied
[✓] Flushing DNS cache
@jpgpi250 No, your assumption was wrong. Updating the database also is not sufficient. The fields added in there are only mock fields, they are not expected to update. In contrast, they will just be present for a tiny amount of time and will be replaced by the new gravity.db created by gravity. It is not supported to upgrade the database outside of a pihole -g run.
This shows that you're still on the release/v5.0 branch. However, my fix also included some modifications to other files in the entire gravity process. You cannot mix old and new code.