summaryrefslogtreecommitdiffstats
path: root/tools/sfsnapshot-upload
diff options
context:
space:
mode:
Diffstat (limited to 'tools/sfsnapshot-upload')
-rwxr-xr-xtools/sfsnapshot-upload125
1 files changed, 0 insertions, 125 deletions
diff --git a/tools/sfsnapshot-upload b/tools/sfsnapshot-upload
deleted file mode 100755
index d8ebcc5..0000000
--- a/tools/sfsnapshot-upload
+++ /dev/null
@@ -1,125 +0,0 @@
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 in sfsnapshot-upload 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=~/bin/sfsnapshotgit
21
22# Retention time for snapshots (in minutes), 0 for no retention.
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
42# If we don't keep old snapshots we can clean up all links now
43if [ $CLEAN_TIME -eq 0 ]
44then
45 find $SFSNAP_DEST -type l -name '*.gz' -delete
46fi
47
48for head in $HEADS ; do
49 # This runs the actual snapshot code. It creates new snapshots if needed and always
50 # return the current snapshot file (even if it wasn't modified).
51 file=$($sfsnapshot $head)
52 # Create main head link
53 ln -sf $file $SFSNAP_DEST/nagios-plugins-$head.tar.gz
54
55 # Keep links by branch name too if we keep old snapshots, so we can keep tracks of them
56 if [ $CLEAN_TIME -gt 0 -a ! -e "$SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}" ]
57 then
58 ln -s $file $SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}
59 fi
60
61 # Cleanup and re-create backward-compatibility links
62 if [ "$head" == "master" ]
63 then
64 for cclean in $COMPATCLEANUP
65 do
66 find $SFSNAP_DEST -type l -name "nagios-plugins-$cclean.tar.gz" -delete
67 done
68 for compat in $COMPATLINKS
69 do
70 ln -sf $file $SFSNAP_DEST/nagios-plugins-$compat.tar.gz
71 done
72 fi
73done
74
75cd $SFSNAP_DEST
76
77# Clean up links older than $CLEAN_TIME if needed
78if [ $CLEAN_TIME -gt 0 ]
79then
80 find . -type l -name '*.gz' -mmin +$CLEAN_TIME -delete
81fi
82
83# Now clean up files that we don't need
84# 1. loop over actual snapshots
85for dest in `find . -type f -name '*.gz' |xargs -n 1 basename`
86do
87 # 2. Loop over the list of linked-to files
88 for current in `find . -type l -name '*.gz' |xargs -n 1 readlink | sort | uniq`
89 do
90 if [ "$current" == "$dest" ]
91 then
92 # File is being linked to - don't delete (continue first loop)
93 continue 2
94 fi
95 done
96 # No link to this file, we can drop it
97 rm -f $dest
98done
99
100# Create MD5 sum
101cat <<-END_README > README
102 This is the latest snapshot of nagiosplug, consisting of the following
103 head(s):
104 $HEADS
105
106 The nagios-plugins-<head>.tar.gz link will always point to the latest
107 corresponding snapshot (nagios-plugins-<git-describe>.tar.gz).
108
109 For backward-compatibility, the nagios-plugins-HEAD.tar.gz and
110 nagios-plugins-trunk-<ts>.tar.gz point to their corresponding "master"
111 head.
112
113 The tarballs will only be updated when a change has been made. The
114 MD5SUM file is updated every time the snapshot script runs.
115
116 The MD5SUMs are:
117 END_README
118md5sum *.gz | tee -a README > MD5SUM
119
120# Sync the files
121[ -n "$OUT_SERVER" ] && OUT_SERVER="$OUT_SERVER:"
122rsync -a --exclude=.htaccess --exclude=HEADER.html --delete "$SFSNAP_DEST/" "$OUT_SERVER$OUT_PATH"
123
124trap - EXIT
125