More functions

Splitting into more functions
This commit is contained in:
Dan Schaper 2015-11-23 03:11:16 -08:00
parent 3d22e3bb7d
commit 4f1bb12d36
1 changed files with 15 additions and 10 deletions

View File

@ -179,6 +179,19 @@ grep -vxf $latentWhitelist $piholeDir/$matter > $piholeDir/$andLight
}
function gravity_unique() {
# Sort and remove duplicates
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
numberOf=$(wc -l < $piholeDir/$eventHorizon)
echo "** $numberOf unique domains trapped in the event horizon."
}
function gravity_hostFormat() {
# Format domain list as "192.168.x.x domain.com"
echo "** Formatting domains into a HOSTS file..."
cat $piholeDir/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"' " $0}' > $piholeDir/$accretionDisc
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
cp $piholeDir/$accretionDisc $adList
}
function gravity_advanced() {
numberOf=$(wc -l < $piholeDir/$andLight)
@ -191,19 +204,11 @@ function gravity_advanced() {
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$andLight | \
sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
# Sort and remove duplicates
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
numberOf=$(wc -l < $piholeDir/$eventHorizon)
echo "** $numberOf unique domains trapped in the event horizon."
# Format domain list as "192.168.x.x domain.com"
echo "** Formatting domains into a HOSTS file..."
cat $piholeDir/$eventHorizon | awk '{sub(/\r$/,""); print "'"$piholeIP"' " $0}' > $piholeDir/$accretionDisc
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
cp $piholeDir/$accretionDisc $adList
sudo kill -HUP $(pidof dnsmasq)
}
gravity_spinup
gravity_Schwarzchild
gravity_unique
gravity_hostFormat
gravity_advanced