replace blacklist with blacklistFile

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

View file

@ -50,8 +50,8 @@ HandleOther(){
PopBlacklistFile(){ PopBlacklistFile(){
#check blacklist file exists, and if not, create it #check blacklist file exists, and if not, create it
if [[ ! -f ${blacklist} ]];then if [[ ! -f ${blacklistFile} ]];then
touch ${blacklist} touch ${blacklistFile}
fi fi
for dom in "${domList[@]}"; do for dom in "${domList[@]}"; do
if "$addmode"; then if "$addmode"; then
@ -65,13 +65,13 @@ PopBlacklistFile(){
AddDomain(){ AddDomain(){
#| sed 's/\./\\./g' #| sed 's/\./\\./g'
bool=false bool=false
grep -Ex -q "$1" ${blacklist} || bool=true grep -Ex -q "$1" ${blacklistFile} || 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 ${verbose}; 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" >> ${blacklistFile}
echo " done!" echo " done!"
else else
if ${verbose}; then if ${verbose}; then
@ -83,7 +83,7 @@ AddDomain(){
RemoveDomain(){ RemoveDomain(){
bool=false bool=false
grep -Ex -q "$1" ${blacklist} || bool=true grep -Ex -q "$1" ${blacklistFile} || 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 ${verbose}; then if ${verbose}; then
@ -94,7 +94,7 @@ RemoveDomain(){
if ${verbose}; then if ${verbose}; then
echo "::: Un-blacklisting $dom..." echo "::: Un-blacklisting $dom..."
fi fi
echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${blacklist} echo "$1" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${blacklistFile}
fi fi
} }