diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/build-docs | 84 | ||||
| -rwxr-xr-x | bin/build-snapshot | 83 | ||||
| -rwxr-xr-x | bin/build-web-site | 46 | ||||
| -rwxr-xr-x | bin/create-checksum | 36 | ||||
| -rwxr-xr-x | bin/git-export | 40 | ||||
| -rwxr-xr-x | bin/git-mirror | 84 |
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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 19 | |||
| 20 | prefix='/home/plugins' | ||
| 21 | repository="$prefix/repositories/nagios-plugins.git" | ||
| 22 | branch='master' | ||
| 23 | guidelines="$prefix/web/work/guidelines.html" | ||
| 24 | man_dir="$prefix/web/work/man" | ||
| 25 | myself=${0##*/} | ||
| 26 | |||
| 27 | build_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 | |||
| 40 | build_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 | |||
| 62 | if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] | ||
| 63 | then | ||
| 64 | echo "Usage: $myself" | ||
| 65 | exit 0 | ||
| 66 | fi | ||
| 67 | |||
| 68 | temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") | ||
| 69 | log_file="$temp_dir/log" | ||
| 70 | exec >"$log_file" 3>&2 2>&1 | ||
| 71 | trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT | ||
| 72 | set -x | ||
| 73 | |||
| 74 | src_dir="$temp_dir/src" | ||
| 75 | dst_dir="$temp_dir/dst" | ||
| 76 | |||
| 77 | git --git-dir="$repository" rev-parse --git-dir >'/dev/null' | ||
| 78 | git --git-dir="$repository" archive --prefix="$src_dir/" "$branch" | tar -x -P -f - | ||
| 79 | build_plugins "$src_dir" "$dst_dir" | ||
| 80 | build_manpages "$dst_dir" "$man_dir" | ||
| 81 | cp -p "$src_dir/doc/developer-guidelines.html" "$guidelines" | ||
| 82 | |||
| 83 | trap - EXIT | ||
| 84 | 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 @@ | |||
| 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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 19 | |||
| 20 | prefix='/home/plugins' | ||
| 21 | keep_days=2 | ||
| 22 | snapshot_dir="$prefix/web/download/snapshot" | ||
| 23 | repository="$prefix/repositories/nagios-plugins.git" | ||
| 24 | branches=${*:-'maint master pu'} | ||
| 25 | myself=${0##*/} | ||
| 26 | |||
| 27 | make_dist() | ||
| 28 | { | ||
| 29 | version=$1 | ||
| 30 | |||
| 31 | tools/setup | ||
| 32 | ./configure | ||
| 33 | make dist VERSION="$version" | ||
| 34 | } | ||
| 35 | |||
| 36 | create_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 | |||
| 57 | if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] | ||
| 58 | then | ||
| 59 | echo "Usage: $myself [branch ...]" | ||
| 60 | exit 0 | ||
| 61 | fi | ||
| 62 | |||
| 63 | temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") | ||
| 64 | log_file="$temp_dir/log" | ||
| 65 | exec >"$log_file" 3>&2 2>&1 | ||
| 66 | trap 'tail -n 25 "$log_file" >&3; rm -rf "$temp_dir"' EXIT | ||
| 67 | set -x | ||
| 68 | |||
| 69 | src_dir="$temp_dir/src" | ||
| 70 | git clone --quiet --shared "$repository" "$src_dir" | ||
| 71 | cd "$src_dir" | ||
| 72 | |||
| 73 | for branch in $branches | ||
| 74 | do | ||
| 75 | git show-ref --verify "refs/heads/$branch" \ | ||
| 76 | && create_snapshot "$branch" "$snapshot_dir" | ||
| 77 | done | ||
| 78 | |||
| 79 | cd "$OLDPWD" | ||
| 80 | find "$snapshot_dir" -type f -mtime "+$((keep_days - 1))" -exec rm -f '{}' '+' | ||
| 81 | find "$snapshot_dir" -type l '!' -exec test -e '{}' ';' -exec rm -f '{}' '+' | ||
| 82 | trap - EXIT | ||
| 83 | 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 @@ | |||
| 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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | prefix='/home/plugins' | ||
| 19 | poole_dir="$prefix/web/generator" | ||
| 20 | site_source_dir="$prefix/exported/site/web/content" | ||
| 21 | site_target_dir="$poole_dir/input" | ||
| 22 | man_source_dir="$prefix/web/work/man" | ||
| 23 | man_target_dir="$site_target_dir/doc/man" | ||
| 24 | guidelines_source="$prefix/web/work/guidelines.html" | ||
| 25 | guidelines_target="$site_target_dir/doc/guidelines.html" | ||
| 26 | |||
| 27 | export 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 | # | ||
| 32 | rsync -aH --delete "$site_source_dir/" "$site_target_dir" | ||
| 33 | rsync -aH "$man_source_dir/" "$man_target_dir" | ||
| 34 | cp -p "$guidelines_source" "$guidelines_target" | ||
| 35 | |||
| 36 | cd "$poole_dir" | ||
| 37 | |||
| 38 | # | ||
| 39 | # See http://pythonhosted.org/Markdown/extensions/ for documentation on the | ||
| 40 | # extensions. | ||
| 41 | # | ||
| 42 | exec 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 | |||
| 15 | set -u | ||
| 16 | |||
| 17 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 18 | |||
| 19 | create_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 | |||
| 27 | if [ $# -eq 1 ] && [ "x$1" = 'x-h' -o "x$1" = 'x--help' ] | ||
| 28 | then | ||
| 29 | echo "Usage: $myself [branch ...]" | ||
| 30 | exit 0 | ||
| 31 | fi | ||
| 32 | |||
| 33 | for tarball in "$@" | ||
| 34 | do | ||
| 35 | create_checksum "$tarball" | ||
| 36 | 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 @@ | |||
| 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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 19 | |||
| 20 | export_prefix='/home/plugins/exported' | ||
| 21 | export_branch='master' | ||
| 22 | myself=${0##*/} | ||
| 23 | |||
| 24 | if [ $# -lt 1 ] | ||
| 25 | then | ||
| 26 | echo >&2 "Usage: $myself <repository> ..." | ||
| 27 | exit 2 | ||
| 28 | fi | ||
| 29 | |||
| 30 | for repository in "$@" | ||
| 31 | do | ||
| 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" | ||
| 40 | 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 @@ | |||
| 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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | |||
| 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 19 | |||
| 20 | temp_prefix='/run/shm' | ||
| 21 | fourty_zeros=$(printf '%.40u' 0) | ||
| 22 | myself=${0##*/} | ||
| 23 | |||
| 24 | check_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 | |||
| 45 | if [ $# -lt 1 ] | ||
| 46 | then | ||
| 47 | echo >&2 "Usage: $myself <repository> ..." | ||
| 48 | exit 2 | ||
| 49 | fi | ||
| 50 | |||
| 51 | temp_dir=$(mktemp -d "$temp_prefix/$myself.XXXXXX") | ||
| 52 | temp_file=$(mktemp "$temp_prefix/$myself.XXXXXX") | ||
| 53 | trap 'rm -rf "$temp_dir" "$temp_file"' EXIT | ||
| 54 | |||
| 55 | for repository in "$@" | ||
| 56 | do | ||
| 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" | ||
| 84 | done | ||
