first commit

This commit is contained in:
git
2025-07-20 13:25:51 +10:00
commit a2971879f0
294 changed files with 42788 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
BASE_DIR="/mnt/docker-persistent-data/docker"
INI_FILE=$BASE_DIR"/last-ip.ini"
LOG_FILE=$BASE_DIR"/update-firewall.log"
CURRENT_IP=$(dig +short lan.ddnsgeek.com)
LAST_IP=`cat $INI_FILE`
CMD_PART_1='allow proto tcp from'
CMD_PART_2='to any port 22'
echo $(date -d "+10 hours" "+%a %b %d %T") > $LOG_FILE
echo "Last IP address: "$LAST_IP >> $LOG_FILE
echo "Current IP address: "$CURRENT_IP >> $LOG_FILE
if ! [ $CURRENT_IP == $LAST_IP ];
then
echo "Updating Firewall Rules" >> $LOG_FILE
sudo ufw delete $CMD_PART_1 $LAST_IP $CMD_PART_2
sudo ufw $CMD_PART_1 $CURRENT_IP $CMD_PART_2
echo $CURRENT_IP > $INI_FILE
else
echo "IP address is correct. No firewall changes needed" >> $LOG_FILE
fi