From 22ea384ac822349ce0eac4f61264815fc6534dce Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 3 Apr 2016 18:05:11 -0500 Subject: [PATCH 1/6] Fix whiptail spacing --- automated install/basic-install.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cd408887..139a7a4b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -110,7 +110,8 @@ welcomeDialogs() { # Explain the need for a static address whiptail --msgbox --backtitle "Initating network interface" --title "Static IP Needed" "The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly. - In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c + +In the next section, you can choose to use your current network settings (DHCP) or to manually edit them." $r $c } @@ -174,7 +175,7 @@ cleanupIPv6() { use4andor6() { # Let use select IPv4 and/or IPv6 - cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2) + cmd=(whiptail --separate-output --checklist "Select Protocols (press space to select)" $r $c 2) options=(IPv4 "Block ads over IPv4" on IPv6 "Block ads over IPv6" off) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) @@ -232,8 +233,8 @@ getStaticIPv4Settings() { Gateway: $IPv4gw" $r $c) then # If they choose yes, let the user know that the IP address will not be available via DHCP and may cause a conflict. whiptail --msgbox --backtitle "IP information" --title "FYI: IP Conflict" "It is possible your router could still try to assign this IP to a device, which would cause a conflict. But in most cases the router is smart enough to not do that. - If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. - It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c +If you are worried, either manually set the address, or modify the DHCP reservation pool so it does not include the IP you want. +It is also possible to use a DHCP reservation, but if you are going to do that, you might as well set a static address." $r $c # Nothing else to do since the variables are already set above else # Otherwise, we need to ask the user to input their desired settings. @@ -695,12 +696,12 @@ displayFinalMessage() { # Final completion message to user whiptail --msgbox --backtitle "Make it so." --title "Installation Complete!" "Configure your devices to use the Pi-hole as their DNS server using: - $IPv4addr - $piholeIPv6 +IPv4: $IPv4addr +IPv6: $piholeIPv6 - If you set a new IP address, you should restart the Pi. +If you set a new IP address, you should restart the Pi. - The install log is in /etc/pihole." $r $c +The install log is in /etc/pihole." $r $c } ######## SCRIPT ############ From 3877f6fd9485cea9a9be17a58634d4dbcee4e597 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 6 Apr 2016 09:27:46 +0100 Subject: [PATCH 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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.