Skip to content

Instantly share code, notes, and snippets.

@Habmala
Created March 28, 2016 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habmala/bea023f9dd57d95327d7 to your computer and use it in GitHub Desktop.
Save Habmala/bea023f9dd57d95327d7 to your computer and use it in GitHub Desktop.
#!/bin/bash
#### CheckIP ###################################
# Checks if the IP-adress has changed from the
# last time the script ran.
##################################################
##################################################
savefile="$HOME/checkIP.log"
newIP="$(wget -T 60 -q -O - checkip.dyndns.org | sed -e 's/.*Current IP Address:\ //' -e 's/<.*//')"
oldIP="$(tail -n 1 ${savefile})"
pusher="$(pushoverNotifyer)"
Header="IP Change"
Message="The IP-address at home seems to have changed to ${newIP}"
Sound="pianobar"
##################################################
if [ ${newIP} != ${oldIP} ]; then
${pusher} -H ${Header} -M ${Message} -S ${Sound}
echo -e "\n${newIP}" >> ${savefile}
sed -i "1s/.*/$(date)/" ${savefile}
else
sed -i "1s/.*/$(date)/" ${savefile}
fi
exit
@Habmala
Copy link
Author

Habmala commented Mar 29, 2016

Skrivet för att gå ihop med pushoverNotifyer (https://gist.github.com/Habmala/339fd38bf2e032becc0d#file-pushovernotifyer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment