Pihole Blacklist not working properly when scripted

Hi All,

I currently run PiHole as a docker container - see previous post Move from Full Pihole to Docker - #10 by anowak.

Understand PiHole was not intended for parental control but seemed to be the easiest way to prevent access to social media sites during school days.

The idea is to have a cron job run a script twice a week. Once on Monday morning and then on Friday afternoon. This script would enable or disable the gravity database blacklist table based on the comment with the word "script".

Cron Job.

00 6 * * Mon /opt/script/enabledisable_domainlist.sh
30 16 * * Fri /opt/script/enabledisable_domainlist.sh

enabledisable_domainlist.sh

#!/bin/bash

dayofweek="$(date +%w)"
# Monday
if [ ${dayofweek} = "1" ]; then
 enabled=1
# Friday
elif [ ${dayofweek} = "5" ]; then
 enabled=0
else
 exit
fi

gravitydb="/etc/pihole/gravity.db"

# Enable/Disable blacklists with script in comment.
pihole-FTL sqlite3 ${gravitydb} "update 'domainlist' SET enabled = '${enabled}' WHERE comment like '%Script%';"

pihole restartdns reload-lists

Using docker-compose, I inject the initialisation script into /etc/cont-init.d to create the Cron jobs.

Initialisation script

#!/bin/bash

chmod +x /opt/script/enabledisable_domainlist.sh
crontab /opt/script/cron.txt

All seems to work, as the scripts are being triggered correctly and modify the DB.

The issue I am having is that PiHole, even though I have the blocklist enabled through the script - seem to ignore the changes until I manually restart the DNS Service or manually run *pihole restartdns reload-lists*.

Notes:
I modified script to take in a variable 0 or 1 to activate and deactivate blacklist - script worked but PiHole still ignored changes until manual steps run??

Wondering if anyone had any ideas how to get PiHole to refresh the changes using scripts? Or is this a Docker issue?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.