mirror of
https://github.com/pi-hole/pi-hole
synced 2025-02-02 03:11:11 +00:00
Merge branch 'promoTweaksTheSecond' of https://github.com/pi-hole/pi-hole into promoTweaksTheSecond
This commit is contained in:
commit
ff588200c0
23
gravity.sh
23
gravity.sh
@ -314,31 +314,15 @@ gravity_reload() {
|
|||||||
|
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
echo "::: Refresh lists in dnsmasq..."
|
||||||
|
|
||||||
#ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list!
|
#ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list!
|
||||||
#First escape forward slashes in the path:
|
#First escape forward slashes in the path:
|
||||||
adList=${adList//\//\\\/}
|
adList=${adList//\//\\\/}
|
||||||
#Now replace the line in dnsmasq file
|
#Now replace the line in dnsmasq file
|
||||||
sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
# sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
pihole restartdns
|
||||||
|
|
||||||
if [[ ${dnsmasqPid} ]]; then
|
|
||||||
# service already running - reload config
|
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
|
||||||
systemctl restart dnsmasq
|
|
||||||
else
|
|
||||||
service dnsmasq restart
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# service not running, start it up
|
|
||||||
if [ -x "$(command -v systemctl)" ]; then
|
|
||||||
systemctl start dnsmasq
|
|
||||||
else
|
|
||||||
service dnsmasq start
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
@ -375,3 +359,4 @@ gravity_hostFormat
|
|||||||
gravity_blackbody
|
gravity_blackbody
|
||||||
|
|
||||||
gravity_reload
|
gravity_reload
|
||||||
|
pihole status
|
||||||
|
68
pihole
68
pihole
@ -96,6 +96,65 @@ versionFunc() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restartDNS() {
|
||||||
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
|
# service already running - reload config
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# service not running, start it up
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
piholeEnable() {
|
||||||
|
if [[ "${1}" == "0" ]] ; then
|
||||||
|
#Disable Pihole
|
||||||
|
sed -i 's/^addn-hosts/#addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
else
|
||||||
|
#Enable pihole
|
||||||
|
sed -i 's/^#addn-hosts/addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
fi
|
||||||
|
restartDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
piholeStatus() {
|
||||||
|
if [[ $(cat /etc/dnsmasq.d/01-pihole.conf | grep "#addn-hosts=/") ]] ; then
|
||||||
|
#list is commented out
|
||||||
|
if [[ "${1}" == "web" ]] ; then
|
||||||
|
echo 0;
|
||||||
|
else
|
||||||
|
echo "::: Pi-hole 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 "::: Pi-hole 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Control all PiHole specific functions!"
|
echo "::: Control all PiHole specific functions!"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
@ -115,6 +174,10 @@ helpFunc() {
|
|||||||
echo "::: -v, version Show current versions"
|
echo "::: -v, version Show current versions"
|
||||||
echo "::: -q, query Query the adlists for a specific domain"
|
echo "::: -q, query Query the adlists for a specific domain"
|
||||||
echo "::: uninstall Uninstall Pi-Hole from your system :(!"
|
echo "::: uninstall Uninstall Pi-Hole from your system :(!"
|
||||||
|
echo "::: status Is Pi-Hole Enabled or Disabled"
|
||||||
|
echo "::: enable Enable Pi-Hole DNS Blocking"
|
||||||
|
echo "::: disable Disable Pi-Hole DNS Blocking"
|
||||||
|
echo "::: restartdns Restart dnsmasq"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,5 +200,10 @@ case "$1" in
|
|||||||
"-v" | "version" ) versionFunc "$@";;
|
"-v" | "version" ) versionFunc "$@";;
|
||||||
"-q" | "query" ) queryFunc "$@";;
|
"-q" | "query" ) queryFunc "$@";;
|
||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
|
"enable" ) piholeEnable 1;;
|
||||||
|
"disable" ) piholeEnable 0;;
|
||||||
|
"status" ) piholeStatus "$2";;
|
||||||
|
"restartdns" ) restartDNS;;
|
||||||
|
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user