From b184db73df1d0c9b5c6e1c30a3c155e446436ec3 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Wed, 29 Jun 2022 15:30:23 +0100 Subject: [PATCH] Add dynamic IP change check script --- misc/dynIP.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 misc/dynIP.sh diff --git a/misc/dynIP.sh b/misc/dynIP.sh new file mode 100755 index 0000000..63da50f --- /dev/null +++ b/misc/dynIP.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Get new IP, and push it to DNS server +# Maybe check new IP vs old stored IP, and if they're the same +# update, and also email myself that dynIP has changed + +while getopts r:R: flag +do + case "${flag}" in + r) REMOTE=${OPTARG};; + R) REMOTELOCATION=${OPTARG};; + esac +done + +newIP=$(curl -4 ifconfig.co) +oldIP=$(cat ~/.myIP) + +if [[ "$newIP" != "$oldIP" ]] +then + echo $newIP > ~/.myIP + scp ~/.myIP $REMOTE:$REMOTELOCATION + # Email myself with the new IP so I can manually change anything +fi +