Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

matthewg42

By: a guest on Sep 5th, 2008  |  syntax: Bash  |  size: 1.35 KB  |  views: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. RSS="https://sourceforge.net/export/rss2_projnews.php?group_id=48857&rss_fulltext=1"
  4. WORK="/home/matthew/projects/stellarium_gubbins/web_backup/stellarium.org"
  5.  
  6. main () {
  7.         # running from cron, so must set the working directly explicitly
  8.         cd "$WORK"
  9.  
  10.         case "$1" in
  11.         check)
  12.                 get_and_patch test.xml
  13.                 check test.xml news.xml
  14.                 ;;
  15.         *)
  16.                 get_and_patch news.xml
  17.                 upload news.xml
  18.                 ;;
  19.         esac
  20. }
  21.  
  22. get_and_patch () {
  23.         GET "$RSS" > "$1"
  24.         # patch the news feed where it got truncated
  25.         perl -i -npe 's|(win32 package can be found here:)|$1 <a href="http://porpoisehead.net/41">http://porpoisehead.net/41</a>|;' "$1"
  26. }
  27.  
  28. check () {
  29.         grep -v "RSS generated by SourceForge.net at" "$1" > "$1.test"
  30.         grep -v "RSS generated by SourceForge.net at" "$2" > "$2.test"
  31.  
  32.         # and output gets mailed to the calling user by crond
  33.         cmp -s "$1.test" "$2.test" || echo "new stellarium news found, run the update."
  34.         rm -f "$1.test" "$2.test"
  35. }
  36.  
  37. upload () {
  38.         # stellarium_web is configured in my ~/.ssh/config with the proper username and key id
  39.         scp "$1" stellarium_web:/home/groups/s/st/stellarium/htdocs/news.xml && echo "done"
  40. }
  41.  
  42. main "$@"