Merge branch 'development' into WebServerChanges

Conflicts:
	advanced/Scripts/whitelist.sh
This commit is contained in:
Mcat12 2016-04-20 20:17:46 -04:00
commit 36c320859a
7 changed files with 199 additions and 116 deletions

View file

@ -48,3 +48,6 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt #https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
#http://spam404bl.com/spam404scamlist.txt #http://spam404bl.com/spam404scamlist.txt
#http://malwaredomains.lehigh.edu/files/domains.txt #http://malwaredomains.lehigh.edu/files/domains.txt
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt

View file

@ -10,6 +10,21 @@
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
#rootcheck
if [[ $EUID -eq 0 ]];then
echo "::: You are root."
else
echo "::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if [[ $(dpkg-query -s sudo) ]];then
export SUDO="sudo"
else
echo "::: Please install sudo or run this script as root."
exit 1
fi
fi
if [[ $# = 0 ]]; then if [[ $# = 0 ]]; then
helpFunc helpFunc
fi fi
@ -22,7 +37,7 @@ blacklist=$piholeDir/blacklist.txt
reload=true reload=true
addmode=true addmode=true
force=false force=false
versbose=true verbose=true
domList=() domList=()
domToRemoveList=() domToRemoveList=()
@ -42,17 +57,22 @@ function helpFunc()
{ {
echo "::: Immediately blacklists one or more domains in the hosts file" echo "::: Immediately blacklists one or more domains in the hosts file"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
echo ":::" echo ":::"
echo "::: Usage: pihole -b domain1 [domain2 ...]"
echo "::: Options:" echo "::: Options:"
echo "::: -d, --delmode Remove domains from the blacklist" echo "::: -d, --delmode Remove domains from the blacklist"
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose" echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog" echo "::: -h, --help Show this help dialog"
echo "::: -l, --list Display your blacklisted domains"
exit 1 exit 1
} }
if [[ $# = 0 ]]; then
helpFunc
fi
function HandleOther(){ function HandleOther(){
#check validity of domain #check validity of domain
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/') validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
@ -83,14 +103,14 @@ function AddDomain(){
grep -Ex -q "$1" $blacklist || bool=true grep -Ex -q "$1" $blacklist || bool=true
if $bool; then if $bool; then
#domain not found in the blacklist file, add it! #domain not found in the blacklist file, add it!
if $versbose; then if $verbose; then
echo -n "::: Adding $1 to blacklist file..." echo -n "::: Adding $1 to blacklist file..."
fi fi
echo "$1" >> $blacklist echo "$1" >> $blacklist
modifyHost=true modifyHost=true
echo " done!" echo " done!"
else else
if $versbose; then if $verbose; then
echo "::: $1 already exists in $blacklist! No need to add" echo "::: $1 already exists in $blacklist! No need to add"
fi fi
fi fi
@ -102,12 +122,12 @@ function RemoveDomain(){
grep -Ex -q "$1" $blacklist || bool=true grep -Ex -q "$1" $blacklist || bool=true
if $bool; then if $bool; then
#Domain is not in the blacklist file, no need to Remove #Domain is not in the blacklist file, no need to Remove
if $versbose; then if $verbose; then
echo "::: $1 is NOT blacklisted! No need to remove" echo "::: $1 is NOT blacklisted! No need to remove"
fi fi
else else
#Domain is in the blacklist file, add to a temporary array #Domain is in the blacklist file, add to a temporary array
if $versbose; then if $verbose; then
echo "::: Un-blacklisting $dom..." echo "::: Un-blacklisting $dom..."
fi fi
domToRemoveList=("${domToRemoveList[@]}" $1) domToRemoveList=("${domToRemoveList[@]}" $1)
@ -154,14 +174,25 @@ function Reload() {
if [[ $dnsmasqPid ]]; then if [[ $dnsmasqPid ]]; then
# service already running - reload config # service already running - reload config
sudo kill -HUP "$dnsmasqPid" $SUDO killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
sudo service dnsmasq start $SUDO service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
function DisplayBlist() {
verbose=false
echo -e " Displaying Gravity Affected Domains \n"
count=1
while IFS= read -r AD
do
echo "${count}: $AD"
count=$((count+1))
done < "$blacklist"
}
################################################### ###################################################
for var in "$@" for var in "$@"
@ -170,8 +201,9 @@ do
"-nr"| "--noreload" ) reload=false;; "-nr"| "--noreload" ) reload=false;;
"-d" | "--delmode" ) addmode=false;; "-d" | "--delmode" ) addmode=false;;
"-f" | "--force" ) force=true;; "-f" | "--force" ) force=true;;
"-q" | "--quiet" ) versbose=false;; "-q" | "--quiet" ) verbose=false;;
"-h" | "--help" ) helpFunc;; "-h" | "--help" ) helpFunc;;
"-l" | "--list" ) DisplayBlist;;
* ) HandleOther "$var";; * ) HandleOther "$var";;
esac esac
done done
@ -181,7 +213,7 @@ PopBlacklistFile
if $modifyHost || $force; then if $modifyHost || $force; then
ModifyHostFile ModifyHostFile
else else
if $versbose; then if $verbose; then
echo "::: No changes need to be made" echo "::: No changes need to be made"
fi fi
exit 1 exit 1

