remove if

This commit is contained in:
Valentin CZERYBA 2023-02-28 11:04:30 +01:00
parent 8219583961
commit 2b63ec3527

View File

@ -3,17 +3,15 @@ MAIL=/tmp/mail
SERVER_LOG=/var/log/nginx
HOST=($(cat /etc/sentinel/virtualhost))
BLACKLIST=/etc/sentinel/blacklist
currently_blacklist=$(ps -ef | grep blacklist | grep bash |grep ${USER} | wc -l)
if [ ${currently_blacklist} -eq 2 ]; then
chain_count=$(iptables -L BLACKLIST -n | wc -l)
if [ ${chain_count} -eq 0 ]; then
chain_count=$(iptables -L BLACKLIST -n | wc -l)
if [ ${chain_count} -eq 0 ]; then
bash /usr/local/bin/sentinel/refill_blacklist.sh
fi
fi
for i in ${HOST[@]}
do
for i in ${HOST[@]}
do
log_access=${SERVER_LOG}/${i}_access.log
tail -n 50 $log_access | awk -F "|" '{ if($2 == "400" || $2 == "404") print $0}' > /tmp/error_$i
cat /tmp/error_$i | awk -F "|" '{ if($2 == "404") print $1}' > /tmp/404_$i
@ -38,5 +36,5 @@ if [ ${currently_blacklist} -eq 2 ]; then
cat ${BLACKLIST} >> ${MAIL}
cat ${MAIL} |mail -s "Blacklist IP ${i}" valczebackup@gmail.com
fi
done
fi
done