mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Move black/white list check to pulsar
This commit is contained in:
parent
c45dc277b6
commit
d1e475da89
1 changed files with 77 additions and 67 deletions
22
gravity.sh
22
gravity.sh
|
@ -4,6 +4,7 @@
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
# http://pi-hole.net
|
# http://pi-hole.net
|
||||||
# Compiles a list of ad-serving domains by downloading them from multiple sources
|
# Compiles a list of ad-serving domains by downloading them from multiple sources
|
||||||
|
|
||||||
piholeIPfile=/tmp/piholeIP
|
piholeIPfile=/tmp/piholeIP
|
||||||
if [[ -f $piholeIPfile ]];then
|
if [[ -f $piholeIPfile ]];then
|
||||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||||
|
@ -15,7 +16,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ad-list sources--one per line in single quotes
|
# Ad-list sources--one per line in single quotes
|
||||||
# The mahakala source is commented out due to many users having issues with it blocking legitimate domains. Uncomment at your own risk
|
# The mahakala source is commented out due to many users having issues with it blocking legitimate domains.
|
||||||
|
# Uncomment at your own risk
|
||||||
sources=('https://adaway.org/hosts.txt'
|
sources=('https://adaway.org/hosts.txt'
|
||||||
'http://adblock.gjtech.net/?format=unix-hosts'
|
'http://adblock.gjtech.net/?format=unix-hosts'
|
||||||
#'http://adblock.mahakala.is/'
|
#'http://adblock.mahakala.is/'
|
||||||
|
@ -45,6 +47,7 @@ if [[ -r $piholeDir/pihole.conf ]];then
|
||||||
echo "** Local calibration requested..."
|
echo "** Local calibration requested..."
|
||||||
. $piholeDir/pihole.conf
|
. $piholeDir/pihole.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# collapse - begin formation of pihole
|
# collapse - begin formation of pihole
|
||||||
function gravity_collapse() {
|
function gravity_collapse() {
|
||||||
|
@ -85,6 +88,7 @@ function gravity_transport() {
|
||||||
url=$1
|
url=$1
|
||||||
cmd_ext=$2
|
cmd_ext=$2
|
||||||
agent=$3
|
agent=$3
|
||||||
|
|
||||||
# tmp file, so we don't have to store the (long!) lists in RAM
|
# tmp file, so we don't have to store the (long!) lists in RAM
|
||||||
patternBuffer=$(mktemp)
|
patternBuffer=$(mktemp)
|
||||||
heisenbergCompensator=""
|
heisenbergCompensator=""
|
||||||
|
@ -92,15 +96,16 @@ function gravity_transport() {
|
||||||
# if domain has been saved, add file for date check to only download newer
|
# if domain has been saved, add file for date check to only download newer
|
||||||
heisenbergCompensator="-z $saveLocation"
|
heisenbergCompensator="-z $saveLocation"
|
||||||
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
|
||||||
gravity_patternCheck $patternBuffer
|
gravity_patternCheck $patternBuffer
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -f $patternBuffer
|
rm -f $patternBuffer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# spinup - main gravity function
|
# spinup - main gravity function
|
||||||
function gravity_spinup() {
|
function gravity_spinup() {
|
||||||
|
|
||||||
|
@ -148,6 +153,9 @@ for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matter
|
cat $i |tr -d '\r' >> $piholeDir/$matter
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function gravity_pulsar() {
|
||||||
|
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r $blacklist ]];then
|
||||||
|
@ -155,9 +163,6 @@ if [[ -r $blacklist ]];then
|
||||||
echo "** Blacklisting $numberOf domain(s)..."
|
echo "** Blacklisting $numberOf domain(s)..."
|
||||||
cat $blacklist >> $piholeDir/$matter
|
cat $blacklist >> $piholeDir/$matter
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
function gravity_pulsar() {
|
|
||||||
|
|
||||||
# Whitelist (if applicable) domains
|
# Whitelist (if applicable) domains
|
||||||
if [[ -r $whitelist ]];then
|
if [[ -r $whitelist ]];then
|
||||||
|
@ -192,6 +197,7 @@ function gravity_unique() {
|
||||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
||||||
echo "** $numberOf unique domains trapped in the event horizon."
|
echo "** $numberOf unique domains trapped in the event horizon."
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_hostFormat() {
|
function gravity_hostFormat() {
|
||||||
# Format domain list as "192.168.x.x domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo "** Formatting domains into a HOSTS file..."
|
echo "** Formatting domains into a HOSTS file..."
|
||||||
|
@ -199,9 +205,12 @@ function gravity_hostFormat() {
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
cp $piholeDir/$accretionDisc $adList
|
cp $piholeDir/$accretionDisc $adList
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_blackbody() {
|
function gravity_blackbody() {
|
||||||
|
# Loop through list files
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in $piholeDir/*.$justDomainsExtension
|
||||||
do
|
do
|
||||||
|
# If list is active then leave it (noop) else rm the list
|
||||||
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
|
@ -209,6 +218,7 @@ function gravity_blackbody() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_advanced() {
|
function gravity_advanced() {
|
||||||
|
|
||||||
# Remove comments and print only the domain name
|
# Remove comments and print only the domain name
|
||||||
|
|
Loading…
Reference in a new issue