Created
August 11, 2009 10:31
-
-
Save vrutberg/165737 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 | |
# edit this, should be login details for sms.se and your phone number | |
loginnumber="0701234567" | |
password="abc123" | |
sendTo="0701234567" | |
# you shouldn't have to edit anything beyond this point | |
if [ $# != 1 ]; then | |
echo "Usage: $0 <url>" | |
exit | |
fi | |
page=$1 | |
tmpSum=/tmp/updatechecker/sum | |
tmpFile=/tmp/updatechecker/file | |
tmpCookie=/tmp/updatechecker/cookie | |
if [ ! -e /tmp/updatechecker/ ]; then | |
echo -n "Creating /tmp/updatechecker/..." | |
mkdir /tmp/updatechecker | |
echo " done!" | |
fi | |
echo -n "Downloading file..." | |
wget -O $tmpFile $page 2&> /dev/null | |
echo " done!" | |
if [ -f $tmpSum ]; then | |
echo -n "Comparing checksums..." | |
oldSum=`cat $tmpSum` | |
currentSum=`md5sum $tmpFile | cut -d " " -f1` | |
echo " done!" | |
if [ "$oldSum" != "$currentSum" ]; then | |
echo -n "Sums differ, alerting via sms..." | |
wget -O - "http://www.sms.se/action.php?action=login" --post-data "cellphone=$mnumber&password=$password&buttonName=x" --keep-session-cookies --save-cookies $tmpCookie 2&> /dev/null | |
wget -O - "http://www.sms.se/action.php?action=sendsms&type=1" --post-data "tocellphone=$sendTo&text=$meddelande2&remaining=160&thesubmit=x" --load-cookies $tmpCookie 2&> /dev/null | |
wget -O - "http://www.sms.se/action.php?action=logout" --load-cookies $tmpCookie 2&> /dev/null | |
echo " done!" | |
else | |
echo "Sums are the same, do not alert..." | |
fi | |
fi | |
echo $currentSum > $tmpSum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment