# 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}..."