mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-03-29 13:53:26 -04:00
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@936 f882894a-f735-0410-b71e-b25c423dba1c
103 lines
2.6 KiB
Bash
Executable file
103 lines
2.6 KiB
Bash
Executable file
#! /bin/bash
|
|
|
|
# Butchered version of snapshot
|
|
# Can only run on the shell compile farm server
|
|
# Will always create a snapshot of HEAD
|
|
# If want multiple snapshots, just run with "sfsnapshot [branch ...]"
|
|
# Assumes:
|
|
# ssh setup to send to shell.sf.net and $CF without password prompt
|
|
# the compile server has all the prerequisites stated at http://nagiosplug.sourceforge.net/developer-guidelines.html
|
|
# Install in cron with something like:
|
|
# 47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0
|
|
|
|
function die { echo $1; exit 1; }
|
|
|
|
# This makes the distribution. Expects $1 as CVS tag, otherwise uses HEAD
|
|
function make_dist {
|
|
if [[ -n $1 ]] ; then
|
|
cvs_rel=$1
|
|
v="$1-"
|
|
else
|
|
cvs_rel="HEAD"
|
|
v="HEAD-"
|
|
fi
|
|
|
|
# Get compile server to do the work
|
|
# Variables will be expanded locally before being run on $CF
|
|
ssh $CF <<EOF
|
|
set -x
|
|
PATH=$PATH:/usr/local/bin
|
|
[[ ! -d $COMPILE_DIR/$cvs_rel ]] && mkdir -p $COMPILE_DIR/$cvs_rel
|
|
cd $COMPILE_DIR/$cvs_rel
|
|
|
|
# Cannot use cvs export due to conflicts on second run - think this is better for cvs server
|
|
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nagiosplug co -r $cvs_rel nagiosplug
|
|
|
|
cd $PROJECT
|
|
|
|
tools/setup
|
|
|
|
./configure
|
|
|
|
# Make the Nagiosplug dist tarball
|
|
make dist VERSION=$v$DS RELEASE=snapshot
|
|
|
|
# May fail if file not generated - do not trap
|
|
mv *.gz $IN
|
|
|
|
rm -rf $COMPILE_DIR
|
|
# End ssh
|
|
EOF
|
|
}
|
|
|
|
# Set working variables
|
|
PROJECT=nagiosplug
|
|
|
|
# This is local to the compile server for faster compile
|
|
COMPILE_DIR=/tmp/tonvoon/tmp_snapshot
|
|
|
|
# Needs to be on NFS so gz file can be read on the compile shell server
|
|
IN=${HOME}/tmp_snapshot
|
|
|
|
# Where to place the generated files
|
|
OUT_SERVER="shell.sf.net"
|
|
OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
|
|
|
|
# Make sure prereqs are satisfied on server!
|
|
CF="x86-linux2"
|
|
DS=`date -u +%Y%m%d%H%M`
|
|
|
|
# Setup home directory area
|
|
[[ ! -d $IN ]] && mkdir -p $IN
|
|
|
|
# Make dists for HEAD and any others in command parameters
|
|
make_dist
|
|
for i in $* ; do
|
|
make_dist $i
|
|
done
|
|
|
|
# Check for *.gz files locally (expect NFS between cf shell server and $CF)
|
|
set -x
|
|
files=$(ls $IN/*.gz 2>/dev/null)
|
|
[[ -z $files ]] && die "No files created"
|
|
ssh -2 $OUT_SERVER "rm -f $OUT/*.gz"
|
|
scp -2 $files $OUT_SERVER:$OUT
|
|
|
|
# Create MD5 sum
|
|
ssh -2 $OUT_SERVER << EOF
|
|
cd $OUT
|
|
cat <<-END_README > README
|
|
This is the daily CVS snapshot of nagiosplug, consisting of the CVS HEAD
|
|
and any other branches
|
|
The MD5SUM is:
|
|
END_README
|
|
md5sum *.gz | tee -a README > MD5SUM
|
|
EOF
|
|
|
|
rm -f $files
|
|
|
|
# Work out success or failure
|
|
expected=$(($# + 1))
|
|
set -- $files
|
|
[[ $# -ne $expected ]] && die "Expected $expected, got $#"
|
|
exit 0
|