Merge pull request #1402 from edgd1er/skigravityonboot

if skipgravityonboot set, check db version.
This commit is contained in:
Adam Warner 2023-08-09 19:47:04 +01:00 committed by GitHub
commit fa2eb0d2f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 9 deletions

View File

@ -26,7 +26,7 @@ echo " [i] Starting docker specific checks & setup for docker pihole/pihole"
# If PIHOLE_UID is set, modify the pihole user's id to match
if [ -n "${PIHOLE_UID}" ]; then
currentId=$(id -u ${username})
currentId=$(id -u pihole)
if [[ ${currentId} -ne ${PIHOLE_UID} ]]; then
echo " [i] Changing ID for user: pihole (${currentId} => ${PIHOLE_UID})"
usermod -o -u ${PIHOLE_UID} pihole
@ -104,16 +104,25 @@ sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /crontab.txt
/usr/sbin/crond
#migrate Database if needed:
gravityDBfile=$(getFTLConfigValue files.gravity)
if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -f "${gravityDBfile}" ]; then
if [ -n "$SKIPGRAVITYONBOOT" ];then
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
pihole -g
else
if [ -n "${SKIPGRAVITYONBOOT}" ]; then
if [ -f "${gravityDBfile}" ]; then
#skip set + file =>update if needed
echo " Skipping Gravity Database Update."
# TODO: Revist this path if we move to a multistage build
source /etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh
upgrade_gravityDB "${gravityDBfile}" "/etc/pihole"
else
#skip set + nofile => pihole -g (install error)
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 occasion."
pihole -g
fi
else
#skip not set + no file => error => create file
#skip not set + file => update db + lists
pihole -g
fi
pihole updatechecker