Merge pull request #933 from DL6ER/delayedreactivation

Add possiblity for delayed reactivation of blocking
This commit is contained in:
Mcat12 2016-11-21 08:26:26 -05:00 committed by GitHub
commit 3ba7d7640f

22
pihole
View file

@ -122,6 +122,24 @@ piholeEnable() {
#Disable Pihole #Disable Pihole
sed -i 's/^addn-hosts/#addn-hosts/' /etc/dnsmasq.d/01-pihole.conf sed -i 's/^addn-hosts/#addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
echo "::: Blocking has been disabled!" echo "::: Blocking has been disabled!"
if [[ $# > 1 ]] ; then
if [[ ${2} == *"s"* ]] ; then
tt=${2%"s"}
echo "::: Blocking will be re-enabled in ${tt} seconds"
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
elif [[ ${2} == *"m"* ]] ; then
tt=${2%"m"}
echo "::: Blocking will be re-enabled in ${tt} minutes"
tt=$((${tt}*60))
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/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 re-enabled!"
fi
fi
else else
#Enable pihole #Enable pihole
echo "::: Blocking has been enabled!" echo "::: Blocking has been enabled!"
@ -205,6 +223,8 @@ helpFunc() {
::: status Is Pi-Hole Enabled or Disabled ::: status Is Pi-Hole Enabled or Disabled
::: enable Enable Pi-Hole DNS Blocking ::: enable Enable Pi-Hole DNS Blocking
::: disable Disable 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 ::: restartdns Restart dnsmasq
EOM EOM
exit 1 exit 1
@ -231,7 +251,7 @@ case "${1}" in
"-l" | "logging" ) piholeLogging "$@";; "-l" | "logging" ) piholeLogging "$@";;
"uninstall" ) uninstallFunc;; "uninstall" ) uninstallFunc;;
"enable" ) piholeEnable 1;; "enable" ) piholeEnable 1;;
"disable" ) piholeEnable 0;; "disable" ) piholeEnable 0 $2;;
"status" ) piholeStatus "$2";; "status" ) piholeStatus "$2";;
"restartdns" ) restartDNS;; "restartdns" ) restartDNS;;
"-a" | "admin" ) webpageFunc "$@";; "-a" | "admin" ) webpageFunc "$@";;