Merge pull request #440 from pi-hole/Bugfix439

fixes #439
This commit is contained in:
Adam Warner 2016-04-06 09:42:07 +01:00
commit 28a3cbfa87
3 changed files with 43 additions and 28 deletions

View file

@ -11,16 +11,7 @@
# (at your option) any later version.
if [[ $# = 0 ]]; then
echo "::: Immediately blacklists one or more domains in the hosts file"
echo ":::"
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
echo ":::"
echo "::: Options:"
echo "::: -d, --delmode Remove domains from the blacklist"
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose"
exit 1
helpFunc
fi
#globals
@ -58,6 +49,21 @@ if [[ -f $piholeIPv6file ]];then
fi
function helpFunc()
{
echo "::: Immediately blacklists one or more domains in the hosts file"
echo ":::"
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
echo ":::"
echo "::: Options:"
echo "::: -d, --delmode Remove domains from the blacklist"
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog"
exit 1
}
function HandleOther(){
#check validity of domain
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
@ -175,7 +181,8 @@ do
"-nr"| "--noreload" ) reload=false;;
"-d" | "--delmode" ) addmode=false;;
"-f" | "--force" ) force=true;;
"-q" | "--quiet" ) versbose=false;;
"-q" | "--quiet" ) versbose=false;;
"-h" | "--help" ) helpFunc;;
* ) HandleOther "$var";;
esac
done

View file

@ -11,16 +11,7 @@
# (at your option) any later version.
if [[ $# = 0 ]]; then
echo "::: Immediately whitelists one or more domains in the hosts file"
echo ":::"
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
echo ":::"
echo "::: Options:"
echo "::: -d, --delmode Remove domains from the whitelist"
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose"
exit 1
helpFunc
fi
#globals
@ -57,6 +48,21 @@ if [[ -f $piholeIPv6file ]];then
fi
function helpFunc()
{
echo "::: Immediately whitelists one or more domains in the hosts file"
echo ":::"
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
echo ":::"
echo "::: Options:"
echo "::: -d, --delmode Remove domains from the whitelist"
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog"
exit 1
}
function HandleOther(){
#check validity of domain
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
@ -188,7 +194,8 @@ do
"-nr"| "--noreload" ) reload=false;;
"-d" | "--delmode" ) addmode=false;;
"-f" | "--force" ) force=true;;
"-q" | "--quiet" ) versbose=false;;
"-q" | "--quiet" ) versbose=false;;
"-h" | "--help" ) helpFunc;;
* ) HandleOther "$var";;
esac
done

13
pihole
View file

@ -11,10 +11,10 @@
# (at your option) any later version.
# Must be root to use this tool
if [[ $EUID -eq 0 ]];then
echo "::: You are root."
else
echo "::: Sudo will be used for this tool."
if [[ ! $EUID -eq 0 ]];then
#echo "::: You are root."
#else
#echo "::: Sudo will be used for this tool."
# Check if it is actually installed
# If it isn't, exit because the pihole cannot be invoked without privileges.
if [[ $(dpkg-query -s sudo) ]];then
@ -63,7 +63,8 @@ function setupLCDFunction {
}
function chronometerFunc {
$SUDO /opt/pihole/chronometer.sh
shift
$SUDO /opt/pihole/chronometer.sh "$@"
exit 1
}
@ -106,7 +107,7 @@ case "$1" in
"-u" | "updateDashboard" ) updateDashboardFunc;;
"-g" | "updateGravity" ) updateGravityFunc;;
"-s" | "setupLCD" ) setupLCDFunction;;
"-c" | "chronometer" ) chronometerFunc;;
"-c" | "chronometer" ) chronometerFunc "$@";;
"-h" | "help" ) helpFunc;;
"uninstall" ) uninstallFunc;;
* ) helpFunc;;