sfsnapshot 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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
  41. # Make the Nagiosplug dist tarball
  42. make dist
  43. # End ssh
  44. EOF
  45. }
  46. # Set working variables
  47. PROJECT=nagiosplug
  48. IN=${HOME}/tmp_snapshot
  49. OUT_SERVER="shell.sf.net"
  50. OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
  51. CF="usf-cf-x86-linux-2"
  52. DS=`date -u +%Y%m%d%H%M`
  53. # Make dists for HEAD and any others in command parameters
  54. make_dist
  55. for i in $* ; do
  56. make_dist $i
  57. done
  58. # Check for *.gz files locally (expect NFS between cf shell server and $CF)
  59. set -x
  60. files=$(ls $IN/*/$PROJECT/*.gz 2>/dev/null)
  61. [[ -z $files ]] && die "No files created"
  62. ssh $OUT_SERVER "rm -f $OUT/*.gz"
  63. scp $files $OUT_SERVER:$OUT
  64. # Create MD5 sum
  65. ssh $OUT_SERVER << EOF
  66. cd $OUT
  67. cat <<-END_README > README
  68. This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
  69. and any other branches
  70. The MD5SUM is:
  71. END_README
  72. md5sum *.gz | tee -a README > MD5SUM
  73. EOF
  74. rm -f $files
  75. # Work out success or failure
  76. expected=$(($# + 1))
  77. set -- $files
  78. [[ $# -ne $expected ]] && die "Expected $expected, got $#"
  79. exit 0