Created
March 28, 2016 19:28
-
-
Save Habmala/bea023f9dd57d95327d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Skrivet för att gå ihop med pushoverNotifyer (https://gist.github.com/Habmala/339fd38bf2e032becc0d#file-pushovernotifyer).