View file

@ -120,7 +120,7 @@ function normalChrono(){
function displayHelp(){ function displayHelp(){
echo "::: Displays stats about your piHole!" echo "::: Displays stats about your piHole!"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -c [optional:-j]" echo "::: Usage: sudo pihole -c [optional:-j]"
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"

View file

@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log"
DNSMASQFILE="/etc/dnsmasq.conf" DNSMASQFILE="/etc/dnsmasq.conf"
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf" PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf" LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
GRAVITYFILE="/etc/pihole/gravity.list" GRAVITYFILE="/etc/pihole/gravity.list"
HOSTSFILE="/etc/hosts" HOSTSFILE="/etc/hosts"
WHITELISTFILE="/etc/pihole/whitelist.txt" WHITELISTFILE="/etc/pihole/whitelist.txt"
@ -53,6 +54,19 @@ else
fi fi
### Private functions exist here ### ### Private functions exist here ###
function versionCheck {
echo "#######################################" >> $DEBUG_LOG
echo "########## Versions Section ###########" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
echo "Pi-hole Version: $TMP" >> $DEBUG_LOG
TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0)
echo "WebUI Version: $TMP" >> $DEBUG_LOG
echo >> $DEBUG_LOG
}
function compareWhitelist { function compareWhitelist {
if [ ! -f "$WHITELISTMATCHES" ]; then if [ ! -f "$WHITELISTMATCHES" ]; then
$SUDO touch $WHITELISTMATCHES $SUDO touch $WHITELISTMATCHES
@ -126,12 +140,44 @@ function checkProcesses {
for i in "${PROCESSES[@]}" for i in "${PROCESSES[@]}"
do do
echo "" >> $DEBUG_LOG echo "" >> $DEBUG_LOG
echo -n $i >> "$DEBUG_LOG" echo -n "$i" >> "$DEBUG_LOG"
echo " processes status:" >> $DEBUG_LOG echo " processes status:" >> $DEBUG_LOG
$SUDO systemctl -l status $i >> "$DEBUG_LOG" $SUDO systemctl -l status "$i" >> "$DEBUG_LOG"
done done
} }
function debugLighttpd {
echo "::: Writing lighttpd to debug log..."
echo "#######################################" >> $DEBUG_LOG
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$LIGHTTPDFILE" ]
then
while read -r line; do
if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG
fi
done < "$LIGHTTPDFILE"
echo >> $DEBUG_LOG
else
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd.conf file found\n"
fi
if [ -e "$LIGHTTPDERRFILE" ]
then
echo "#######################################" >> $DEBUG_LOG
echo "######### lighttpd error.log ##########" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG
else
echo "No lighttpd error.log file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd error.log file found\n"
fi
echo >> $DEBUG_LOG
}
### END FUNCTIONS ### ### END FUNCTIONS ###
### Check Pi internet connections ### ### Check Pi internet connections ###
@ -148,10 +194,12 @@ echo "Gateway check:" >> $DEBUG_LOG
echo "$GATEWAY_CHECK" >> $DEBUG_LOG echo "$GATEWAY_CHECK" >> $DEBUG_LOG
echo >> $DEBUG_LOG echo >> $DEBUG_LOG
versionCheck
compareWhitelist compareWhitelist
compareBlacklist compareBlacklist
testNslookup testNslookup
checkProcesses checkProcesses
debugLighttpd
echo "::: Writing dnsmasq.conf to debug log..." echo "::: Writing dnsmasq.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG
@ -178,7 +226,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG
if [ -e "$PIHOLECONFFILE" ] if [ -e "$PIHOLECONFFILE" ]
then then
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
while read -r line; do while read -r line; do
if [ ! -z "$line" ]; then if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue [[ "$line" =~ ^#.*$ ]] && continue
@ -191,25 +238,6 @@ else
printf ":::\tNo 01-pihole.conf file found\n" printf ":::\tNo 01-pihole.conf file found\n"
fi fi
echo "::: Writing lighttpd.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$LIGHTTPDFILE" ]
then
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
while read -r line; do
if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG
fi
done < "$LIGHTTPDFILE"
echo >> $DEBUG_LOG
else
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd.conf file found\n"
fi
echo "::: Writing size of gravity.list to debug log..." echo "::: Writing size of gravity.list to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG
echo "############ gravity.list #############" >> $DEBUG_LOG echo "############ gravity.list #############" >> $DEBUG_LOG
@ -283,7 +311,7 @@ fi
# Continuously append the pihole.log file to the pihole_debug.log file # Continuously append the pihole.log file to the pihole_debug.log file
function dumpPiHoleLog { function dumpPiHoleLog {
trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> $DEBUG_LOG
echo "############# pihole.log ##############" >> $DEBUG_LOG echo "############# pihole.log ##############" >> $DEBUG_LOG
@ -303,6 +331,7 @@ function dumpPiHoleLog {
# Anything to be done after capturing of pihole.log terminates # Anything to be done after capturing of pihole.log terminates
function finalWork { function finalWork {
echo "::: Finshed debugging!" echo "::: Finshed debugging!"
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
} }
trap finalWork EXIT trap finalWork EXIT

View file

@ -10,6 +10,21 @@
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
#rootcheck
if [[ $EUID -eq 0 ]];then
echo "::: You are root."
else
echo "::: sudo will be used."
# Check if it is actually installed
# If it isn't, exit because the install cannot complete
if [[ $(dpkg-query -s sudo) ]];then
export SUDO="sudo"
else
echo "::: Please install sudo or run this script as root."
exit 1
fi
fi
if [[ $# = 0 ]]; then if [[ $# = 0 ]]; then
helpFunc helpFunc
fi fi
@ -22,7 +37,7 @@ whitelist=$piholeDir/whitelist.txt
reload=true reload=true
addmode=true addmode=true
force=false force=false
versbose=true verbose=true
domList=() domList=()
domToRemoveList=() domToRemoveList=()
@ -42,7 +57,7 @@ function helpFunc()
{ {
echo "::: Immediately whitelists one or more domains in the hosts file" echo "::: Immediately whitelists one or more domains in the hosts file"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" echo "::: Usage: pihole -w domain1 [domain2 ...]"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -d, --delmode Remove domains from the whitelist" echo "::: -d, --delmode Remove domains from the whitelist"
@ -50,9 +65,14 @@ function helpFunc()
echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose" echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog" echo "::: -h, --help Show this help dialog"
echo "::: -l, --list Display your whitelisted domains"
exit 1 exit 1
} }
if [[ $# = 0 ]]; then
helpFunc
fi
function HandleOther(){ function HandleOther(){
#check validity of domain #check validity of domain
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/') validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
@ -85,16 +105,16 @@ function AddDomain(){
grep -Ex -q "$1" $whitelist || bool=true grep -Ex -q "$1" $whitelist || bool=true
if $bool; then if $bool; then
#domain not found in the whitelist file, add it! #domain not found in the whitelist file, add it!
if $versbose; then if $verbose; then
echo -n "::: Adding $1 to $whitelist..." echo -n "::: Adding $1 to $whitelist..."
fi fi
echo "$1" >> $whitelist echo "$1" >> $whitelist
modifyHost=true modifyHost=true
if $versbose; then if $verbose; then
echo " done!" echo " done!"
fi fi
else else
if $versbose; then if $verbose; then
echo "::: $1 already exists in $whitelist, no need to add!" echo "::: $1 already exists in $whitelist, no need to add!"
fi fi
fi fi
@ -106,12 +126,12 @@ function RemoveDomain(){
grep -Ex -q "$1" $whitelist || bool=true grep -Ex -q "$1" $whitelist || bool=true
if $bool; then if $bool; then
#Domain is not in the whitelist file, no need to Remove #Domain is not in the whitelist file, no need to Remove
if $versbose; then if $verbose; then
echo "::: $1 is NOT whitelisted! No need to remove" echo "::: $1 is NOT whitelisted! No need to remove"
fi fi
else else
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file #Domain is in the whitelist file, add to a temporary array and remove from whitelist file
#if $versbose; then #if $verbose; then
#echo "::: Un-whitelisting $dom..." #echo "::: Un-whitelisting $dom..."
#fi #fi
domToRemoveList=("${domToRemoveList[@]}" $1) domToRemoveList=("${domToRemoveList[@]}" $1)
@ -167,14 +187,25 @@ function Reload() {
if [[ $dnsmasqPid ]]; then if [[ $dnsmasqPid ]]; then
# service already running - reload config # service already running - reload config
sudo kill -HUP "$dnsmasqPid" $SUDO killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
sudo service dnsmasq start $SUDO service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
function DisplayWlist() {
verbose=false
echo -e " Displaying Gravity Resistant Domains \n"
count=1
while IFS= read -r RD
do
echo "${count}: $RD"
count=$((count+1))
done < "$whitelist"
}
################################################### ###################################################
for var in "$@" for var in "$@"
@ -183,8 +214,9 @@ do
"-nr"| "--noreload" ) reload=false;; "-nr"| "--noreload" ) reload=false;;
"-d" | "--delmode" ) addmode=false;; "-d" | "--delmode" ) addmode=false;;
"-f" | "--force" ) force=true;; "-f" | "--force" ) force=true;;
"-q" | "--quiet" ) versbose=false;; "-q" | "--quiet" ) verbose=false;;
"-h" | "--help" ) helpFunc;; "-h" | "--help" ) helpFunc;;
"-l" | "--list" ) DisplayWlist;;
* ) HandleOther "$var";; * ) HandleOther "$var";;
esac esac
done done
@ -194,11 +226,11 @@ PopWhitelistFile
if $modifyHost || $force; then if $modifyHost || $force; then
ModifyHostFile ModifyHostFile
else else
if $versbose; then if $verbose; then
echo ":::" echo ":::"
echo "::: No changes need to be made" echo "::: No changes need to be made"
exit 1
fi fi
exit 1
fi fi
if $reload; then if $reload; then

View file

@ -12,6 +12,7 @@
# Run this script as root or under sudo # Run this script as root or under sudo
echo ":::" echo ":::"
if [[ $EUID -eq 0 ]];then if [[ $EUID -eq 0 ]];then
echo "::: You are root." echo "::: You are root."
else else
@ -55,20 +56,6 @@ if [[ -r $piholeDir/pihole.conf ]];then
. $piholeDir/pihole.conf . $piholeDir/pihole.conf
fi fi
spinner() {
local pid=$1
local delay=0.50
local spinstr='/-|'
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}
########################### ###########################
# collapse - begin formation of pihole # collapse - begin formation of pihole
function gravity_collapse() { function gravity_collapse() {
@ -198,7 +185,7 @@ function gravity_Schwarzchild() {
echo "::: " echo "::: "
# 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 -n "::: Aggregating list of domains..." echo -n "::: Aggregating list of domains..."
truncate -s 0 $piholeDir/$matterandlight & spinner $! truncate -s 0 $piholeDir/$matterandlight
for i in "${activeDomains[@]}" for i in "${activeDomains[@]}"
do do
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
@ -209,7 +196,7 @@ function gravity_Schwarzchild() {
function gravity_Blacklist(){ function gravity_Blacklist(){
# Append blacklist entries if they exist # Append blacklist entries if they exist
echo -n "::: Running blacklist script to update HOSTS file...." echo -n "::: Running blacklist script to update HOSTS file...."
$blacklistScript -f -nr -q > /dev/null & spinner $! $blacklistScript -f -nr -q > /dev/null
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
@ -231,7 +218,7 @@ function gravity_Whitelist() {
echo " done!" echo " done!"
echo -n "::: Running whitelist script to update HOSTS file...." echo -n "::: Running whitelist script to update HOSTS file...."
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $! $whitelistScript -f -nr -q "${urls[@]}" > /dev/null
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
echo " $numWhitelisted domain${plural} whitelisted!" echo " $numWhitelisted domain${plural} whitelisted!"
@ -240,7 +227,7 @@ function gravity_Whitelist() {
function gravity_unique() { function gravity_unique() {
# Sort and remove duplicates # Sort and remove duplicates
echo -n "::: Removing duplicate domains...." echo -n "::: Removing duplicate domains...."
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $! sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
echo " done!" echo " done!"
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."
@ -281,7 +268,7 @@ function gravity_advanced() {
# 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
echo -n "::: Formatting list of domains to remove comments...." echo -n "::: Formatting list of domains to remove comments...."
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $! awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
echo " done!" echo " done!"
numberOf=$(wc -l < $piholeDir/$supernova) numberOf=$(wc -l < $piholeDir/$supernova)
@ -308,14 +295,14 @@ function gravity_reload() {
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf $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 {} \;
if [[ $dnsmasqPid ]]; then if [[ $dnsmasqPid ]]; then
# service already running - reload config # service already running - reload config
$SUDO kill -HUP "$dnsmasqPid" & spinner $! $SUDO killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
$SUDO service dnsmasq start & spinner $! $SUDO service dnsmasq start
fi fi
echo " done!" echo " done!"
} }

4
pihole
View file

@ -77,8 +77,8 @@ function uninstallFunc {
function helpFunc { function helpFunc {
echo "::: Control all PiHole specific functions!" echo "::: Control all PiHole specific functions!"
echo ":::" echo ":::"
echo "::: Usage: pihole.sh [options]" echo "::: Usage: pihole [options]"
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -w, whitelist Whitelist domains" echo "::: -w, whitelist Whitelist domains"