Omit the use of sudo when running as root.

This commit is contained in:
Manuel Friedli 2020-07-24 02:52:35 +02:00
parent 771531167c
commit d33c43030d

View file

@ -370,7 +370,12 @@ sudo -k
# one of them.
while read -r addr ; do
echo "Banning ${addr} ..."
sudo fail2ban-client set apache-badbots banip "${addr}"
if [[ $(id -un) == "root" ]] ; then
# Don't use sudo when we're running as root.
fail2ban-client set apache-auth banip "${addr}"
else
sudo fail2ban-client set apache-auth banip "${addr}"
fi
done < "${banlist}"
echo -e "${green}All done!${reset}"