# 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
piholeIP=$(cat $piholeIPfile)
piholeIP=$(cat ${piholeIPfile})
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
@ -75,13 +75,13 @@ fi
modifyHost=false
# After setting defaults, check if there's local overrides
if[[ -r $piholeDir/pihole.conf ]];then
if[[ -r ${piholeDir}/pihole.conf ]];then
echo"::: Local calibration requested..."
. $piholeDir/pihole.conf
. ${piholeDir}/pihole.conf
fi
if[[ -f $piholeIPv6file ]];then
if[[ -f ${piholeIPv6file}]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
@ -92,14 +92,14 @@ function HandleOther(){
if[ -z "$validDomain"];then
echo"::: $1 is not a valid argument or domain name"
else
domList=("${domList[@]}"$validDomain)
domList=("${domList[@]}"${validDomain})
fi
}
function PopBlacklistFile(){
#check blacklist file exists, and if not, create it
if[[ ! -f $blacklist ]];then
touch $blacklist
if[[ ! -f ${blacklist}]];then
touch ${blacklist}
fi
for dom in "${domList[@]}";do
if"$addmode";then
@ -113,17 +113,17 @@ function PopBlacklistFile(){
function AddDomain(){
#| sed 's/\./\\./g'
bool=false
grep -Ex -q "$1"$blacklist ||bool=true
if$bool;then
grep -Ex -q "$1"${blacklist}||bool=true
if${bool};then
#domain not found in the blacklist file, add it!
if$verbose;then
if${verbose};then
echo -n "::: Adding $1 to blacklist file..."
fi
echo"$1" >> $blacklist
echo"$1" >> ${blacklist}
modifyHost=true
echo" done!"
else
if$verbose;then
if${verbose};then
echo"::: $1 already exists in $blacklist! No need to add"
fi
fi
@ -132,15 +132,15 @@ function AddDomain(){
function RemoveDomain(){
bool=false
grep -Ex -q "$1"$blacklist ||bool=true
if$bool;then
grep -Ex -q "$1"${blacklist}||bool=true
if${bool};then
#Domain is not in the blacklist file, no need to Remove
if$verbose;then
if${verbose};then
echo"::: $1 is NOT blacklisted! No need to remove"
fi
else
#Domain is in the blacklist file, add to a temporary array
if$verbose;then
if${verbose};then
echo"::: Un-blacklisting $dom..."
fi
domToRemoveList=("${domToRemoveList[@]}"$1)
@ -149,17 +149,17 @@ function RemoveDomain(){
}
function ModifyHostFile(){
if$addmode;then
if${addmode};then
#add domains to the hosts file
if[[ -r $blacklist ]];then
numberOf=$(cat $blacklist | sed '/^\s*$/d'| wc -l)
if[[ -r ${blacklist}]];then
numberOf=$(cat ${blacklist}| sed '/^\s*$/d'| wc -l)
plural=;[["$numberOf" !="1"]]&&plural=s
echo":::"
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
echo"No adlists.list file found... using adlists.default!" >> $DEBUG_LOG
echo"No adlists.list file found... using adlists.default!" >> ${DEBUG_LOG}
printf":::\tNo adlists.list file found... using adlists.default!\n"
fi
@ -320,17 +320,17 @@ fi
function dumpPiHoleLog {
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)"
# 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
piholeIP=$(cat $piholeIPfile)
piholeIP=$(cat ${piholeIPfile})
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
@ -75,12 +75,12 @@ fi
modifyHost=false
# After setting defaults, check if there's local overrides
if[[ -r $piholeDir/pihole.conf ]];then
if[[ -r ${piholeDir}/pihole.conf ]];then
echo"::: Local calibration requested..."
. $piholeDir/pihole.conf
. ${piholeDir}/pihole.conf
fi
if[[ -f $piholeIPv6file ]];then
if[[ -f ${piholeIPv6file}]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
@ -91,18 +91,18 @@ function HandleOther(){
if[ -z "$validDomain"];then
echo"::: $1 is not a valid argument or domain name"
else
domList=("${domList[@]}"$validDomain)
domList=("${domList[@]}"${validDomain})
fi
}
function PopWhitelistFile(){
#check whitelist file exists, and if not, create it
if[[ ! -f $whitelist ]];then
touch $whitelist
if[[ ! -f ${whitelist}]];then
touch ${whitelist}
fi
for dom in "${domList[@]}"
do
if$addmode;then
if${addmode};then
AddDomain "$dom"
else
RemoveDomain "$dom"
@ -114,19 +114,19 @@ function AddDomain(){
#| sed 's/\./\\./g'
bool=false
grep -Ex -q "$1"$whitelist ||bool=true
if$bool;then
grep -Ex -q "$1"${whitelist}||bool=true
if${bool};then
#domain not found in the whitelist file, add it!
if$verbose;then
if${verbose};then
echo -n "::: Adding $1 to $whitelist..."
fi
echo"$1" >> $whitelist
echo"$1" >> ${whitelist}
modifyHost=true
if$verbose;then
if${verbose};then
echo" done!"
fi
else
if$verbose;then
if${verbose};then
echo"::: $1 already exists in $whitelist, no need to add!"
fi
fi
@ -135,10 +135,10 @@ function AddDomain(){
function RemoveDomain(){
bool=false
grep -Ex -q "$1"$whitelist ||bool=true
if$bool;then
grep -Ex -q "$1"${whitelist}||bool=true
if${bool};then
#Domain is not in the whitelist file, no need to Remove
if$verbose;then
if${verbose};then
echo"::: $1 is NOT whitelisted! No need to remove"
fi
else
@ -152,21 +152,21 @@ function RemoveDomain(){
}
function ModifyHostFile(){
if$addmode;then
if${addmode};then
#remove domains in from hosts file
if[[ -r $whitelist ]];then
if[[ -r ${whitelist}]];then
# Remove whitelist entries
numberOf=$(cat $whitelist | sed '/^\s*$/d'| wc -l)
numberOf=$(cat ${whitelist}| sed '/^\s*$/d'| wc -l)
plural=;[["$numberOf" !="1"]]&&plural=s
echo":::"
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
# 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
piholeIP=$(cat $piholeIPfile)
piholeIP=$(cat ${piholeIPfile})
#rm $piholeIPfile
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
@ -58,7 +58,7 @@ else
piholeIP=${piholeIPCIDR%/*}
fi
if[[ -f $piholeIPv6file ]];then
if[[ -f ${piholeIPv6file}]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " "'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
@ -66,22 +66,22 @@ fi
# Variables for various stages of downloading and formatting the list
## Nate 3/26/2016 - Commented unused variables
basename=pihole
piholeDir=/etc/$basename
adList=$piholeDir/gravity.list
piholeDir=/etc/${basename}
adList=${piholeDir}/gravity.list
#blacklist=$piholeDir/blacklist.txt
#whitelist=$piholeDir/whitelist.txt
#latentWhitelist=$piholeDir/latentWhitelist.txt
justDomainsExtension=domains
matterandlight=$basename.0.matterandlight.txt
supernova=$basename.1.supernova.txt
eventHorizon=$basename.2.eventHorizon.txt
accretionDisc=$basename.3.accretionDisc.txt
matterandlight=${basename}.0.matterandlight.txt
supernova=${basename}.1.supernova.txt
eventHorizon=${basename}.2.eventHorizon.txt
accretionDisc=${basename}.3.accretionDisc.txt
#eyeOfTheNeedle=$basename.4.wormhole.txt
# After setting defaults, check if there's local overrides
if[[ -r $piholeDir/pihole.conf ]];then
if[[ -r ${piholeDir}/pihole.conf ]];then
echo"::: Local calibration requested..."
. $piholeDir/pihole.conf
. ${piholeDir}/pihole.conf
fi
###########################
@ -90,18 +90,18 @@ function gravity_collapse() {
echo"::: Neutrino emissions detected..."
echo":::"
#Decide if we're using a custom ad block list, or defaults.
echo"::: $numberOf unique domains trapped in the event horizon."
}
@ -266,25 +266,25 @@ function gravity_hostFormat() {
echo"::: Formatting domains into a HOSTS file..."
hostname=$(</etc/hostname)
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
if[[ -n $piholeIPv6 ]];then
if[[ -n ${piholeIPv6}]];then
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
# Otherwise, just create gravity.list as normal using IPv4
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)