From f667298b64e082ce06979a59572ee8694fd31725 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 17 Nov 2016 22:58:00 +0100 Subject: [PATCH] Added possiblity for delayed reactivation of blocking --- pihole | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 83046675..310efb7e 100755 --- a/pihole +++ b/pihole @@ -117,6 +117,32 @@ piholeEnable() { #Disable Pihole sed -i 's/^addn-hosts/#addn-hosts/' /etc/dnsmasq.d/01-pihole.conf echo "::: Blocking has been disabled!" + if [[ $# > 1 ]] ; then + if [ -x "$(command -v nohup)" ]; then + if [[ ${2} == *"s"* ]] ; then + echo "Seconds" + tt=${2%"s"} + echo "::: Blocking will be reenabled in ${tt} seconds" + echo "sleep ${tt}; pihole enable" + nohup bash -c "sleep ${tt}; pihole enable" /dev/null & + elif [[ ${2} == *"m"* ]] ; then + tt=${2%"m"} + echo "::: Blocking will be reenabled in ${tt} minutes" + tt=$((${tt}*60)) + echo "sleep ${tt}; pihole enable" + nohup bash -c "sleep ${tt}; pihole enable" /dev/null & + else + echo "::: Unknown format for delayed reactivation of the blocking!" + echo "::: Example:" + echo "::: pihole disable 5s - will disable blocking for 5 seconds" + echo "::: pihole disable 7m - will disable blocking for 7 minutes" + echo "::: Blocking will not automatically be reenabled!" + fi + else + echo "::: Command 'nohup' has to be available for this feature." + echo "::: Blocking will not automatically be reenabled!" + fi + fi else #Enable pihole echo "::: Blocking has been enabled!" @@ -224,8 +250,8 @@ case "${1}" in "-q" | "query" ) queryFunc "$@";; "-l" | "logging" ) piholeLogging "$@";; "uninstall" ) uninstallFunc;; - "enable" ) piholeEnable 1;; - "disable" ) piholeEnable 0;; + "enable" ) piholeEnable 1 $2;; + "disable" ) piholeEnable 0 $2;; "status" ) piholeStatus "$2";; "restartdns" ) restartDNS;; * ) helpFunc;;