mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-23 07:18:07 +00:00
Add root check to blacklist script
This commit is contained in:
parent
76899c9ac5
commit
4c890ab202
@ -10,6 +10,21 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
#rootcheck
|
||||||
|
if [[ $EUID -eq 0 ]];then
|
||||||
|
echo "::: You are root."
|
||||||
|
else
|
||||||
|
echo "::: sudo will be used."
|
||||||
|
# Check if it is actually installed
|
||||||
|
# If it isn't, exit because the install cannot complete
|
||||||
|
if [[ $(dpkg-query -s sudo) ]];then
|
||||||
|
export SUDO="sudo"
|
||||||
|
else
|
||||||
|
echo "::: Please install sudo or run this script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
helpFunc
|
helpFunc
|
||||||
fi
|
fi
|
||||||
@ -54,7 +69,7 @@ function helpFunc()
|
|||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
echo "::: Immediately blacklists one or more domains in the hosts file"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo "::: Usage: sudo pihole -b domain1 [domain2 ...]"
|
echo "::: Usage: pihole -b domain1 [domain2 ...]"
|
||||||
echo "::: Options:"
|
echo "::: Options:"
|
||||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
echo "::: -d, --delmode Remove domains from the blacklist"
|
||||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
||||||
@ -166,10 +181,10 @@ function Reload() {
|
|||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
if [[ $dnsmasqPid ]]; then
|
||||||
# service already running - reload config
|
# service already running - reload config
|
||||||
sudo kill -HUP "$dnsmasqPid"
|
$SUDO kill -HUP "$dnsmasqPid"
|
||||||
else
|
else
|
||||||
# service not running, start it up
|
# service not running, start it up
|
||||||
sudo service dnsmasq start
|
$SUDO service dnsmasq start
|
||||||
fi
|
fi
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user