Closed dschaper closed 3 years ago
Thanks! I changed it from
sed -i 's/NULL/IP/gi' /etc/pihole/pihole-FTL.conf
to
sed -i 's/BLOCKINGMODE=/BLOCKINGMODE=IP/gi' /etc/pihole/pihole-FTL.conf
I did not realize that NULL was not default, I read a post on Reddit that said it was default. Now I know better.
I will close this issue since it has been resolved.
It's not resolved.
What I am saying is that the /etc/pihole/pihole-FTL.conf
file has no contents by default. It's empty if it even exists. There's a good chance that it doesn't. https://docs.pi-hole.net/ftldns/configfile/
pihole-FTL
runs with it's default settings when there is no config file and the default mode is NULL.
https://docs.pi-hole.net/ftldns/blockingmode/
Your sed
lines will not enable IP blocking mode for the default installation. Running your install script will not make the block page work.
dan@raspberrypi:~ $ cat /etc/pihole/pihole-FTL.conf
PRIVACYLEVEL=0
dan@raspberrypi:~ $ sed -i 's/BLOCKINGMODE=/BLOCKINGMODE=IP/gi' /etc/pihole/pihole-FTL.conf
[sudo] password for dan:
dan@raspberrypi:~ $ cat /etc/pihole/pihole-FTL.conf
PRIVACYLEVEL=0
Oh sorry. I updated the file. Thank you!
Thank you for all your support. I think I (finally) figured it out! I just used echo and piped to tee:
echo "BLOCKINGMODE=IP" | sudo tee -a /etc/pihole/pihole-FTL.conf
Almost!
That change will duplicate BLOCKINGMODE
if it already exists and that will break things.
What you need are three conditions:
BLOCKINGMODE
lineBLOCKINGMODE
line that isn't IP
.Thanks for your patience! This should Actually work:
FILE=/etc/pihole/pihole-FTL.conf
if [ -f "$FILE" ]; then
# File exists
if grep -q "BLOCKINGMODE" $FILE
then
# If BLOCKINGMODE line is present
if grep -q "=IP" $FILE
then
# If BLOCKINGMODE is set to IP
continue
else
# IF BLOCKINGMODE is present but not set to IP
sed -i 's/.*BLOCKINGMODE.*/BLOCKINGMODE=IP/' $FILE
fi
else
# If BLOCKINGMODE line is not present
echo "BLOCKINGMODE=IP" | sudo tee -a $FILE
fi
else
# File does not exist
touch $FILE
echo "BLOCKINGMODE=IP" | sudo tee -a $FILE
fi
There is probably a simpler way, but I think this should work. A bunch of nested if then else statements.
I tested the code, and it works. I'm closing this issue since it has (now actually) been resolved. Thank you so much for your help!
https://github.com/BennyThePythonCoder/Pihole-404/blob/c04f53f8c183fcbd7908f27eae1728cc71606e24/install.sh#L53
That
sed
line won't do anything for a default install of Pi-hole. Thepihole-FTL.conf
file has no blocking mode config line so there's nothing forsed
to modify. You'll never actually enable IP blocking mode with this script on a default Pi-hole install.