summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-29 22:03:24 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-29 22:03:24 (GMT)
commit0b6423f9c99d9edf8c96fefd0f6c453859395aa1 (patch)
tree1c2b6b21704a294940f87c7892676998d8371707 /bin
downloadsite-0b6423f9c99d9edf8c96fefd0f6c453859395aa1.tar.gz
Import Nagios Plugins site
Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build-docs84
-rwxr-xr-xbin/build-snapshot83
-rwxr-xr-xbin/build-web-site46
-rwxr-xr-xbin/create-checksum36
-rwxr-xr-xbin/git-export40
-rwxr-xr-xbin/git-mirror84
6 files changed, 373 insertions, 0 deletions
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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19
20prefix='/home/plugins'
21repository="$prefix/repositories/nagios-plugins.git"
22branch='master'
23guidelines="$prefix/web/work/guidelines.html"
24man_dir="$prefix/web/work/man"
25myself=${0##*/}
26
27build_plugins()
28{
29 src_dir=$1
30 dst_dir=$2
31
32 cd "$src_dir"
33 tools/setup
34 ./configure --prefix="$dst_dir"
35 make install
36 make install-root
37 cd "$OLDPWD"
38}
39
40build_manpages()
41{
42 dst_dir=$1
43 man_dir=$2
44
45 find "$man_dir" -name 'check_*.md' -exec rm -f '{}' '+'
46 find "$dst_dir/libexec" -name 'check_*' | while read plugin_path
47 do
48 plugin_name=${plugin_path##*/}
49 man_file="$man_dir/${plugin_name}.md"
50
51 {
52 echo "title: $plugin_name"
53 echo 'parent: Manpages'
54 echo '---'
55 echo "# The $plugin_name Plugin"
56 echo
57 $plugin_path --help | sed 's/./ &/'
58 } >"$man_file"
59 done
60}
61
62if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ]
63then
64 echo "Usage: $myself"
65 exit 0
66fi
67
68temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX")
69log_file="$temp_dir/log"
70exec >"$log_file" 3>&2 2>&1
71trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT
72set -x
73
74src_dir="$temp_dir/src"
75dst_dir="$temp_dir/dst"
76
77git --git-dir="$repository" rev-parse --git-dir >'/dev/null'
78git --git-dir="$repository" archive --prefix="$src_dir/" "$branch" | tar -x -P -f -
79build_plugins "$src_dir" "$dst_dir"
80build_manpages "$dst_dir" "$man_dir"
81cp -p "$src_dir/doc/developer-guidelines.html" "$guidelines"
82
83trap - EXIT
84rm -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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19
20prefix='/home/plugins'
21keep_days=2
22snapshot_dir="$prefix/web/download/snapshot"
23repository="$prefix/repositories/nagios-plugins.git"
24branches=${*:-'maint master pu'}
25myself=${0##*/}
26
27make_dist()
28{
29 version=$1
30
31 tools/setup
32 ./configure
33 make dist VERSION="$version"
34}
35
36create_snapshot()
37{
38 branch=$1
39 snapshot_dir=$2
40
41 git checkout --quiet "$branch"
42 version=$(git describe --abbrev=4 'HEAD' | sed 's/release-//')
43 tarball="nagios-plugins-$version.tar.gz"
44 symlink="nagios-plugins-$branch.tar.gz"
45 make_dist "$version"
46 cp "$tarball" "$snapshot_dir"
47 git reset --quiet --hard
48 git clean --quiet --force -d -x
49
50 cd "$snapshot_dir"
51 test -e "$tarball.sha1" || shasum -a 1 -b "$tarball" >"$tarball.sha1"
52 ln -s -f "$tarball" "$symlink"
53 ln -s -f "$tarball.sha1" "$symlink.sha1"
54 cd "$OLDPWD"
55}
56
57if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ]
58then
59 echo "Usage: $myself [branch ...]"
60 exit 0
61fi
62
63temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX")
64log_file="$temp_dir/log"
65exec >"$log_file" 3>&2 2>&1
66trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT
67set -x
68
69src_dir="$temp_dir/src"
70git clone --quiet --shared "$repository" "$src_dir"
71cd "$src_dir"
72
73for branch in $branches
74do
75 git show-ref --verify "refs/heads/$branch" \
76 && create_snapshot "$branch" "$snapshot_dir"
77done
78
79cd "$OLDPWD"
80find "$snapshot_dir" -type f -mtime "+$((keep_days - 1))" -exec rm -f '{}' '+'
81find "$snapshot_dir" -type l '!' -exec test -e '{}' ';' -exec rm -f '{}' '+'
82trap - EXIT
83rm -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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18prefix='/home/plugins'
19poole_dir="$prefix/web/generator"
20site_source_dir="$prefix/exported/site/web/content"
21site_target_dir="$poole_dir/input"
22man_source_dir="$prefix/web/work/man"
23man_target_dir="$site_target_dir/doc/man"
24guidelines_source="$prefix/web/work/guidelines.html"
25guidelines_target="$site_target_dir/doc/guidelines.html"
26
27export PATH="$prefix/src/poole:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin"
28
29#
30# Collect the pieces of the site.
31#
32rsync -aH --delete "$site_source_dir/" "$site_target_dir"
33rsync -aH "$man_source_dir/" "$man_target_dir"
34cp -p "$guidelines_source" "$guidelines_target"
35
36cd "$poole_dir"
37
38#
39# See http://pythonhosted.org/Markdown/extensions/ for documentation on the
40# extensions.
41#
42exec poole.py --build \
43 --md-ext='extra' \
44 --md-ext='headerid' \
45 --md-ext='toc' \
46 --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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -u
16
17export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
18
19create_checksum()
20{
21 tarball=$1
22
23 shasum -a 1 -b "$tarball" >"$tarball.sha1"
24 touch --date="$(stat --format='%y' "$tarball")" "$tarball.sha1"
25}
26
27if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ]
28then
29 echo "Usage: $myself [branch ...]"
30 exit 0
31fi
32
33for tarball in "$@"
34do
35 create_checksum "$tarball"
36done
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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19
20export_prefix='/home/plugins/exported'
21export_branch='master'
22myself=${0##*/}
23
24if [ $# -lt 1 ]
25then
26 echo >&2 "Usage: $myself <repository> ..."
27 exit 2
28fi
29
30for repository in "$@"
31do
32 export_dir="$export_prefix/${repository##*/}"
33 export_dir=${export_dir%.git}
34
35 cd "$repository"
36 rm -r -f "$export_dir"
37 mkdir -p "$export_dir"
38 git archive "$export_branch" | tar -x -C "$export_dir" -f -
39 cd "$OLDPWD"
40done
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 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19
20temp_prefix='/run/shm'
21fourty_zeros=$(printf '%.40u' 0)
22myself=${0##*/}
23
24check_refs()
25{
26 turn=$1
27 temp_dir=$2
28
29 git show-ref | while read object ref
30 do
31 ref_dir="$temp_dir/${ref%/*}"
32 ref_file="$temp_dir/$ref"
33
34 if [ $turn -eq 2 -a -f "$ref_file" ] \
35 && grep "^1 $object$" "$ref_file" >'/dev/null'
36 then # The ref has not been modified.
37 rm -f "$ref_file"
38 else
39 mkdir -p "$ref_dir"
40 echo "$turn $object" >>"$ref_file"
41 fi
42 done
43}
44
45if [ $# -lt 1 ]
46then
47 echo >&2 "Usage: $myself <repository> ..."
48 exit 2
49fi
50
51temp_dir=$(mktemp -d "$temp_prefix/$myself.XXXXXX")
52temp_file=$(mktemp "$temp_prefix/$myself.XXXXXX")
53trap 'rm -rf "$temp_dir" "$temp_file"' EXIT
54
55for repository in "$@"
56do
57 hook="$repository/hooks/post-receive"
58 cd "$repository"
59
60 check_refs 1 "$temp_dir"
61 if ! git remote update --prune >"$temp_file" 2>&1
62 then
63 cat >&2 "$temp_file"
64 exit 1
65 fi
66 git fetch --quiet --tags
67 check_refs 2 "$temp_dir"
68
69 if [ -x "$hook" ]
70 then
71 find "$temp_dir" -type 'f' -print | while read ref_file
72 do
73 ref=${ref_file#$temp_dir/}
74 old=$(awk '$1 == "1" { print $2; exit }' "$ref_file")
75 new=$(awk '$1 == "2" { print $2; exit }' "$ref_file")
76 old=${old:-$fourty_zeros}
77 new=${new:-$fourty_zeros}
78
79 echo "$old" "$new" "$ref"
80 done >"$temp_file"
81 test -s "$temp_file" && "$hook" <"$temp_file"
82 fi
83 cd "$OLDPWD"
84done