diff options
author | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
---|---|---|
committer | Ethan Galstad <egalstad@users.sourceforge.net> | 2002-02-28 06:42:51 +0000 |
commit | 44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch) | |
tree | a1a4d9f7b92412a17ab08f34f04eec45433048b7 /plugins-scripts/subst.in | |
parent | 54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff) | |
download | monitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz |
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/subst.in')
-rw-r--r-- | plugins-scripts/subst.in | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in new file mode 100644 index 00000000..cc0fd1b6 --- /dev/null +++ b/plugins-scripts/subst.in | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/usr/bin/awk | ||
2 | |||
3 | function which(c,path) { | ||
4 | cmd = "test -x " c; | ||
5 | |||
6 | if (system(cmd)==0) { | ||
7 | return c; | ||
8 | } | ||
9 | |||
10 | sub(/\/.*\//,"",c); | ||
11 | for (dir in path) { | ||
12 | cmd = "test -x " path[dir] "/" c; | ||
13 | if (system(cmd)==0) { | ||
14 | return path[dir] "/" c; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | |||
19 | return c; | ||
20 | } | ||
21 | |||
22 | BEGIN { | ||
23 | split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); | ||
24 | } | ||
25 | |||
26 | # scripting language (first line) | ||
27 | |||
28 | /^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} | ||
29 | /^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} | ||
30 | /^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} | ||
31 | /^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} | ||
32 | |||
33 | # Trusted path mechanism (deprecated) | ||
34 | |||
35 | /^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ { | ||
36 | sub(/\=[ \t]*['"][^"']+["']/,"='@trusted_path@' # autoconf-derived"); | ||
37 | } | ||
38 | |||
39 | /^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ { | ||
40 | sub(/\=.*$/,"='@trusted_path@' # autoconf-derived"); | ||
41 | } | ||
42 | |||
43 | # Specific programs | ||
44 | |||
45 | # | ||
46 | /^[^#]/ && /(\/.*)?\/(bin|sbin|lib|libexec)\// { | ||
47 | match($0,/(\/.*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/); | ||
48 | start=RSTART+RLENGTH; | ||
49 | c=substr($0,RSTART,RLENGTH); | ||
50 | sub(c,which(c,path)); | ||
51 | } | ||
52 | |||
53 | { | ||
54 | print; | ||
55 | } | ||
56 | |||