Change gravity-on-boot so it's run by cron

Proposed solution to #834

I believe the correct way to solve this issue is to change when "Gravity on Boot" is run.

The s6 init system has different stages. Currently, "gravity on boot" is run during Stage 2.ii: cont-init.d. One instance of pihole-FTL is started during cont-init, but it is only there to check the validity of the config files; it exits soon after starting. The final "service mode" instance of pihole-FTL is not started until Stage 2.iii, when the supervisor starts doing work.

If gravity.sh is counting on FTL to do its DNS lookups, then we should not run gravity until the supervised instance of FTL is running. We can accomplish this by moving "Gravity on Boot" to a @reboot line in /etc/cron.d/gravity-on-boot, and making that file's existence dependent on the value of SKIPGRAVITYONBOOT.

This will work because cron isn't started until we've reached Stage 2.iii.

Signed-off-by: Matt Winter <MattWinter@gmail.com>
This commit is contained in:
Matt Winter 2021-04-16 10:37:05 -04:00
parent 68ad7b045d
commit fa771f74fd
1 changed files with 2 additions and 1 deletions

View File

@ -15,9 +15,10 @@ if [ -n "$PYTEST" ]; then
sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"
fi
if [ -z "$SKIPGRAVITYONBOOT" ]; then
gravity.sh
echo '@reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log' > /etc/cron.d/gravity-on-boot
else
echo " Skipping Gravity Database Update."
rm /etc/cron.d/gravity-on-boot &>/dev/null
fi
# Kill dnsmasq because s6 won't like it if it's running when s6 services start