From aaee895b2bd282ace43ae7f8b504bc81303f1e59 Mon Sep 17 00:00:00 2001 From: Tommy Huff Date: Thu, 20 Oct 2016 08:58:36 -0400 Subject: [PATCH] add pihole status web option to return 1 or 0 for easy use with php --- pihole | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pihole b/pihole index 8828dfe4..1651ac9c 100755 --- a/pihole +++ b/pihole @@ -128,13 +128,16 @@ piholeEnable() { piholeStatus() { if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "#addn-hosts=") ]] ; then - echo "pihole is Diabled" + if [[ "${1}" == "web" ]] ; then echo 0; else echo "::: pihole is Diabled"; fi else if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "addn-hosts=") ]] ; then - echo "pihole is Enabled" + if [[ "${1}" == "web" ]] ; then echo 1; else echo "::: pihole is Enabled"; fi 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 + if [[ "${1}" == "web" ]] ; then echo 1; 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 fi fi } @@ -187,7 +190,7 @@ case "$1" in "uninstall" ) uninstallFunc;; "enable" ) piholeEnable 1;; "disable" ) piholeEnable 0;; -"status" ) piholeStatus;; +"status" ) piholeStatus "$2";; "restartdnsmasq" ) restartDNS;; * ) helpFunc;;