diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-10-25 20:43:04 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-10-25 20:43:04 +0000 |
commit | cf0dee616af1f417daa76e746dfaa50947009fac (patch) | |
tree | 58e5ae5ef39f76bce53c7b09a49dfbaf0324cfac /tools/sync_website | |
parent | 745b58a68bf2e60a6652475c56a1cff0aa6ebf9f (diff) | |
download | monitoring-plugins-cf0dee616af1f417daa76e746dfaa50947009fac.tar.gz |
Automatically update website with --help output. Cosmetic
fixes for some help output
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1810 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'tools/sync_website')
-rwxr-xr-x | tools/sync_website | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/sync_website b/tools/sync_website new file mode 100755 index 00000000..8489bc54 --- /dev/null +++ b/tools/sync_website @@ -0,0 +1,44 @@ +#!/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 $pid = open(F, "-|", qw(ssh -n -N -L 25555:127.0.0.1:3306 nagiosplugins.org)); + +# Allow time for ssh tunnel to be created +sleep 2; + +# To stop the death of ssh tunnel being defunct +$SIG{CHLD} = 'IGNORE'; + +END { kill 'INT', $pid if $pid }; + +my $dbh = DBI->connect("DBI:mysql:database=drupal;host=127.0.0.1;port=25555", "drupal", $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"; |