change whitelist to whitelistFile

This commit is contained in:
tuplink 2016-10-20 13:45:00 -04:00
parent c3f2a9328f
commit ab24e61754

View file

@ -50,8 +50,8 @@ HandleOther(){
PopWhitelistFile(){ PopWhitelistFile(){
#check whitelist file exists, and if not, create it #check whitelist file exists, and if not, create it
if [[ ! -f ${whitelist} ]];then if [[ ! -f ${whitelistFile} ]];then
touch ${whitelist} touch ${whitelistFile}
fi fi
for dom in "${domList[@]}" for dom in "${domList[@]}"
do do
@ -67,13 +67,13 @@ AddDomain(){
#| sed 's/\./\\./g' #| sed 's/\./\\./g'
bool=false bool=false
grep -Ex -q "$1" ${whitelist} || bool=true grep -Ex -q "$1" ${whitelistFile} || 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 ${verbose}; then if ${verbose}; then
echo -n "::: Adding $1 to $whitelist..." echo -n "::: Adding $1 to $whitelist..."
fi fi
echo "$1" >> ${whitelist} echo "$1" >> ${whitelistFile}
if ${verbose}; then if ${verbose}; then
echo " done!" echo " done!"
fi fi
@ -87,14 +87,14 @@ AddDomain(){
RemoveDomain(){ RemoveDomain(){
bool=false bool=false
grep -Ex -q "$1" ${whitelist} || bool=true grep -Ex -q "$1" ${whitelistFile} || 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 ${verbose}; 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
echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelist} echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelistFile}
#reload gravity to pickup any entries this may have removed #reload gravity to pickup any entries this may have removed
pihole -g pihole -g
fi fi
@ -113,7 +113,7 @@ DisplayWlist() {
do do
echo "${count}: $RD" echo "${count}: $RD"
count=$((count+1)) count=$((count+1))
done < "$whitelist" done < "$whitelistFile"
} }
################################################### ###################################################