diff options
author | dermoth <dermoth@nagiosplugins.org> | 2012-11-03 19:07:40 (GMT) |
---|---|---|
committer | dermoth <dermoth@nagiosplugins.org> | 2012-11-03 19:07:40 (GMT) |
commit | 42a7b3d6d6392a4f1a26090a8dc6de9ae93720f1 (patch) | |
tree | 7384c5a24b40a04e55d9b979e5bdbbbd5d5869af /tools | |
parent | c537d71a3af67d0df4e1e015f6b9dcbb505f08d2 (diff) | |
download | monitoring-plugins-42a7b3d6d6392a4f1a26090a8dc6de9ae93720f1.tar.gz |
Add scripts that update man pages in drupal
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/np_build_from_sf | 11 | ||||
-rwxr-xr-x | tools/update_man_pages | 34 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tools/np_build_from_sf b/tools/np_build_from_sf new file mode 100755 index 0000000..7ba349a --- /dev/null +++ b/tools/np_build_from_sf | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -xeu | ||
4 | |||
5 | temp=$(mktemp -d) | ||
6 | trap "cd $HOME; rm -rf $temp; exit 1" EXIT | ||
7 | curl -sS http://nagiosplug.sourceforge.net/snapshot/nagios-plugins-HEAD.tar.gz|tar -C "$temp" --strip-components=1 -xzf - | ||
8 | cd $temp | ||
9 | ./configure && make | ||
10 | $HOME/bin/update_man_pages | ||
11 | |||
diff --git a/tools/update_man_pages b/tools/update_man_pages new file mode 100755 index 0000000..5c4a901 --- /dev/null +++ b/tools/update_man_pages | |||
@@ -0,0 +1,34 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use strict; | ||
3 | use DBI; | ||
4 | #$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm | ||
5 | |||
6 | unless ($ENV{DRUPAL_PASSWORD}) { | ||
7 | die "Must set envvar for DRUPAL_PASSWORD"; | ||
8 | } | ||
9 | |||
10 | my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD}); | ||
11 | |||
12 | my @plugin_paths; | ||
13 | push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) ); | ||
14 | |||
15 | foreach my $plugin_path (@plugin_paths) { | ||
16 | my $plugin = $plugin_path; | ||
17 | $plugin =~ s%.*/%%; | ||
18 | my $help_option = "--help"; | ||
19 | $help_option = "-h" if ($plugin eq "check_icmp"); | ||
20 | my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h"; | ||
21 | $help =~ s/</</g; | ||
22 | $help =~ s/>/>/g; | ||
23 | |||
24 | my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'"); | ||
25 | unless ($rows == 1) { | ||
26 | die "Cannot find $plugin in drupal to update - create book page first"; | ||
27 | } | ||
28 | |||
29 | $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'", | ||
30 | {}, | ||
31 | "<pre>".$help."</pre>"); | ||
32 | } | ||
33 | |||
34 | print "Finished\n"; | ||