mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
add pihole status web option to return 1 or 0 for easy use with php
This commit is contained in:
parent
7d7e17b351
commit
aaee895b2b
13
pihole
13
pihole
@ -128,13 +128,16 @@ piholeEnable() {
|
|||||||
|
|
||||||
piholeStatus() {
|
piholeStatus() {
|
||||||
if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "#addn-hosts=") ]] ; then
|
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
|
else
|
||||||
if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "addn-hosts=") ]] ; then
|
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
|
else
|
||||||
echo "no hosts file linked to dnsmasq, adding it in enabled state"
|
if [[ "${1}" == "web" ]] ; then echo 1; else
|
||||||
echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -187,7 +190,7 @@ case "$1" in
|
|||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
"enable" ) piholeEnable 1;;
|
"enable" ) piholeEnable 1;;
|
||||||
"disable" ) piholeEnable 0;;
|
"disable" ) piholeEnable 0;;
|
||||||
"status" ) piholeStatus;;
|
"status" ) piholeStatus "$2";;
|
||||||
"restartdnsmasq" ) restartDNS;;
|
"restartdnsmasq" ) restartDNS;;
|
||||||
|
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
|
Loading…
Reference in New Issue
Block a user