summaryrefslogtreecommitdiffstats
path: root/bin/build-docs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/build-docs')
-rwxr-xr-xbin/build-docs84
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
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"