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

13 lines
383 B
Bash
Executable file

#!/bin/sh
URL=kiel.csprung.de
cd /opt/container-server
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