[nagiosplug] Add scripts that update man pages in drupal
"Nagios Plugin Development" <[email protected]> Sat, 3 Nov 2012 18:50:59 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: master Commit: 42a7b3d6d6392a4f1a26090a8dc6de9ae93720f1 Author: dermoth <[email protected]> Date: Sat Nov 3 19:07:40 2012 +0000 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=42a7b3d Add scripts that update man pages in drupal --- tools/np_build_from_sf | 11 +++++++++++ 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 @@ +#!/bin/bash + +set -xeu + +temp=$(mktemp -d) +trap "cd $HOME; rm -rf $temp; exit 1" EXIT +curl -sS http://nagiosplug.sourceforge.net/snapshot/nagios-plugins-HEAD.tar.gz|tar -C "$temp" --strip-components=1 -xzf - +cd $temp +./configure && make +$HOME/bin/update_man_pages + 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 @@ +#!/usr/bin/perl +use strict; +use DBI; +#$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm + +unless ($ENV{DRUPAL_PASSWORD}) { + die "Must set envvar for DRUPAL_PASSWORD"; +} + +my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD}); + +my @plugin_paths; +push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) ); + +foreach my $plugin_path (@plugin_paths) { + my $plugin = $plugin_path; + $plugin =~ s%.*/%%; + my $help_option = "--help"; + $help_option = "-h" if ($plugin eq "check_icmp"); + my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h"; + $help =~ s/</</g; + $help =~ s/>/>/g; + + my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'"); + unless ($rows == 1) { + die "Cannot find $plugin in drupal to update - create book page first"; + } + + $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'", + {}, + "<pre>".$help."</pre>"); +} + +print "Finished\n"; ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d