diff options
Diffstat (limited to 'bin/build-docs')
| -rwxr-xr-x | bin/build-docs | 84 |
1 files changed, 84 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" | ||
