From 3877f6fd9485cea9a9be17a58634d4dbcee4e597 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:27:46 +0100 Subject: [PATCH 1/5] Fix arguments not being passed through to chronometer.sh --- pihole | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 66f967dc..add8a04a 100755 --- a/pihole +++ b/pihole @@ -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;; From 96f3f863e584f9de57300a1ae14d6a5cd4759d90 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:28:24 +0100 Subject: [PATCH 2/5] Clean up output. Commented out un-needed root/sudo notification --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index add8a04a..29e85309 100755 --- a/pihole +++ b/pihole @@ -12,9 +12,9 @@ # Must be root to use this tool if [[ $EUID -eq 0 ]];then - echo "::: You are root." + #echo "::: You are root." else - echo "::: Sudo will be used for this tool." + #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 From e074c721301b86e4595ee75a24f83e195ae9ff99 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:32:36 +0100 Subject: [PATCH 3/5] Move help output to function helpFunc, add -h argument. --- advanced/Scripts/whitelist.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 1d33e41a..bf58b100 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -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 From 391dea445a1271f6c54f79ee0e7c8613ffae1258 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:34:05 +0100 Subject: [PATCH 4/5] Move help output to function, add -h argument --- advanced/Scripts/blacklist.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 9e5d557b..fe6d42f3 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -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 From 0b480c2d3f78f5d04c60fc0bcced20abddb75eae Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:36:41 +0100 Subject: [PATCH 5/5] remove redundant else, add ! to if logic. --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index 29e85309..5ff26246 100755 --- a/pihole +++ b/pihole @@ -11,9 +11,9 @@ # (at your option) any later version. # Must be root to use this tool -if [[ $EUID -eq 0 ]];then +if [[ ! $EUID -eq 0 ]];then #echo "::: You are root." -else +#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.