From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- bin/build-snapshot | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 bin/build-snapshot (limited to 'bin/build-snapshot') diff --git a/bin/build-snapshot b/bin/build-snapshot new file mode 100755 index 0000000..18777a5 --- /dev/null +++ b/bin/build-snapshot @@ -0,0 +1,83 @@ +#!/bin/sh +# +# Copyright (c) 2013 Nagios Plugins Development Team +# +# Originally written by Holger Weiss . +# +# This file is free software; the Nagios Plugins Development Team gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY, to the extent permitted by law; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set -e +set -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +prefix='/home/plugins' +keep_days=2 +snapshot_dir="$prefix/web/download/snapshot" +repository="$prefix/repositories/nagios-plugins.git" +branches=${*:-'maint master pu'} +myself=${0##*/} + +make_dist() +{ + version=$1 + + tools/setup + ./configure + make dist VERSION="$version" +} + +create_snapshot() +{ + branch=$1 + snapshot_dir=$2 + + git checkout --quiet "$branch" + version=$(git describe --abbrev=4 'HEAD' | sed 's/release-//') + tarball="nagios-plugins-$version.tar.gz" + symlink="nagios-plugins-$branch.tar.gz" + make_dist "$version" + cp "$tarball" "$snapshot_dir" + git reset --quiet --hard + git clean --quiet --force -d -x + + cd "$snapshot_dir" + test -e "$tarball.sha1" || shasum -a 1 -b "$tarball" >"$tarball.sha1" + ln -s -f "$tarball" "$symlink" + ln -s -f "$tarball.sha1" "$symlink.sha1" + cd "$OLDPWD" +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself [branch ...]" + exit 0 +fi + +temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") +log_file="$temp_dir/log" +exec >"$log_file" 3>&2 2>&1 +trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT +set -x + +src_dir="$temp_dir/src" +git clone --quiet --shared "$repository" "$src_dir" +cd "$src_dir" + +for branch in $branches +do + git show-ref --verify "refs/heads/$branch" \ + && create_snapshot "$branch" "$snapshot_dir" +done + +cd "$OLDPWD" +find "$snapshot_dir" -type f -mtime "+$((keep_days - 1))" -exec rm -f '{}' '+' +find "$snapshot_dir" -type l '!' -exec test -e '{}' ';' -exec rm -f '{}' '+' +trap - EXIT +rm -rf "$temp_dir" -- cgit v1.2.3-74-g34f1