container-server/setup/cron/daily/fail2ban-ignore

15 lines
406 B
Text
Raw Permalink Normal View History

#!/bin/sh
URL=kiel.csprung.de
2024-01-27 14:43:50 +01:00
SERVER_DIR=/opt/container-server
2024-01-27 14:43:50 +01:00
cd $SERVER_DIR
NEW_IP=$(nslookup -type=a $URL | awk '/^Address: / { print $2 ; exit }')
OLD_IP=$(awk -F '=' '/^FAIL2BAN_IGNORED_IP/{ print $2 }' .env)
if [ "$NEW_IP" != "$OLD_IP" ]; then
echo "Found new IP: $URL = $OLD_IP -> $NEW_IP"
sed -i -e "s/\(FAIL2BAN_IGNORED_IP\)=.*/\1=$NEW_IP/" .env
task compose:restart -- fail2ban
fi