mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 14:20:18 +00:00
Merge pull request #450 from pi-hole/SmallFixesToWhitelistBlacklist
Small fixes to whitelist blacklist
This commit is contained in:
commit
01f53f6d6c
2 changed files with 21 additions and 21 deletions
|
@ -22,7 +22,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=()
|
||||||
|
@ -95,14 +95,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
|
||||||
|
@ -114,12 +114,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)
|
||||||
|
@ -175,7 +175,7 @@ function Reload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function DisplayBlist() {
|
function DisplayBlist() {
|
||||||
clear
|
verbose=false
|
||||||
echo -e " Displaying Gravity Affected Domains \n"
|
echo -e " Displaying Gravity Affected Domains \n"
|
||||||
count=1
|
count=1
|
||||||
while IFS= read -r AD
|
while IFS= read -r AD
|
||||||
|
@ -193,7 +193,7 @@ 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;;
|
"-l" | "--list" ) DisplayBlist;;
|
||||||
* ) HandleOther "$var";;
|
* ) HandleOther "$var";;
|
||||||
|
@ -205,7 +205,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
|
||||||
|
|
|
@ -22,7 +22,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=()
|
||||||
|
@ -96,16 +96,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
|
||||||
|
@ -117,12 +117,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)
|
||||||
|
@ -188,7 +188,7 @@ function Reload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function DisplayWlist() {
|
function DisplayWlist() {
|
||||||
clear
|
verbose=false
|
||||||
echo -e " Displaying Gravity Resistant Domains \n"
|
echo -e " Displaying Gravity Resistant Domains \n"
|
||||||
count=1
|
count=1
|
||||||
while IFS= read -r RD
|
while IFS= read -r RD
|
||||||
|
@ -206,7 +206,7 @@ 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;;
|
"-l" | "--list" ) DisplayWlist;;
|
||||||
* ) HandleOther "$var";;
|
* ) HandleOther "$var";;
|
||||||
|
@ -218,11 +218,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
|
||||||
|
|
Loading…
Reference in a new issue