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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 bin/build-docs (limited to 'bin/build-docs') 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" -- cgit v1.2.3-74-g34f1