From 4f0835978686a462fb6e154dac6b437ec4f8a616 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 21:08:45 +0100 Subject: [PATCH 1/4] Make blacklist honour pihole.conf file --- advanced/Scripts/blacklist.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/blacklist.sh b/advanced/Scripts/blacklist.sh index 2b194630..20329f1e 100755 --- a/advanced/Scripts/blacklist.sh +++ b/advanced/Scripts/blacklist.sh @@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then fi #globals -blacklist=/etc/pihole/blacklist.txt -adList=/etc/pihole/gravity.list +basename=pihole +piholeDir=/etc/$basename +adList=$piholeDir/gravity.list +blacklist=$piholeDir/blacklist.txt reload=true addmode=true force=false versbose=true + domList=() domToRemoveList=() @@ -42,6 +45,12 @@ piholeIP=${piholeIPCIDR%/*} modifyHost=false +# After setting defaults, check if there's local overrides +if [[ -r $piholeDir/pihole.conf ]];then + echo "::: Local calibration requested..." + . $piholeDir/pihole.conf +fi + if [[ -f $piholeIPv6file ]];then # If the file exists, then the user previously chose to use IPv6 in the automated installer From 0bbfb323b1e13bb2ed3b4c06bd287f455d4526da Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 21:08:56 +0100 Subject: [PATCH 2/4] make whitelist honour pihole.conf file --- advanced/Scripts/whitelist.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index 8b57b250..d457d3d7 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then fi #globals -whitelist=/etc/pihole/whitelist.txt -adList=/etc/pihole/gravity.list +basename=pihole +piholeDir=/etc/$basename +adList=$piholeDir/gravity.list +whitelist=$piholeDir/whitelist.txt reload=true addmode=true force=false versbose=true + domList=() domToRemoveList=() @@ -42,6 +45,11 @@ piholeIP=${piholeIPCIDR%/*} modifyHost=false +# After setting defaults, check if there's local overrides +if [[ -r $piholeDir/pihole.conf ]];then + echo "::: Local calibration requested..." + . $piholeDir/pihole.conf +fi if [[ -f $piholeIPv6file ]];then # If the file exists, then the user previously chose to use IPv6 in the automated installer @@ -127,10 +135,10 @@ function ModifyHostFile(){ awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp echo "l" >> /etc/pihole/whitelist.tmp - grep -F -x -v -f /etc/pihole/whitelist.tmp /etc/pihole/gravity.list > /etc/pihole/gravity.tmp - rm /etc/pihole/gravity.list - mv /etc/pihole/gravity.tmp /etc/pihole/gravity.list - rm /etc/pihole/whitelist.tmp + grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp + rm $adList + mv $piholeDir/gravity.tmp $adList + rm $piholeDir/whitelist.tmp echo " done!" fi From c6405bc93be04a248526a1e029281883bae9e253 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 23:38:46 +0100 Subject: [PATCH 3/4] Ensure addn-hosts value is updated in /etc/dnsmasq.d/01-pihole.conf if user has a custom value set in pihole.conf --- gravity.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gravity.sh b/gravity.sh index d741ac80..7d03ae7f 100755 --- a/gravity.sh +++ b/gravity.sh @@ -321,6 +321,12 @@ function gravity_reload() { # Reload hosts file echo ":::" echo -n "::: Refresh lists in dnsmasq..." + + #ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list! + #First escape forward slashes in the path: + adList=${adList//\//\\\/} + #Now replace the line in dnsmasq file + $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 $! From 0c0dd914f7950d54fc8573ce02730d0d31ed456e Mon Sep 17 00:00:00 2001 From: Promofaux Date: Mon, 4 Apr 2016 23:48:34 +0100 Subject: [PATCH 4/4] Fix source lists not being skipped if they are already up to date --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 7d03ae7f..80f80553 100755 --- a/gravity.sh +++ b/gravity.sh @@ -165,7 +165,7 @@ function gravity_transport() { fi # Silently curl url - curl -s "$cmd_ext" "$heisenbergCompensator" -A "$agent" "$url" > "$patternBuffer" + curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer # Check for list updates gravity_patternCheck "$patternBuffer" # Cleanup