Instead of changing the dnsmasq configuration, we replace gravity.list and black.list by empty files for disabling. When pihole-FTL receives SIGHUP, it will clear its cache and reload all configured lists. If the files are empty, blocking will be disabled as no content to be blocked will be imported.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2018-08-12 19:31:00 +02:00
parent c00357663b
commit 20b946eae5
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

22
pihole
View file

@ -10,7 +10,8 @@
# Please see LICENSE file for your rights under this license. # Please see LICENSE file for your rights under this license.
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole" readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf" readonly gravitylist="/etc/pihole/gravity.list"
readonly blacklist="/etc/pihole/black.list"
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE" readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
source "${colfile}" source "${colfile}"
@ -146,10 +147,13 @@ Time:
elif [[ "${1}" == "0" ]]; then elif [[ "${1}" == "0" ]]; then
# Disable Pi-hole # Disable Pi-hole
sed -i 's/^addn-hosts=\/etc\/pihole\/gravity.list/#addn-hosts=\/etc\/pihole\/gravity.list/' /etc/dnsmasq.d/01-pihole.conf if [[ -e "${gravitylist}" ]]; then
sed -i 's/^addn-hosts=\/etc\/pihole\/black.list/#addn-hosts=\/etc\/pihole\/black.list/' /etc/dnsmasq.d/01-pihole.conf mv "${gravitylist}" "${gravitylist}.bck"
if [[ -e "$wildcardlist" ]]; then echo "" > "${gravitylist}"
mv "$wildcardlist" "/etc/pihole/wildcard.list" fi
if [[ -e "${blacklist}" ]]; then
mv "${blacklist}" "${blacklist}.bck"
echo "" > "${blacklist}"
fi fi
if [[ $# > 1 ]]; then if [[ $# > 1 ]]; then
local error=false local error=false
@ -193,9 +197,11 @@ Time:
echo -e " ${INFO} Enabling blocking" echo -e " ${INFO} Enabling blocking"
local str="Pi-hole Enabled" local str="Pi-hole Enabled"
sed -i 's/^#addn-hosts/addn-hosts/' /etc/dnsmasq.d/01-pihole.conf if [[ -e "${gravitylist}.bck" ]]; then
if [[ -e "/etc/pihole/wildcard.list" ]]; then mv "${gravitylist}.bck" "${gravitylist}"
mv "/etc/pihole/wildcard.list" "$wildcardlist" fi
if [[ -e "${blacklist}" ]]; then
mv "${blacklist}.bck" "${blacklist}"
fi fi
fi fi