Code

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