mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-05-28 04:35:40 -04:00
Add scripts that update man pages in drupal
This commit is contained in:
parent
c537d71a3a
commit
42a7b3d6d6
2 changed files with 45 additions and 0 deletions
11
tools/np_build_from_sf
Executable file
11
tools/np_build_from_sf
Executable file
|
|
@ -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
|
||||
|
||||
34
tools/update_man_pages
Executable file
34
tools/update_man_pages
Executable file
|
|
@ -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";
|
||||
Loading…
Reference in a new issue