mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-23 07:18:07 +00:00
Merge pull request #429 from pi-hole/white-black-piholeconf
Ensure all scripts honour pihole.conf fixed small bug where source lists were being updated on every run of gravity
This commit is contained in:
commit
f6edd435af
@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
blacklist=/etc/pihole/blacklist.txt
|
basename=pihole
|
||||||
adList=/etc/pihole/gravity.list
|
piholeDir=/etc/$basename
|
||||||
|
adList=$piholeDir/gravity.list
|
||||||
|
blacklist=$piholeDir/blacklist.txt
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
versbose=true
|
versbose=true
|
||||||
|
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
@ -42,6 +45,12 @@ piholeIP=${piholeIPCIDR%/*}
|
|||||||
|
|
||||||
modifyHost=false
|
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 [[ -f $piholeIPv6file ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
||||||
|
@ -24,12 +24,15 @@ if [[ $# = 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#globals
|
#globals
|
||||||
whitelist=/etc/pihole/whitelist.txt
|
basename=pihole
|
||||||
adList=/etc/pihole/gravity.list
|
piholeDir=/etc/$basename
|
||||||
|
adList=$piholeDir/gravity.list
|
||||||
|
whitelist=$piholeDir/whitelist.txt
|
||||||
reload=true
|
reload=true
|
||||||
addmode=true
|
addmode=true
|
||||||
force=false
|
force=false
|
||||||
versbose=true
|
versbose=true
|
||||||
|
|
||||||
domList=()
|
domList=()
|
||||||
domToRemoveList=()
|
domToRemoveList=()
|
||||||
|
|
||||||
@ -42,6 +45,11 @@ piholeIP=${piholeIPCIDR%/*}
|
|||||||
|
|
||||||
modifyHost=false
|
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 [[ -f $piholeIPv6file ]];then
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
# 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 "$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
|
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
|
||||||
echo "l" >> /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
|
grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp
|
||||||
rm /etc/pihole/gravity.list
|
rm $adList
|
||||||
mv /etc/pihole/gravity.tmp /etc/pihole/gravity.list
|
mv $piholeDir/gravity.tmp $adList
|
||||||
rm /etc/pihole/whitelist.tmp
|
rm $piholeDir/whitelist.tmp
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -165,7 +165,7 @@ function gravity_transport() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Silently curl url
|
# 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
|
# Check for list updates
|
||||||
gravity_patternCheck "$patternBuffer"
|
gravity_patternCheck "$patternBuffer"
|
||||||
# Cleanup
|
# Cleanup
|
||||||
@ -321,6 +321,12 @@ function gravity_reload() {
|
|||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
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)
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
|
|
||||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||||
|
Loading…
Reference in New Issue
Block a user