From 78fbafa1cd3a2c21ee1cc1b7b9f69017defdff86 Mon Sep 17 00:00:00 2001 From: tuplink Date: Thu, 20 Oct 2016 18:40:03 -0400 Subject: [PATCH] test out new status logic --- pihole | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pihole b/pihole index 29acfe29..7d5f59b5 100755 --- a/pihole +++ b/pihole @@ -127,18 +127,30 @@ piholeEnable() { } piholeStatus() { - if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "#addn-hosts=") ]] ; then - if [[ "${1}" == "web" ]] ; then echo 0; else echo "::: pihole is Disabled"; fi - else - if [[ "${1}" == "web" ]] ; then echo 1; else - if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "addn-hosts=") ]] ; then - echo "::: pihole is Enabled"; - else - echo "::: no hosts file linked to dnsmasq, adding it in enabled state" - echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf - restartDNS - fi + if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "#addn-hosts=/") ]] ; then + #list is commented out + if [[ "${1}" == "web" ]] ; then + echo 0; + else + echo "::: pihole is Disabled"; + fi + elif [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "addn-hosts=/") ]] ; then + #list set + if [[ "${1}" == "web" ]] ; then + echo 1; + else + echo "::: pihole is Enabled"; fi + else + #addn-host not found + if [[ "${1}" == "web" ]] ; then + echo 99 + else + echo "::: no hosts file linked to dnsmasq, adding it in enabled state" + fi + #add addn-host= to dnsmasq + echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf + restartDNS fi }