mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Changed whitelist function to outsource to whitelist.sh
This commit is contained in:
parent
534dbc9b6e
commit
cc62d984d2
1 changed files with 26 additions and 33 deletions
59
gravity.sh
59
gravity.sh
|
@ -48,12 +48,11 @@ blacklist=$piholeDir/blacklist.txt
|
||||||
whitelist=$piholeDir/whitelist.txt
|
whitelist=$piholeDir/whitelist.txt
|
||||||
latentWhitelist=$piholeDir/latentWhitelist.txt
|
latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||||
justDomainsExtension=domains
|
justDomainsExtension=domains
|
||||||
matter=$basename.0.matter.txt
|
matterandlight=$basename.0.matterandlight.txt
|
||||||
andLight=$basename.1.andLight.txt
|
supernova=$basename.1.supernova.txt
|
||||||
supernova=$basename.2.supernova.txt
|
eventHorizon=$basename.2.eventHorizon.txt
|
||||||
eventHorizon=$basename.3.eventHorizon.txt
|
accretionDisc=$basename.3.accretionDisc.txt
|
||||||
accretionDisc=$basename.4.accretionDisc.txt
|
eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||||
eyeOfTheNeedle=$basename.5.wormhole.txt
|
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
# After setting defaults, check if there's local overrides
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
if [[ -r $piholeDir/pihole.conf ]];then
|
||||||
|
@ -160,48 +159,39 @@ function gravity_Schwarzchild() {
|
||||||
|
|
||||||
# Find all active domains and compile them into one file and remove CRs
|
# Find all active domains and compile them into one file and remove CRs
|
||||||
echo "** Aggregating list of domains..."
|
echo "** Aggregating list of domains..."
|
||||||
truncate -s 0 $piholeDir/$matter
|
truncate -s 0 $piholeDir/$matterandlight
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matter
|
cat $i |tr -d '\r' >> $piholeDir/$matterandlight
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pulsar - White/blacklist application
|
|
||||||
function gravity_pulsar() {
|
|
||||||
|
|
||||||
|
function gravity_Blacklist(){
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r $blacklist ]];then
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
||||||
echo "** Blacklisting $numberOf domain(s)..."
|
echo "** Blacklisting $numberOf domain(s)..."
|
||||||
cat $blacklist >> $piholeDir/$matter
|
cat $blacklist >> $piholeDir/$matterandlight
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Whitelist (if applicable) domains
|
function gravity_Whitelist() {
|
||||||
if [[ -r $whitelist ]];then
|
|
||||||
# Remove whitelist entries
|
|
||||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
|
||||||
echo "** Whitelisting $numberOf domain${plural}..."
|
|
||||||
|
|
||||||
# Append a "$" to the end, prepend a "^" to the beginning, and
|
|
||||||
# replace "." with "\." of each line to turn each entry into a
|
|
||||||
# regexp so it can be parsed out with grep -x
|
|
||||||
awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist
|
|
||||||
else
|
|
||||||
rm $latentWhitelist 2>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prevent our sources from being pulled into the hole
|
# Prevent our sources from being pulled into the hole
|
||||||
plural=; [[ "${#sources[@]}" != "1" ]] && plural=s
|
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
||||||
echo "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
echo "** Whitelisting ${sources[@]} ad list source${plural}..."
|
||||||
|
|
||||||
|
urls=()
|
||||||
for url in ${sources[@]}
|
for url in ${sources[@]}
|
||||||
do
|
do
|
||||||
echo "$url" | awk -F '/' '{print "^"$3"$"}' | sed 's/\./\\./g' >> $latentWhitelist
|
tmp=$(echo "$url" | awk -F '/' '{print $3}' | sed 's/\./\\./g')
|
||||||
|
urls=("${urls[@]}" $tmp)
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove whitelist entries from list
|
whitelist.sh -f -dr ${urls[@]}
|
||||||
grep -vxf $latentWhitelist $piholeDir/$matter > $piholeDir/$andLight
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_unique() {
|
function gravity_unique() {
|
||||||
|
@ -240,12 +230,13 @@ function gravity_blackbody() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_advanced() {
|
function gravity_advanced() {
|
||||||
|
|
||||||
|
|
||||||
# Remove comments and print only the domain name
|
# Remove comments and print only the domain name
|
||||||
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
||||||
# This helps with that and makes it easier to read
|
# 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
|
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$andLight | \
|
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
|
||||||
sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
|
|
||||||
|
|
||||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
numberOf=$(wc -l < $piholeDir/$supernova)
|
||||||
echo "** $numberOf domains being pulled in by gravity..."
|
echo "** $numberOf domains being pulled in by gravity..."
|
||||||
|
@ -268,11 +259,13 @@ function gravity_reload() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
gravity_pulsar
|
|
||||||
gravity_advanced
|
gravity_advanced
|
||||||
gravity_hostFormat
|
gravity_hostFormat
|
||||||
gravity_blackbody
|
gravity_blackbody
|
||||||
|
gravity_Whitelist
|
||||||
|
gravity_Blacklist
|
||||||
gravity_reload
|
gravity_reload
|
||||||
|
|
Loading…
Reference in a new issue