* Set file permission for querie database in pihole-FTL.service
Signed-off-by: Christian König <ckoenig@posteo.de>
* Use -f flag for chmod of the macvendor.db
Signed-off-by: Christian König <ckoenig@posteo.de>
* Fix missing space
Signed-off-by: Christian König <ckoenig@posteo.de>
* Fix spelling
Signed-off-by: Christian König <ckoenig@posteo.de>
Make this script a bourne shell script, which requires the removal of only a single bashism, the "{n..m}" expansion. Furthermore, since POSIX echo has no reliable command line options, switch to printf when line breaks shall be omitted. On most distros/setups "sh" calls a much lighter bourne shell like dash, which inits and runs much faster than bash.
Remove unused PIDFILE variable, remove the single case of FTLUSER call and remove it as well. Using variables here might give the wrong impression that there is a change these can be varied. But both are hardcoded in many places throughout Pi-hole, so in this service script.
Consolidate and merge the commands to pre-create and set permissions for required files and directories. The /var/log/pihole directory is and was never used, the touch, chmod and chown call can be merged into one each to reduce overhead. Use "-f" option to to fail on missing database files instead of redirecting STDERR, which is otherwise helpful to debug other possible errors, like missing or corrupted commands, filesystem errors and such.
Do not use "which pihole-FTL" when setting capabilities when the hardcoded path /usr/bin/pihole-FTL is used for the actual daemon call. It makes sense to use the full path here, as the Pi-hole installer and updater installs it explicitly there, and so we prevent users from e.g. overriding it via /usr/local/bin/pihole-FTL too easily.
On pgrep and pkill calls, add the "-x" flag to assure that only "pihole-FTL" is matched and not "foo-pihole-FTL" or "pihole-FTL-bar".
Do not remove possible leftovers from previous pihole-FTL processes on start, but on stop instead. Since "start" includes a proceeding "stop" as well, on service start nothing changes, but on service stop, some resources are now freed.
Remove leading "$" from usage message. In bash this was omitted, as $'...' is a special syntax for escape sequence expansion, which is not applicable here. In dash it would be printed literally. To keep previous behaviour, it is hence removed.
Signed-off-by: MichaIng <micha@dietpi.com>
"$network" on a systemd-driven OS leads to "After=network-online.target" in the generated systemd unit.
This target is no guarantee that all network interfaces have been fully configured, as it depends on the related network services types, but at least it reduces the risk that those have not fully finished their job when pihole-FTL starts. If this is the case, certain issues can occur:
- https://github.com/pi-hole/pi-hole/issues/2924
- https://discourse.pi-hole.net/t/have-to-pihole-restartdns-after-reboot/28772
Runtime files are now consistently created in "/run" instead of "/var/run". The second is a symlink to the first for backwards compatibility but on none-ancient distro versions one should use "/run", systemd even prints a warnings if service files use "/var/run". The service file used "/run" and "/var/run" both, in cases for the same files/directories before, which does not directly cause issues currently, due to the symlink, but is inconsistent at best.
Signed-off-by: MichaIng <micha@dietpi.com>
* Gravity performance improvements.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Do not move downloaded lists into migration_backup directory.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Do not (strictly) sort domains. Random-leaf access is faster than always-last-leaf access (on average).
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Append instead of overwrite gravity_new collection list.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Rename table gravity_new to gravity_temp to clarify that this is only an intermediate table.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Add timers for each of the calls to compute intense parts. They are to be removed before this finally hits the release/v5.0 branch.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Fix legacy list files import. It currently doesn't work when the gravity database has already been updated to using the single domainlist table.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Simplify database_table_from_file(), remove all to this function for gravity lost downloads.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Update gravity.db.sql to version 10 to have newle created databases already reflect the most recent state.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Create second gravity database and swap them on success. This has a number of advantages such as instantaneous gravity updates (as seen from FTL) and always available gravity blocking. Furthermore, this saves disk space as the old database is removed on completion.
* Add timing output for the database swapping SQLite3 call.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Explicitly generate index as a separate process.
Signed-off-by: DL6ER <dl6er@dl6er.de>
* Remove time measurements.
Signed-off-by: DL6ER <dl6er@dl6er.de>