From 70dadfba28f8f5862d0b3d8453bebae19656d0d9 Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Thu, 7 Apr 2016 21:52:47 -0400 Subject: [PATCH 01/26] add list options requested from issue#442 --- advanced/Scripts/blacklist.sh | 17 ++++++++++++++++- advanced/Scripts/whitelist.sh | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index fe6d42f3..11d13c5b 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,6 +61,7 @@ function helpFunc() 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" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -173,6 +174,19 @@ function Reload() { echo " done!" } +function DisplayBlist() { +clear +echo -e " Displaying Gravity Affected Domains \n" + +GRD="$blacklist" +count=1 +while IFS= read -r RD +do + echo "${count}: $RD" +count=$((count+1)) +done < "$blacklist" +} + ################################################### for var in "$@" @@ -182,7 +196,8 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; + "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index bf58b100..6ecb7715 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,6 +60,7 @@ function helpFunc() 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" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -186,6 +187,19 @@ function Reload() { echo " done!" } +function DisplayWlist() { +clear +echo -e " Displaying Gravity Resistant Domains \n" + +GRD="$whitelist" +count=1 +while IFS= read -r RD +do + echo "${count}: $RD" +count=$((count+1)) +done < "$whitelist" +} + ################################################### for var in "$@" @@ -195,7 +209,8 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; + "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; esac done From bdfc86f850175c75a575cb1dd08d6e52c4e4f89b Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Thu, 7 Apr 2016 21:58:57 -0400 Subject: [PATCH 02/26] fix formatting --- advanced/Scripts/blacklist.sh | 4 ++-- advanced/Scripts/whitelist.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 11d13c5b..f06cd138 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,7 +61,7 @@ function helpFunc() 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" - echo "::: -l, --list Display your blacklisted domains" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -197,7 +197,7 @@ do "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; "-h" | "--help" ) helpFunc;; - "-l" | "--list" ) DisplayBlist;; + "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; esac done diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 6ecb7715..a19a175f 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,7 +60,7 @@ function helpFunc() 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" - echo "::: -l, --list Display your whitelisted domains" + echo "::: -l, --list Display your whitelisted domains" exit 1 } From 9a4c5cef8620e45ae5e31a66aad27c9d281e5827 Mon Sep 17 00:00:00 2001 From: Justin Theberge Date: Fri, 8 Apr 2016 10:14:17 -0400 Subject: [PATCH 03/26] fix indentations --- advanced/Scripts/blacklist.sh | 20 +++++++++----------- advanced/Scripts/whitelist.sh | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f06cd138..418b5a4c 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -61,7 +61,7 @@ function helpFunc() 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" - echo "::: -l, --list Display your blacklisted domains" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -175,16 +175,14 @@ function Reload() { } function DisplayBlist() { -clear -echo -e " Displaying Gravity Affected Domains \n" - -GRD="$blacklist" -count=1 -while IFS= read -r RD -do - echo "${count}: $RD" -count=$((count+1)) -done < "$blacklist" + clear + echo -e " Displaying Gravity Affected Domains \n" + count=1 + while IFS= read -r AD + do + echo "${count}: $AD" + count=$((count+1)) + done < "$blacklist" } ################################################### diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index a19a175f..ea9b33ad 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -60,7 +60,7 @@ function helpFunc() 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" - echo "::: -l, --list Display your whitelisted domains" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -188,16 +188,14 @@ function Reload() { } function DisplayWlist() { -clear -echo -e " Displaying Gravity Resistant Domains \n" - -GRD="$whitelist" -count=1 -while IFS= read -r RD -do - echo "${count}: $RD" -count=$((count+1)) -done < "$whitelist" + clear + echo -e " Displaying Gravity Resistant Domains \n" + count=1 + while IFS= read -r RD + do + echo "${count}: $RD" + count=$((count+1)) + done < "$whitelist" } ################################################### @@ -209,7 +207,7 @@ do "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; "-q" | "--quiet" ) versbose=false;; - "-h" | "--help" ) helpFunc;; + "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; esac From 6c87698f1a9a38ae1583bf4d0190aedcc54e43dd Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:10:10 +0100 Subject: [PATCH 04/26] fix spelling in name of variable ($versbose -> $verbose) --- advanced/Scripts/whitelist.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index ea9b33ad..b9d14541 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -22,7 +22,7 @@ whitelist=$piholeDir/whitelist.txt reload=true addmode=true force=false -versbose=true +verbose=true domList=() domToRemoveList=() @@ -96,16 +96,16 @@ function AddDomain(){ grep -Ex -q "$1" $whitelist || bool=true if $bool; then #domain not found in the whitelist file, add it! - if $versbose; then + if $verbose; then echo -n "::: Adding $1 to $whitelist..." fi echo "$1" >> $whitelist modifyHost=true - if $versbose; then + if $verbose; then echo " done!" fi else - if $versbose; then + if $verbose; then echo "::: $1 already exists in $whitelist, no need to add!" fi fi @@ -117,12 +117,12 @@ function RemoveDomain(){ grep -Ex -q "$1" $whitelist || bool=true if $bool; then #Domain is not in the whitelist file, no need to Remove - if $versbose; then + if $verbose; then echo "::: $1 is NOT whitelisted! No need to remove" fi else #Domain is in the whitelist file, add to a temporary array and remove from whitelist file - #if $versbose; then + #if $verbose; then #echo "::: Un-whitelisting $dom..." #fi domToRemoveList=("${domToRemoveList[@]}" $1) @@ -206,7 +206,7 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) verbose=false;; "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayWlist;; * ) HandleOther "$var";; @@ -218,7 +218,7 @@ PopWhitelistFile if $modifyHost || $force; then ModifyHostFile else - if $versbose; then + if $verbose; then echo ":::" echo "::: No changes need to be made" exit 1 From c0aadeab3d4df173ac0a2c4039d233877f8d5e3c Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:10:27 +0100 Subject: [PATCH 05/26] fix spelling in name of variable ($versbose -> $verbose) --- advanced/Scripts/blacklist.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 418b5a4c..db91a146 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -22,7 +22,7 @@ blacklist=$piholeDir/blacklist.txt reload=true addmode=true force=false -versbose=true +verbose=true domList=() domToRemoveList=() @@ -95,14 +95,14 @@ function AddDomain(){ grep -Ex -q "$1" $blacklist || bool=true if $bool; then #domain not found in the blacklist file, add it! - if $versbose; then + if $verbose; then echo -n "::: Adding $1 to blacklist file..." fi echo "$1" >> $blacklist modifyHost=true echo " done!" else - if $versbose; then + if $verbose; then echo "::: $1 already exists in $blacklist! No need to add" fi fi @@ -114,12 +114,12 @@ function RemoveDomain(){ grep -Ex -q "$1" $blacklist || bool=true if $bool; then #Domain is not in the blacklist file, no need to Remove - if $versbose; then + if $verbose; then echo "::: $1 is NOT blacklisted! No need to remove" fi else #Domain is in the blacklist file, add to a temporary array - if $versbose; then + if $verbose; then echo "::: Un-blacklisting $dom..." fi domToRemoveList=("${domToRemoveList[@]}" $1) @@ -193,7 +193,7 @@ do "-nr"| "--noreload" ) reload=false;; "-d" | "--delmode" ) addmode=false;; "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) versbose=false;; + "-q" | "--quiet" ) verbose=false;; "-h" | "--help" ) helpFunc;; "-l" | "--list" ) DisplayBlist;; * ) HandleOther "$var";; @@ -205,7 +205,7 @@ PopBlacklistFile if $modifyHost || $force; then ModifyHostFile else - if $versbose; then + if $verbose; then echo "::: No changes need to be made" fi exit 1 From 8e04f1c03e8701e5fbd91cb10d17c109d211c486 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:11:39 +0100 Subject: [PATCH 06/26] Remove clear in DisplayBlist and forse verbose to false to tidy up output. --- advanced/Scripts/blacklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index db91a146..f36f5efa 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -175,7 +175,7 @@ function Reload() { } function DisplayBlist() { - clear + verbose=false echo -e " Displaying Gravity Affected Domains \n" count=1 while IFS= read -r AD From 3154a378a686a5e1ad43e645f62926a86edf7088 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 20:12:30 +0100 Subject: [PATCH 07/26] Remove clear in DisplayWlist and force verbose to false to tidy up output. --- advanced/Scripts/whitelist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b9d14541..852e319d 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -188,7 +188,7 @@ function Reload() { } function DisplayWlist() { - clear + verbose=false echo -e " Displaying Gravity Resistant Domains \n" count=1 while IFS= read -r RD From ab99e80333f795b6ea4b7a6ae68eaa0bec17d2b0 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 23:00:46 +0100 Subject: [PATCH 08/26] indent --- advanced/Scripts/blacklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index f36f5efa..04d4d60f 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -206,7 +206,7 @@ if $modifyHost || $force; then ModifyHostFile else if $verbose; then - echo "::: No changes need to be made" + echo "::: No changes need to be made" fi exit 1 fi From 107e0404de91309ebfef9fbf06ad51306b2a85e1 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Fri, 8 Apr 2016 23:01:13 +0100 Subject: [PATCH 09/26] Move `exit 1` outside of `if` block on verbose check to stop dnsmasq reloading --- advanced/Scripts/whitelist.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 852e319d..00556476 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -219,10 +219,10 @@ if $modifyHost || $force; then ModifyHostFile else if $verbose; then - echo ":::" - echo "::: No changes need to be made" - exit 1 + echo ":::" + echo "::: No changes need to be made" fi + exit 1 fi if $reload; then From be79281418424cefd6dfc7d651792871b4e68d0e Mon Sep 17 00:00:00 2001 From: notracking Date: Sun, 10 Apr 2016 16:12:40 +0800 Subject: [PATCH 10/26] Added hosts-blocklists lists The hosts-blocklist is a semi-automatically updated list, based on various well known public sources, for more details read: https://github.com/notracking/hosts-blocklists/ Please be aware that one file is for domain blocking and the other file for hostname based blocking, these lists are complimentary and should therefore be used simultaneously. --- adlists.default | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adlists.default b/adlists.default index 8a396729..837f612a 100644 --- a/adlists.default +++ b/adlists.default @@ -48,3 +48,6 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt #https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt #http://spam404bl.com/spam404scamlist.txt #http://malwaredomains.lehigh.edu/files/domains.txt +# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/) +#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt +#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt From 05e0003555e2b681cb80b1f855468641c96e376f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:17:58 +0100 Subject: [PATCH 11/26] Fixes issue #453 --- advanced/Scripts/blacklist.sh | 24 ++++++++++++------------ advanced/Scripts/chronometer.sh | 2 +- advanced/Scripts/whitelist.sh | 14 +++++++------- pihole | 22 +++++++++++----------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 04d4d60f..7d4edb95 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -53,15 +53,15 @@ function helpFunc() { echo "::: Immediately blacklists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" + echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" echo ":::" 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 "::: -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" - echo "::: -l, --list Display your blacklisted domains" + 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" + echo "::: -l, --list Display your blacklisted domains" exit 1 } @@ -70,7 +70,7 @@ function HandleOther(){ 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/') if [ -z "$validDomain" ]; then echo "::: $1 is not a valid argument or domain name" - else + else domList=("${domList[@]}" $validDomain) fi } @@ -134,12 +134,12 @@ function ModifyHostFile(){ numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) plural=; [[ "$numberOf" != "1" ]] && plural=s echo ":::" - echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." - if [[ -n $piholeIPv6 ]];then + echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." + if [[ -n $piholeIPv6 ]];then cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList - else + else cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList - fi + fi fi else echo ":::" @@ -148,7 +148,7 @@ function ModifyHostFile(){ #we need to remove the domains from the blacklist file and the host file echo "::: $dom" echo -n "::: removing from HOSTS file..." - echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList + echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList echo " done!" echo -n "::: removing from blackist.txt..." echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 58bf300b..1c8a53c9 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -120,7 +120,7 @@ function normalChrono(){ function displayHelp(){ echo "::: Displays stats about your piHole!" echo ":::" - echo "::: Usage: sudo pihole.sh -c [optional:-j]" + echo "::: Usage: sudo pihole -c [optional:-j]" echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" echo ":::" echo "::: Options:" diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 00556476..b6901249 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -52,15 +52,15 @@ function helpFunc() { echo "::: Immediately whitelists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" + echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" echo ":::" echo "::: Options:" - echo "::: -d, --delmode Remove domains from the whitelist" + 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" - echo "::: -l, --list Display your whitelisted domains" + 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" + echo "::: -l, --list Display your whitelisted domains" exit 1 } @@ -220,7 +220,7 @@ if $modifyHost || $force; then else if $verbose; then echo ":::" - echo "::: No changes need to be made" + echo "::: No changes need to be made" fi exit 1 fi diff --git a/pihole b/pihole index 5ff26246..d9d52e0c 100755 --- a/pihole +++ b/pihole @@ -77,20 +77,20 @@ function uninstallFunc { function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" - echo "::: Usage: pihole.sh [options]" + echo "::: Usage: pihole [options]" printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo ":::" echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" - echo "::: uninstall Uninstall Pi-Hole from your system!" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" + echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 48fa83c9ac5140f8d4665a668fdf6ef56010ab4a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:36:33 +0100 Subject: [PATCH 12/26] Fix whitespace --- advanced/Scripts/blacklist.sh | 24 ++++++++++++------------ advanced/Scripts/whitelist.sh | 24 ++++++++++++------------ pihole | 20 ++++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 7d4edb95..aa98f011 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -51,18 +51,18 @@ fi function helpFunc() { - echo "::: Immediately blacklists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole -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" - echo "::: -l, --list Display your blacklisted domains" - exit 1 + echo "::: Immediately blacklists one or more domains in the hosts file" + echo ":::" + echo ":::" + echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" + 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" + echo "::: -l, --list Display your blacklisted domains" + exit 1 } function HandleOther(){ diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index b6901249..e69e8804 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -50,18 +50,18 @@ fi function helpFunc() { - echo "::: Immediately whitelists one or more domains in the hosts file" - echo ":::" - echo "::: Usage: sudo pihole -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" - echo "::: -l, --list Display your whitelisted domains" - exit 1 + echo "::: Immediately whitelists one or more domains in the hosts file" + echo ":::" + echo "::: Usage: sudo pihole -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" + echo "::: -l, --list Display your whitelisted domains" + exit 1 } function HandleOther(){ diff --git a/pihole b/pihole index d9d52e0c..5b785978 100755 --- a/pihole +++ b/pihole @@ -81,16 +81,16 @@ function helpFunc { printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo ":::" echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" - echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" - echo "::: uninstall Uninstall Pi-Hole from your system!" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" + echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 1c10a801dc077f8ce5e4a58420482c491ea0b9ee Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:39:44 +0100 Subject: [PATCH 13/26] Fix whitespace... --- pihole | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pihole b/pihole index 5b785978..03e07d6e 100755 --- a/pihole +++ b/pihole @@ -75,23 +75,23 @@ function uninstallFunc { } function helpFunc { - echo "::: Control all PiHole specific functions!" - echo ":::" - echo "::: Usage: pihole [options]" - printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" - echo ":::" - echo "::: Options:" - echo "::: -w, whitelist Whitelist domains" - echo "::: -b, blacklist Blacklist domains" - echo "::: -d, debug Start a debugging session if having trouble" - echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" - echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" + echo "::: Control all PiHole specific functions!" + echo ":::" + echo "::: Usage: pihole [options]" + printf "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" + echo ":::" + echo "::: Options:" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -h, help Show this help dialog" echo "::: uninstall Uninstall Pi-Hole from your system!" - exit 1 + exit 1 } if [[ $# = 0 ]]; then From 1ce888e828b4a9a80896794e3cb3a9f60de4020a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:41:46 +0100 Subject: [PATCH 14/26] more whitespace fixes...... --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pihole b/pihole index 03e07d6e..59fe1383 100755 --- a/pihole +++ b/pihole @@ -78,7 +78,7 @@ function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" echo "::: Usage: pihole [options]" - printf "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" + echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" echo ":::" echo "::: Options:" echo "::: -w, whitelist Whitelist domains" From b6e1b3bff0e22480984e8d9afbb756171f7ca32a Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 10 Apr 2016 21:43:12 +0100 Subject: [PATCH 15/26] Last one, promise! tabs are behaving strangely here... --- pihole | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pihole b/pihole index 59fe1383..1c348b71 100755 --- a/pihole +++ b/pihole @@ -85,11 +85,11 @@ function helpFunc { echo "::: -b, blacklist Blacklist domains" echo "::: -d, debug Start a debugging session if having trouble" echo "::: -f, flush Flush the pihole.log file" - echo "::: -u, updateDashboard Update the web dashboard manually" - echo "::: -g, updateGravity Update the list of ad-serving domains" + echo "::: -u, updateDashboard Update the web dashboard manually" + echo "::: -g, updateGravity Update the list of ad-serving domains" echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -c, chronometer Calculates stats and displays to an LCD" - echo "::: -h, help Show this help dialog" + echo "::: -h, help Show this help dialog" echo "::: uninstall Uninstall Pi-Hole from your system!" exit 1 } From 99a5b3a98ab71693426daf15254ad8c64936f867 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 11 Apr 2016 11:29:14 +0100 Subject: [PATCH 16/26] remove all mentions of spinner --- gravity.sh | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/gravity.sh b/gravity.sh index d77d75cf..ac9cd629 100755 --- a/gravity.sh +++ b/gravity.sh @@ -12,6 +12,7 @@ # Run this script as root or under sudo echo ":::" + if [[ $EUID -eq 0 ]];then echo "::: You are root." else @@ -71,20 +72,6 @@ if [[ -r $piholeDir/pihole.conf ]];then . $piholeDir/pihole.conf fi -spinner() { - local pid=$1 - local delay=0.50 - local spinstr='/-|' - while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do - local temp=${spinstr#?} - printf " [%c] " "$spinstr" - local spinstr=$temp${spinstr%"$temp"} - sleep $delay - printf "\b\b\b\b\b\b" - done - printf " \b\b\b\b" -} - ########################### # collapse - begin formation of pihole function gravity_collapse() { @@ -214,7 +201,7 @@ function gravity_Schwarzchild() { echo "::: " # Find all active domains and compile them into one file and remove CRs echo -n "::: Aggregating list of domains..." - truncate -s 0 $piholeDir/$matterandlight & spinner $! + truncate -s 0 $piholeDir/$matterandlight for i in "${activeDomains[@]}" do cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight @@ -225,7 +212,7 @@ function gravity_Schwarzchild() { function gravity_Blacklist(){ # Append blacklist entries if they exist echo -n "::: Running blacklist script to update HOSTS file...." - $blacklistScript -f -nr -q > /dev/null & spinner $! + $blacklistScript -f -nr -q > /dev/null numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s @@ -247,7 +234,7 @@ function gravity_Whitelist() { echo " done!" echo -n "::: Running whitelist script to update HOSTS file...." - $whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $! + $whitelistScript -f -nr -q "${urls[@]}" > /dev/null numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") plural=; [[ "$numWhitelisted" != "1" ]] && plural=s echo " $numWhitelisted domain${plural} whitelisted!" @@ -256,7 +243,7 @@ function gravity_Whitelist() { function gravity_unique() { # Sort and remove duplicates echo -n "::: Removing duplicate domains...." - sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $! + sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon echo " done!" numberOf=$(wc -l < $piholeDir/$eventHorizon) echo "::: $numberOf unique domains trapped in the event horizon." @@ -302,7 +289,7 @@ function gravity_advanced() { # This helps with that and makes it easier to read # It also helps with debugging so each stage of the script can be researched more in depth echo -n "::: Formatting list of domains to remove comments...." - awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $! + awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova echo " done!" numberOf=$(wc -l < $piholeDir/$supernova) @@ -329,14 +316,14 @@ function gravity_reload() { $SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf dnsmasqPid=$(pidof dnsmasq) - find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $! + find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" & spinner $! + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - $SUDO service dnsmasq start & spinner $! + $SUDO service dnsmasq start fi echo " done!" } From 2f4f5a6ad2c6557b21ffab66f4403c2a2f1d8fc3 Mon Sep 17 00:00:00 2001 From: nate Date: Mon, 11 Apr 2016 18:35:44 -0500 Subject: [PATCH 17/26] Added lighttpd error.log to debug output --- advanced/Scripts/piholeDebug.sh | 60 ++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 03d1498a..364abde4 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log" DNSMASQFILE="/etc/dnsmasq.conf" PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf" +LIGHTTPDERRFILE="/var/log/lighttpd/error.log" GRAVITYFILE="/etc/pihole/gravity.list" HOSTSFILE="/etc/hosts" WHITELISTFILE="/etc/pihole/whitelist.txt" @@ -126,12 +127,44 @@ function checkProcesses { for i in "${PROCESSES[@]}" do echo "" >> $DEBUG_LOG - echo -n $i >> "$DEBUG_LOG" + echo -n "$i" >> "$DEBUG_LOG" echo " processes status:" >> $DEBUG_LOG - $SUDO systemctl -l status $i >> "$DEBUG_LOG" + $SUDO systemctl -l status "$i" >> "$DEBUG_LOG" done } +function debugLighttpd { + echo "::: Writing lighttpd to debug log..." + echo "#######################################" >> $DEBUG_LOG + echo "############ lighttpd.conf ############" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + if [ -e "$LIGHTTPDFILE" ] + then + while read -r line; do + if [ ! -z "$line" ]; then + [[ "$line" =~ ^#.*$ ]] && continue + echo "$line" >> $DEBUG_LOG + fi + done < "$LIGHTTPDFILE" + echo >> $DEBUG_LOG + else + echo "No lighttpd.conf file found!" >> $DEBUG_LOG + printf ":::\tNo lighttpd.conf file found\n" + fi + + if [ -e "$LIGHTTPDERRFILE" ] + then + echo "#######################################" >> $DEBUG_LOG + echo "######### lighttpd error.log ##########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG + else + echo "No lighttpd error.log file found!" >> $DEBUG_LOG + printf ":::\tNo lighttpd error.log file found\n" + fi + echo >> $DEBUG_LOG +} + ### END FUNCTIONS ### ### Check Pi internet connections ### @@ -152,6 +185,7 @@ compareWhitelist compareBlacklist testNslookup checkProcesses +debugLighttpd echo "::: Writing dnsmasq.conf to debug log..." echo "#######################################" >> $DEBUG_LOG @@ -178,7 +212,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG if [ -e "$PIHOLECONFFILE" ] then - #cat "$PIHOLECONFFILE" >> $DEBUG_LOG while read -r line; do if [ ! -z "$line" ]; then [[ "$line" =~ ^#.*$ ]] && continue @@ -191,25 +224,6 @@ else printf ":::\tNo 01-pihole.conf file found\n" fi -echo "::: Writing lighttpd.conf to debug log..." -echo "#######################################" >> $DEBUG_LOG -echo "############ lighttpd.conf ############" >> $DEBUG_LOG -echo "#######################################" >> $DEBUG_LOG -if [ -e "$LIGHTTPDFILE" ] -then - #cat "$PIHOLECONFFILE" >> $DEBUG_LOG - while read -r line; do - if [ ! -z "$line" ]; then - [[ "$line" =~ ^#.*$ ]] && continue - echo "$line" >> $DEBUG_LOG - fi - done < "$LIGHTTPDFILE" - echo >> $DEBUG_LOG -else - echo "No lighttpd.conf file found!" >> $DEBUG_LOG - printf ":::\tNo lighttpd.conf file found\n" -fi - echo "::: Writing size of gravity.list to debug log..." echo "#######################################" >> $DEBUG_LOG echo "############ gravity.list #############" >> $DEBUG_LOG @@ -283,7 +297,7 @@ fi # Continuously append the pihole.log file to the pihole_debug.log file function dumpPiHoleLog { - trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT + trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo "#######################################" >> $DEBUG_LOG echo "############# pihole.log ##############" >> $DEBUG_LOG From a6bee76581a144cc170df47e59a63d99d7bb8f9f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 12 Apr 2016 08:24:34 +0100 Subject: [PATCH 18/26] add location of debug log output file! --- advanced/Scripts/piholeDebug.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 364abde4..0796310a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -316,7 +316,8 @@ function dumpPiHoleLog { # Anything to be done after capturing of pihole.log terminates function finalWork { - echo "::: Finshed debugging!" + echo "::: Finshed debugging!" + echo "::: Debug log can be found at : /var/log/pihole_debug.log" } trap finalWork EXIT From d10e9b1b6e06ed9d109094234e08b285618c7b46 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 12 Apr 2016 08:47:30 +0100 Subject: [PATCH 19/26] add pihole/webui version numbers --- advanced/Scripts/piholeDebug.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 0796310a..263fe9cd 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -54,6 +54,19 @@ else fi ### Private functions exist here ### +function versionCheck { + echo "#######################################" >> $DEBUG_LOG + echo "########## Versions Section ###########" >> $DEBUG_LOG + echo "#######################################" >> $DEBUG_LOG + + TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0) + echo "Pi-hole Version: $TMP" >> $DEBUG_LOG + + TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0) + echo "WebUI Version: $TMP" >> $DEBUG_LOG + echo >> $DEBUG_LOG +} + function compareWhitelist { if [ ! -f "$WHITELISTMATCHES" ]; then $SUDO touch $WHITELISTMATCHES @@ -181,6 +194,7 @@ echo "Gateway check:" >> $DEBUG_LOG echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo >> $DEBUG_LOG +versionCheck compareWhitelist compareBlacklist testNslookup From 4c890ab2022e2adfbe368ee02c643947cd812bac Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 13 Apr 2016 15:50:48 +0100 Subject: [PATCH 20/26] Add root check to blacklist script --- advanced/Scripts/blacklist.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index aa98f011..c178d9a1 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -10,6 +10,21 @@ # the Free Software Foundation, either version 2 of the License, or # (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 helpFunc fi @@ -54,7 +69,7 @@ function helpFunc() echo "::: Immediately blacklists one or more domains in the hosts file" echo ":::" echo ":::" - echo "::: Usage: sudo pihole -b domain1 [domain2 ...]" + echo "::: Usage: pihole -b domain1 [domain2 ...]" echo "::: Options:" echo "::: -d, --delmode Remove domains from the blacklist" echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" @@ -166,10 +181,10 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - sudo service dnsmasq start + $SUDO service dnsmasq start fi echo " done!" } From 77f4126f9b06596f967d4dd61fd0c3c823b95244 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 13 Apr 2016 15:51:48 +0100 Subject: [PATCH 21/26] add root check to whitelist script --- advanced/Scripts/whitelist.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index e69e8804..651ff4d4 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -10,6 +10,21 @@ # the Free Software Foundation, either version 2 of the License, or # (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 helpFunc fi @@ -52,7 +67,7 @@ function helpFunc() { echo "::: Immediately whitelists one or more domains in the hosts file" echo ":::" - echo "::: Usage: sudo pihole -w domain1 [domain2 ...]" + echo "::: Usage: pihole -w domain1 [domain2 ...]" echo ":::" echo "::: Options:" echo "::: -d, --delmode Remove domains from the whitelist" @@ -179,10 +194,10 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - sudo kill -HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up - sudo service dnsmasq start + $SUDO service dnsmasq start fi echo " done!" } From 3d4bff9414342cb20380749bf1509dc744491e55 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 10:56:49 +0100 Subject: [PATCH 22/26] Add -s switch to kill command to increase compatability --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index c178d9a1..a2f71db7 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 651ff4d4..801ab9a2 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index ac9cd629..1a45de45 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO kill -s HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start From 4941a657bf9e1abfa27df85a4f79981afc03a6ac Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 12:59:40 +0100 Subject: [PATCH 23/26] remove -s switch, as it turns out it worked afterall. --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index a2f71db7..c178d9a1 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 801ab9a2..651ff4d4 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index 1a45de45..ac9cd629 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -s HUP "$dnsmasqPid" + $SUDO kill -HUP "$dnsmasqPid" else # service not running, start it up $SUDO service dnsmasq start From ad574f5e9084f65a1b5450bb95807f035174de5e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sat, 16 Apr 2016 15:52:38 +0100 Subject: [PATCH 24/26] Replace kill with killall --- advanced/Scripts/blacklist.sh | 2 +- advanced/Scripts/whitelist.sh | 2 +- gravity.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index c178d9a1..033289ba 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -181,7 +181,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 651ff4d4..a525b24a 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -194,7 +194,7 @@ function Reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start diff --git a/gravity.sh b/gravity.sh index ac9cd629..ffcbf342 100755 --- a/gravity.sh +++ b/gravity.sh @@ -320,7 +320,7 @@ function gravity_reload() { if [[ $dnsmasqPid ]]; then # service already running - reload config - $SUDO kill -HUP "$dnsmasqPid" + $SUDO killall -s HUP dnsmasq else # service not running, start it up $SUDO service dnsmasq start From b58519b974251e3bba7a40df78e1229d2c2482eb Mon Sep 17 00:00:00 2001 From: Mayur Raiturkar Date: Sun, 17 Apr 2016 18:21:32 +0530 Subject: [PATCH 25/26] fixed helpFunc 1 --- advanced/Scripts/blacklist.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index aa98f011..ae9cee16 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -10,9 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -if [[ $# = 0 ]]; then - helpFunc -fi #globals basename=pihole @@ -65,6 +62,10 @@ function helpFunc() exit 1 } +if [[ $# = 0 ]]; then + helpFunc +fi + 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/') From 56ac04c48e8c867a1ec2b1b1cdd1b0571b749735 Mon Sep 17 00:00:00 2001 From: Mayur Raiturkar Date: Sun, 17 Apr 2016 18:22:06 +0530 Subject: [PATCH 26/26] fixed helpFunc 2 --- advanced/Scripts/whitelist.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index e69e8804..8e9fa9c7 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -10,9 +10,6 @@ # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -if [[ $# = 0 ]]; then - helpFunc -fi #globals basename=pihole @@ -64,6 +61,10 @@ function helpFunc() exit 1 } +if [[ $# = 0 ]]; then + helpFunc +fi + 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/')