Created
May 17, 2016 19:35
-
-
Save sburlot/b334036cab4dfbe018f2ed9124831f6d to your computer and use it in GitHub Desktop.
Checks if the Arq Backup release note page has changed and sends a notification. Run every hour via cron.
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
#!/usr/bin/perl | |
require WebService::Prowl; | |
my $oldvalue = ""; | |
my $md5 = ""; | |
$result = `curl -s "https://www.arqbackup.com/download/arq5_release_notes.html" | md5sum`; | |
($md5, $ignore) = split(/\s/, $result); | |
if ( $? == -1 ) { | |
print "command failed: $!\n"; | |
} else { | |
chop($md5); | |
if (open F, "/tmp/arq.txt") { | |
$old_md5 = <F>; | |
close F; | |
print "old md5: $old_md5\n"; | |
} | |
system('touch /tmp/arq.txt'); | |
if (($md5 ne "") && !($md5 eq $old_md5)) { | |
print "md5: $md5\n"; | |
open F, ">/tmp/arq.txt"; | |
print F $md5; | |
close F; | |
printf "command exited with value %d", $? >> 8; | |
send_notification('Arq5', '', "Arq5 has released a new version!"); | |
} | |
} | |
###################################################################################################### | |
sub send_notification($$$) { | |
my ($app, $event, $message) = @_; | |
if ($event eq "") { | |
$event = ' '; | |
} | |
my $ws = WebService::Prowl->new(apikey => 'notmyrealkeydonteventhinkofusingit'); | |
$ws->verify || die $ws->error(); | |
$ws->add(application => "$app", | |
event => "$event", | |
description => "$message", | |
url => ""); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment