summaryrefslogtreecommitdiffstats
path: root/tools/sfsnapshot-upload
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-10-25 10:33:10 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-10-29 14:17:30 -0400
commit61e77e54d71579d3717963ae6286922aed9d12d9 (patch)
tree274f6edd608dd08238dbb51c5e352b36b4f36f64 /tools/sfsnapshot-upload
parente2ba9ba91fbfcad53892c7ecfb1842dd9e62962a (diff)
downloadmonitoring-plugins-61e77e54d71579d3717963ae6286922aed9d12d9.tar.gz
Add snapshots upload scripts
Diffstat (limited to 'tools/sfsnapshot-upload')
-rwxr-xr-xtools/sfsnapshot-upload100
1 files changed, 100 insertions, 0 deletions
diff --git a/tools/sfsnapshot-upload b/tools/sfsnapshot-upload
new file mode 100755
index 00000000..1507cffc
--- /dev/null
+++ b/tools/sfsnapshot-upload
@@ -0,0 +1,100 @@
1#!/bin/bash
2# sfsnapshot-upload - Snapshot upload script using sfsnapshotgit
3# Original author: Thomas Guyot-Sionnest <tguyot@gmail.com>
4#
5# This script uses sfsnapshotgit to update the snapshot is needed and upload
6# it to SourceForge. The branches to create snapshot from can be given as an
7# argument, otherwise the default is master.
8
9# Handle command errors (-e) and coder sleep deprivation issues (-u)
10set -eu
11trap 'echo "An error occurred at line $LINENO"; exit 1' EXIT
12
13# This can be used to override the default in sfsnapshotgit:
14export SFSNAP_REPO=~/staging/nagiosplugins
15export SFSNAP_ORIGIN=origin
16export SFSNAP_DEST=~/staging/snapshot
17
18## Some stuff that shouldn't change often...
19# The file we'll use to create the snapshot
20sfsnapshot=~/sfsnapshotgit
21
22# Retention time for snapshots (in minutes)
23CLEAN_TIME=1440
24
25# Where to place the generated files
26OUT_SERVER="tonvoon@frs.sourceforge.net"
27OUT_PATH="/home/groups/n/na/nagiosplug/htdocs/snapshot"
28
29# Links to always point to the master branch for backwards-compatibility
30COMPATLINKS="HEAD trunk-`date -u +%Y%m%d%H%M`"
31# And compatibility links to always delete except the last one
32COMPATCLEANUP="trunk-*"
33
34# If one or more argument is given, this is the branches to create the snapshots from
35if [ $# -eq 0 ]
36then
37 HEADS='master'
38else
39 HEADS=$@
40fi
41
42for head in $HEADS ; do
43 file=$($sfsnapshot $head)
44 ln -sf $file $SFSNAP_DEST/nagios-plugins-$head.tar.gz
45 # Keep links by branch name too
46 [ -f "$SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}" ] || ln -s $file $SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}
47 if [ "$head" == "master" ]
48 then
49 for cclean in $COMPATCLEANUP
50 do
51 find . -type l -name "nagios-plugins-$cclean.tar.gz" -delete
52 done
53 for compat in $COMPATLINKS
54 do
55 ln -sf $file $SFSNAP_DEST/nagios-plugins-$compat.tar.gz
56 done
57 fi
58done
59
60# Cleanup old snapshots and links...
61cd $SFSNAP_DEST
62
63# Clean up links older than $CLEAN_TIME
64find . -type l -name '*.gz' -mmin +$CLEAN_TIME -delete
65
66# Then clean up files that we don't need
67for dest in `find . -type f -name '*.gz' |xargs -n 1 basename`
68do
69 # Loop over the list of linked-to files
70 for current in `find . -type l -name '*.gz' |xargs -n 1 readlink | uniq`
71 do
72 if [ "$current" == "$dest" ]
73 then
74 continue 2
75 fi
76 done
77 rm -f $dest
78done
79
80# Create MD5 sum
81cat <<-END_README > README
82This is the latest snapshot of nagiosplug, consisting of the following
83head(s):
84 $HEADS
85
86The nagios-plugins-<head>.tar.gz link will always point to the latest
87corresponding snapshot (nagios-plugins-<git-describe>.tar.gz).
88
89For backward-compatibility, the nagios-plugins-HEAD.tar.gz and
90nagios-plugins-trunk-<ts> point to their corresponding "master" head.
91
92The MD5SUM are:
93END_README
94md5sum *.gz | tee -a README > MD5SUM
95
96# Sync the files
97rsync -a --exclude=.htaccess --exclude=HEADER.html --delete "$SFSNAP_DEST/" "$OUT_SERVER:$OUT_PATH"
98
99trap - EXIT
100