From 7650896158efba02ecdf1a12f240457e47d6856d Mon Sep 17 00:00:00 2001 From: "D.Rect" <48034372+DistractionRectangle@users.noreply.github.com> Date: Thu, 22 Jul 2021 21:57:27 -0700 Subject: [PATCH] Fix gravityDB check piholeFTL exposes configuration to relocate/rename gravityDB so we cannot just check a hard coded location. This commit greps pihole-FTL.conf for a custom location. Since pihole-FTL.conf will eventually be replaced by TOML, some verbosity is added to denote what config file is being checked and what location it ultimately ended up checking. Signed-off-by: D.Rect <48034372+DistractionRectangle@users.noreply.github.com> --- s6/debian-root/etc/cont-init.d/20-start.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/s6/debian-root/etc/cont-init.d/20-start.sh b/s6/debian-root/etc/cont-init.d/20-start.sh index 21d1132..09d0d04 100644 --- a/s6/debian-root/etc/cont-init.d/20-start.sh +++ b/s6/debian-root/etc/cont-init.d/20-start.sh @@ -14,9 +14,19 @@ $bashCmd /start.sh if [ -n "$PYTEST" ]; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" fi -if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -f /etc/pihole/gravity.db ]; then + +gravityDBfile="/etc/pihole/gravity.db" +config_file="/etc/pihole/pihole-FTL.conf" +# make a point to mention which config file we're checking, as breadcrumb to revisit if/when pihole-FTL.conf is succeeded by TOML +echo " Checking if custom gravity.db is set in ${config_file}" +if [[ -f "${config_file}" ]]; then + gravityDBfile="$(grep --color=never -Po "^GRAVITYDB=\K.*" "${config_file}" 2> /dev/null || echo "/etc/pihole/gravity.db")" +fi + + +if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -e "${gravityDBfile}" ]; then if [ -n "$SKIPGRAVITYONBOOT" ];then - echo " SKIPGRAVITYONBOOT is set, however no gravity.db exists (Likely due to a fresh volume). This is a required file for Pi-hole to operate." + echo " SKIPGRAVITYONBOOT is set, however ${gravityDBfile} does not exist (Likely due to a fresh volume). This is a required file for Pi-hole to operate." echo " Ignoring SKIPGRAVITYONBOOT on this occaision." fi