Add dynamic IP change check script
parent
b8fb130e1d
commit
b184db73df
@ -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
|
||||||
|
|
||||||
Loading…
Reference in New Issue