From 20b946eae5ea27704666ed3ccc6a7018385233d2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 12 Aug 2018 19:31:00 +0200 Subject: [PATCH] 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 --- pihole | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pihole b/pihole index 19f7bcb8..a4fcadb3 100755 --- a/pihole +++ b/pihole @@ -10,7 +10,8 @@ # Please see LICENSE file for your rights under this license. 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" source "${colfile}" @@ -146,10 +147,13 @@ Time: elif [[ "${1}" == "0" ]]; then # Disable Pi-hole - sed -i 's/^addn-hosts=\/etc\/pihole\/gravity.list/#addn-hosts=\/etc\/pihole\/gravity.list/' /etc/dnsmasq.d/01-pihole.conf - sed -i 's/^addn-hosts=\/etc\/pihole\/black.list/#addn-hosts=\/etc\/pihole\/black.list/' /etc/dnsmasq.d/01-pihole.conf - if [[ -e "$wildcardlist" ]]; then - mv "$wildcardlist" "/etc/pihole/wildcard.list" + if [[ -e "${gravitylist}" ]]; then + mv "${gravitylist}" "${gravitylist}.bck" + echo "" > "${gravitylist}" + fi + if [[ -e "${blacklist}" ]]; then + mv "${blacklist}" "${blacklist}.bck" + echo "" > "${blacklist}" fi if [[ $# > 1 ]]; then local error=false @@ -193,9 +197,11 @@ Time: echo -e " ${INFO} Enabling blocking" local str="Pi-hole Enabled" - sed -i 's/^#addn-hosts/addn-hosts/' /etc/dnsmasq.d/01-pihole.conf - if [[ -e "/etc/pihole/wildcard.list" ]]; then - mv "/etc/pihole/wildcard.list" "$wildcardlist" + if [[ -e "${gravitylist}.bck" ]]; then + mv "${gravitylist}.bck" "${gravitylist}" + fi + if [[ -e "${blacklist}" ]]; then + mv "${blacklist}.bck" "${blacklist}" fi fi