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 +