From f667298b64e082ce06979a59572ee8694fd31725 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 17 Nov 2016 22:58:00 +0100 Subject: [PATCH 1/6] 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;; From 3aba1607b248baa1cd241a2ca2583e736cf70259 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 17 Nov 2016 23:04:46 +0100 Subject: [PATCH 2/6] Removed debug echos --- pihole | 3 --- 1 file changed, 3 deletions(-) diff --git a/pihole b/pihole index 310efb7e..fca1ed63 100755 --- a/pihole +++ b/pihole @@ -120,16 +120,13 @@ piholeEnable() { 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!" From c6857501aa854502b06dd89f065459238aecaff4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 17 Nov 2016 23:31:11 +0100 Subject: [PATCH 3/6] Removed check for availability of nohup --- pihole | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/pihole b/pihole index fca1ed63..02a64827 100755 --- a/pihole +++ b/pihole @@ -118,25 +118,20 @@ piholeEnable() { 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 - tt=${2%"s"} - echo "::: Blocking will be reenabled in ${tt} seconds" - 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)) - 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 + if [[ ${2} == *"s"* ]] ; then + tt=${2%"s"} + echo "::: Blocking will be reenabled in ${tt} seconds" + 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)) + nohup bash -c "sleep ${tt}; pihole enable" /dev/null & else - echo "::: Command 'nohup' has to be available for this feature." + 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 fi @@ -247,7 +242,7 @@ case "${1}" in "-q" | "query" ) queryFunc "$@";; "-l" | "logging" ) piholeLogging "$@";; "uninstall" ) uninstallFunc;; - "enable" ) piholeEnable 1 $2;; + "enable" ) piholeEnable 1;; "disable" ) piholeEnable 0 $2;; "status" ) piholeStatus "$2";; "restartdns" ) restartDNS;; From 96f2aa18036b06e71768cd20affa0bc37d5a82f3 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 17 Nov 2016 23:36:53 +0100 Subject: [PATCH 4/6] fixed typo --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pihole b/pihole index 02a64827..56953b03 100755 --- a/pihole +++ b/pihole @@ -132,7 +132,7 @@ piholeEnable() { 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!" + echo "::: Blocking will not automatically be re-enabled!" fi fi else From 291ca0874a4479b047dd56bbc8646833dbce29a6 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 18 Nov 2016 12:16:10 +0100 Subject: [PATCH 5/6] Fixed two more typos --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 56953b03..017bdaec 100755 --- a/pihole +++ b/pihole @@ -120,11 +120,11 @@ piholeEnable() { if [[ $# > 1 ]] ; then if [[ ${2} == *"s"* ]] ; then tt=${2%"s"} - echo "::: Blocking will be reenabled in ${tt} seconds" + echo "::: Blocking will be re-enabled in ${tt} seconds" nohup bash -c "sleep ${tt}; pihole enable" /dev/null & elif [[ ${2} == *"m"* ]] ; then tt=${2%"m"} - echo "::: Blocking will be reenabled in ${tt} minutes" + echo "::: Blocking will be re-enabled in ${tt} minutes" tt=$((${tt}*60)) nohup bash -c "sleep ${tt}; pihole enable" /dev/null & else From 7bf0985a5750d29450c24a6a0ab9b5191e4266e9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 11:30:34 +0100 Subject: [PATCH 6/6] Extended help text of main pihole command --- pihole | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pihole b/pihole index 017bdaec..406bc2d8 100755 --- a/pihole +++ b/pihole @@ -217,6 +217,8 @@ helpFunc() { ::: status Is Pi-Hole Enabled or Disabled ::: enable Enable Pi-Hole DNS Blocking ::: disable Disable Pi-Hole DNS Blocking +::: Blocking can also be disabled only temporarily, e.g., +::: pihole disable 5m - will disable blocking for 5 minutes ::: restartdns Restart dnsmasq EOM exit 1