update_man_pages 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl
  2. use strict;
  3. use DBI;
  4. #$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm
  5. unless ($ENV{DRUPAL_PASSWORD}) {
  6. die "Must set envvar for DRUPAL_PASSWORD";
  7. }
  8. my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD});
  9. my @plugin_paths;
  10. push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) );
  11. foreach my $plugin_path (@plugin_paths) {
  12. my $plugin = $plugin_path;
  13. $plugin =~ s%.*/%%;
  14. my $help_option = "--help";
  15. $help_option = "-h" if ($plugin eq "check_icmp");
  16. my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h";
  17. $help =~ s/</&lt;/g;
  18. $help =~ s/>/&gt;/g;
  19. my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'");
  20. unless ($rows == 1) {
  21. die "Cannot find $plugin in drupal to update - create book page first";
  22. }
  23. $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'",
  24. {},
  25. "<pre>".$help."</pre>");
  26. }
  27. print "Finished\n";