diff options
Diffstat (limited to 'libexec/plugins-hook')
-rwxr-xr-x | libexec/plugins-hook | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libexec/plugins-hook b/libexec/plugins-hook new file mode 100755 index 0000000..c2cce60 --- /dev/null +++ b/libexec/plugins-hook | |||
@@ -0,0 +1,37 @@ | |||
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 | hook_name=${0##*/} | ||
20 | hook_directory="/home/plugins/libexec/$hook_name.d" | ||
21 | |||
22 | if [ -d "$hook_directory" ] | ||
23 | then | ||
24 | stdin_file=$(mktemp "/tmp/.$hook_name.XXXXXX") | ||
25 | trap 'rm -f "$stdin_file"' EXIT | ||
26 | test "${hook_name##*-}" = 'receive' && cat > "$stdin_file" | ||
27 | |||
28 | for file in $(find -L "$hook_directory/." ! -name '.' -prune \ | ||
29 | -type 'f' -perm -'+x' | sort) | ||
30 | do | ||
31 | "$file" "$@" < "$stdin_file" | ||
32 | status=$? | ||
33 | test "$status" -ne 0 && return_value=$status | ||
34 | done | ||
35 | fi | ||
36 | |||
37 | exit ${return_value:-0} | ||