sfsnapshot 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/bash
  2. # Butchered version of snapshot
  3. # Can only run on the shell compile farm server
  4. # Will always create a snapshot of HEAD
  5. # If want multiple snapshots, just run with "sfsnapshot {branch} [branch2 ...]"
  6. # Assumes:
  7. # ssh setup to send to shell.sf.net and $CF without password prompt
  8. # autconf and automake installed on shell cf at v 2.57 & 1.72 and in PATH
  9. # Install in cron with something like:
  10. # 47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0
  11. function die { echo $1; exit 1; }
  12. # This makes the distribution. Expects $1 as CVS tag, otherwise uses HEAD
  13. function make_dist {
  14. if [[ -n $1 ]] ; then
  15. cvs_rel=$1
  16. v="$1-"
  17. else
  18. cvs_rel="HEAD"
  19. v=""
  20. fi
  21. # Get compile server to do the work
  22. # Variables will be expanded locally before being run on $CF
  23. ssh $CF <<-EOF
  24. set -x
  25. PATH=$PATH
  26. [[ ! -d $IN/$cvs_rel ]] && mkdir -p $IN/$cvs_rel
  27. cd $IN/$cvs_rel
  28. if [[ -d $PROJECT ]] ; then
  29. cd $PROJECT
  30. rm configure.in
  31. cvs update -r $cvs_rel
  32. else
  33. cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
  34. cd $PROJECT
  35. fi
  36. sed 's/^VER=.*/VER=$v$DS/;s/^REL=.*/REL=snapshot/' configure.in > configure.tmp
  37. mv configure.tmp configure.in
  38. tools/setup
  39. ./configure
  40. # Make the Nagiosplug dist tarball
  41. make dist
  42. # End ssh
  43. EOF
  44. }
  45. # Set working variables
  46. PROJECT=nagiosplug
  47. IN=${HOME}/tmp_snapshot
  48. OUT_SERVER="shell.sf.net"
  49. OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
  50. CF="usf-cf-x86-linux-2"
  51. DS=`date -u +%Y%m%d%H%M`
  52. # Make dists for HEAD and any others in command parameters
  53. make_dist
  54. for i in $* ; do
  55. make_dist $i
  56. done
  57. # Check for *.gz files locally (expect NFS between cf shell server and $CF)
  58. set -x
  59. files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
  60. [[ -z $files ]] && die "No files created"
  61. ssh $OUT_SERVER "rm -f $OUT/*.gz"
  62. scp $files $OUT_SERVER:$OUT
  63. # Create MD5 sum
  64. ssh $OUT_SERVER << EOF
  65. cd $OUT
  66. cat <<-END_README > README
  67. This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
  68. and any other branches
  69. The MD5SUM is:
  70. END_README
  71. md5sum *.gz | tee -a README > MD5SUM
  72. EOF
  73. rm -f $files
  74. # Work out success or failure
  75. expected=$(($# + 1))
  76. set -- $files
  77. [[ $# -ne $expected ]] && die "Expected $expected, got $#"
  78. exit 0