
matthewg42
By: a guest on
Sep 5th, 2008 | syntax:
Bash | size: 1.35 KB | hits: 34 | expires: Never
#!/bin/bash
RSS="https://sourceforge.net/export/rss2_projnews.php?group_id=48857&rss_fulltext=1"
WORK="/home/matthew/projects/stellarium_gubbins/web_backup/stellarium.org"
main () {
# running from cron, so must set the working directly explicitly
cd "$WORK"
case "$1" in
check)
get_and_patch test.xml
check test.xml news.xml
;;
*)
get_and_patch news.xml
upload news.xml
;;
esac
}
get_and_patch () {
GET "$RSS" > "$1"
# patch the news feed where it got truncated
perl -i -npe 's|(win32 package can be found here:)|$1 <a href="http://porpoisehead.net/41">http://porpoisehead.net/41</a>|;' "$1"
}
check () {
grep -v "RSS generated by SourceForge.net at" "$1" > "$1.test"
grep -v "RSS generated by SourceForge.net at" "$2" > "$2.test"
# and output gets mailed to the calling user by crond
cmp -s "$1.test" "$2.test" || echo "new stellarium news found, run the update."
rm -f "$1.test" "$2.test"
}
upload () {
# stellarium_web is configured in my ~/.ssh/config with the proper username and key id
scp "$1" stellarium_web:/home/groups/s/st/stellarium/htdocs/news.xml && echo "done"
}
main "$@"