aboutsummaryrefslogtreecommitdiff
path: root/tools/update_man_pages
blob: 5c4a901e2dab51c44337bd7583d4f5ddd5e3d65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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/</&lt;/g;
	$help =~ s/>/&gt;/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";