1
0
mirror of https://github.com/moparisthebest/pi-hole synced 2024-11-25 10:42:14 -05:00

replace file paths with variables

This commit is contained in:
Jacob Salmela 2015-11-27 18:38:33 -06:00
parent 573c1ef94f
commit 831322b8b2

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
whitelist=/etc/pihole/whitelist.txt
if [[ ! -f /etc/pihole/whitelist.txt ]];then adList=/etc/pihole/gravity.list
touch /etc/pihole/whitelist.txt if [[ ! -f $whitelist ]];then
touch $whitelist
fi fi
if [[ $# = 0 ]]; then if [[ $# = 0 ]]; then
@ -25,8 +26,8 @@ do
combopattern="$combopattern$basicpattern" combopattern="$combopattern$basicpattern"
# Also add the domain to the whitelist but only if it's not already present # Also add the domain to the whitelist but only if it's not already present
grep -E -q "^$basicpattern$" /etc/pihole/whitelist.txt \ grep -E -q "^$basicpattern$" $whitelist \
|| echo "$var" >> /etc/pihole/whitelist.txt || echo "$var" >> $whitelist
fi fi
done done
@ -39,8 +40,8 @@ if [[ "$combopattern" != "" ]]; then
pattern=$(echo $combopattern | awk -F '[# \t]' '{printf "%s", "^(([0-9]+\.){3}[0-9]+ +)+("$1")$"}') pattern=$(echo $combopattern | awk -F '[# \t]' '{printf "%s", "^(([0-9]+\.){3}[0-9]+ +)+("$1")$"}')
# Output what will be removed and then actually remove # Output what will be removed and then actually remove
sed -r -n 's/'"$pattern"'/ Removed: \3/p' /etc/pihole/gravity.list sed -r -n 's/'"$pattern"'/ Removed: \3/p' $adList
sed -r -i '/'"$pattern"'/d' /etc/pihole/gravity.list sed -r -i '/'"$pattern"'/d' $adList
echo "** $# domain(s) whitelisted." echo "** $# domain(s) whitelisted."
# Force dnsmasq to reload /etc/pihole/gravity.list # Force dnsmasq to reload /etc/pihole/gravity.list