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-docs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/build-snapshot | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/build-web-site | 46 +++++++++++++++++++++++++++++ bin/create-checksum | 36 +++++++++++++++++++++++ bin/git-export | 40 +++++++++++++++++++++++++ bin/git-mirror | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 373 insertions(+) create mode 100755 bin/build-docs create mode 100755 bin/build-snapshot create mode 100755 bin/build-web-site create mode 100755 bin/create-checksum create mode 100755 bin/git-export create mode 100755 bin/git-mirror (limited to 'bin') diff --git a/bin/build-docs b/bin/build-docs new file mode 100755 index 0000000..f3e29c5 --- /dev/null +++ b/bin/build-docs @@ -0,0 +1,84 @@ +#!/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' +repository="$prefix/repositories/nagios-plugins.git" +branch='master' +guidelines="$prefix/web/work/guidelines.html" +man_dir="$prefix/web/work/man" +myself=${0##*/} + +build_plugins() +{ + src_dir=$1 + dst_dir=$2 + + cd "$src_dir" + tools/setup + ./configure --prefix="$dst_dir" + make install + make install-root + cd "$OLDPWD" +} + +build_manpages() +{ + dst_dir=$1 + man_dir=$2 + + find "$man_dir" -name 'check_*.md' -exec rm -f '{}' '+' + find "$dst_dir/libexec" -name 'check_*' | while read plugin_path + do + plugin_name=${plugin_path##*/} + man_file="$man_dir/${plugin_name}.md" + + { + echo "title: $plugin_name" + echo 'parent: Manpages' + echo '---' + echo "# The $plugin_name Plugin" + echo + $plugin_path --help | sed 's/./ &/' + } >"$man_file" + done +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself" + 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" +dst_dir="$temp_dir/dst" + +git --git-dir="$repository" rev-parse --git-dir >'/dev/null' +git --git-dir="$repository" archive --prefix="$src_dir/" "$branch" | tar -x -P -f - +build_plugins "$src_dir" "$dst_dir" +build_manpages "$dst_dir" "$man_dir" +cp -p "$src_dir/doc/developer-guidelines.html" "$guidelines" + +trap - EXIT +rm -rf "$temp_dir" 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" diff --git a/bin/build-web-site b/bin/build-web-site new file mode 100755 index 0000000..95ac355 --- /dev/null +++ b/bin/build-web-site @@ -0,0 +1,46 @@ +#!/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 + +prefix='/home/plugins' +poole_dir="$prefix/web/generator" +site_source_dir="$prefix/exported/site/web/content" +site_target_dir="$poole_dir/input" +man_source_dir="$prefix/web/work/man" +man_target_dir="$site_target_dir/doc/man" +guidelines_source="$prefix/web/work/guidelines.html" +guidelines_target="$site_target_dir/doc/guidelines.html" + +export PATH="$prefix/src/poole:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" + +# +# Collect the pieces of the site. +# +rsync -aH --delete "$site_source_dir/" "$site_target_dir" +rsync -aH "$man_source_dir/" "$man_target_dir" +cp -p "$guidelines_source" "$guidelines_target" + +cd "$poole_dir" + +# +# See http://pythonhosted.org/Markdown/extensions/ for documentation on the +# extensions. +# +exec poole.py --build \ + --md-ext='extra' \ + --md-ext='headerid' \ + --md-ext='toc' \ + --md-ext='wikilinks' diff --git a/bin/create-checksum b/bin/create-checksum new file mode 100755 index 0000000..7d6ac1f --- /dev/null +++ b/bin/create-checksum @@ -0,0 +1,36 @@ +#!/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 -u + +export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' + +create_checksum() +{ + tarball=$1 + + shasum -a 1 -b "$tarball" >"$tarball.sha1" + touch --date="$(stat --format='%y' "$tarball")" "$tarball.sha1" +} + +if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] +then + echo "Usage: $myself [branch ...]" + exit 0 +fi + +for tarball in "$@" +do + create_checksum "$tarball" +done diff --git a/bin/git-export b/bin/git-export new file mode 100755 index 0000000..fc76081 --- /dev/null +++ b/bin/git-export @@ -0,0 +1,40 @@ +#!/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' + +export_prefix='/home/plugins/exported' +export_branch='master' +myself=${0##*/} + +if [ $# -lt 1 ] +then + echo >&2 "Usage: $myself ..." + exit 2 +fi + +for repository in "$@" +do + export_dir="$export_prefix/${repository##*/}" + export_dir=${export_dir%.git} + + cd "$repository" + rm -r -f "$export_dir" + mkdir -p "$export_dir" + git archive "$export_branch" | tar -x -C "$export_dir" -f - + cd "$OLDPWD" +done diff --git a/bin/git-mirror b/bin/git-mirror new file mode 100755 index 0000000..af54a14 --- /dev/null +++ b/bin/git-mirror @@ -0,0 +1,84 @@ +#!/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' + +temp_prefix='/run/shm' +fourty_zeros=$(printf '%.40u' 0) +myself=${0##*/} + +check_refs() +{ + turn=$1 + temp_dir=$2 + + git show-ref | while read object ref + do + ref_dir="$temp_dir/${ref%/*}" + ref_file="$temp_dir/$ref" + + if [ $turn -eq 2 -a -f "$ref_file" ] \ + && grep "^1 $object$" "$ref_file" >'/dev/null' + then # The ref has not been modified. + rm -f "$ref_file" + else + mkdir -p "$ref_dir" + echo "$turn $object" >>"$ref_file" + fi + done +} + +if [ $# -lt 1 ] +then + echo >&2 "Usage: $myself ..." + exit 2 +fi + +temp_dir=$(mktemp -d "$temp_prefix/$myself.XXXXXX") +temp_file=$(mktemp "$temp_prefix/$myself.XXXXXX") +trap 'rm -rf "$temp_dir" "$temp_file"' EXIT + +for repository in "$@" +do + hook="$repository/hooks/post-receive" + cd "$repository" + + check_refs 1 "$temp_dir" + if ! git remote update --prune >"$temp_file" 2>&1 + then + cat >&2 "$temp_file" + exit 1 + fi + git fetch --quiet --tags + check_refs 2 "$temp_dir" + + if [ -x "$hook" ] + then + find "$temp_dir" -type 'f' -print | while read ref_file + do + ref=${ref_file#$temp_dir/} + old=$(awk '$1 == "1" { print $2; exit }' "$ref_file") + new=$(awk '$1 == "2" { print $2; exit }' "$ref_file") + old=${old:-$fourty_zeros} + new=${new:-$fourty_zeros} + + echo "$old" "$new" "$ref" + done >"$temp_file" + test -s "$temp_file" && "$hook" <"$temp_file" + fi + cd "$OLDPWD" +done -- cgit v1.2.3-74-g34f1