diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/mail_error | 25 | ||||
-rwxr-xr-x | tools/np_build_from_sf | 11 | ||||
-rwxr-xr-x | tools/sfsnapshot | 119 | ||||
-rwxr-xr-x | tools/sfsnapshot-upload | 125 | ||||
-rwxr-xr-x | tools/sfsnapshotgit | 77 | ||||
-rwxr-xr-x | tools/sfupload | 27 | ||||
-rwxr-xr-x | tools/sfwebcron | 35 | ||||
-rwxr-xr-x | tools/sync_website | 44 | ||||
-rwxr-xr-x | tools/update_man_pages | 34 |
9 files changed, 0 insertions, 497 deletions
diff --git a/tools/mail_error b/tools/mail_error deleted file mode 100755 index aabb579..0000000 --- a/tools/mail_error +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # mail_error -o file -m email_address command | ||
3 | # Runs command from cron and redirects all output to file | ||
4 | # If command rc != 0, sends output to email_address | ||
5 | |||
6 | function die { echo $1 ; exit 1; } | ||
7 | |||
8 | # Must be export so that sfsnapshot uses correct versions | ||
9 | # of GNU toolchain | ||
10 | export PATH=$HOME/bin:$HOME/local/bin:$PATH | ||
11 | |||
12 | while getopts "o:m:" c; do | ||
13 | case $c in | ||
14 | o) output_file=$OPTARG;; | ||
15 | m) email=$OPTARG;; | ||
16 | \*) echo "oops";; | ||
17 | esac | ||
18 | done | ||
19 | shift $(($OPTIND-1)) | ||
20 | |||
21 | [[ -z $1 ]] && die "Must specify command" | ||
22 | |||
23 | if ! "$@" > $output_file 2>&1 ; then | ||
24 | mail -s "mail_error fail: $1" $email < $output_file | ||
25 | fi | ||
diff --git a/tools/np_build_from_sf b/tools/np_build_from_sf deleted file mode 100755 index 7ba349a..0000000 --- a/tools/np_build_from_sf +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -xeu | ||
4 | |||
5 | temp=$(mktemp -d) | ||
6 | trap "cd $HOME; rm -rf $temp; exit 1" EXIT | ||
7 | curl -sS http://nagiosplug.sourceforge.net/snapshot/nagios-plugins-HEAD.tar.gz|tar -C "$temp" --strip-components=1 -xzf - | ||
8 | cd $temp | ||
9 | ./configure && make | ||
10 | $HOME/bin/update_man_pages | ||
11 | |||
diff --git a/tools/sfsnapshot b/tools/sfsnapshot deleted file mode 100755 index 3b71219..0000000 --- a/tools/sfsnapshot +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | # Butchered version of snapshot | ||
4 | # Can only run on the shell compile farm server | ||
5 | # Will always create a snapshot of HEAD | ||
6 | # If want multiple snapshots, just run with "sfsnapshot [branch ...]" | ||
7 | # Assumes: | ||
8 | # ssh setup to send to shell.sf.net and $CF without password prompt | ||
9 | # the compile server has all the prerequisites stated at http://nagiosplug.sourceforge.net/developer-guidelines.html | ||
10 | # Install in cron with something like: | ||
11 | # 47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0 | ||
12 | |||
13 | function die { echo $1; exit 1; } | ||
14 | |||
15 | # This makes the distribution. Expects $1 as branches/name, otherwise uses trunk | ||
16 | function make_dist { | ||
17 | if [[ -n $1 ]] ; then | ||
18 | svn_url_suffix=$1 | ||
19 | name=${1##*/} | ||
20 | else | ||
21 | svn_url_suffix="trunk" | ||
22 | name="trunk" | ||
23 | fi | ||
24 | v="$name-" | ||
25 | |||
26 | # Get compile server to do the work | ||
27 | # Variables will be expanded locally before being run on $CF | ||
28 | ssh $CF <<EOF | ||
29 | set -x | ||
30 | PATH=$PATH:/usr/local/bin | ||
31 | [[ ! -d $COMPILE_DIR/$name ]] && mkdir -p $COMPILE_DIR/$name | ||
32 | cd $COMPILE_DIR/$name | ||
33 | |||
34 | # Cannot use cvs export due to conflicts on second run - think this is better for cvs server | ||
35 | svn export https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/$svn_url_suffix $PROJECT | ||
36 | |||
37 | cd $PROJECT | ||
38 | |||
39 | tools/setup | ||
40 | |||
41 | ./configure | ||
42 | |||
43 | # Make the Nagiosplug dist tarball | ||
44 | make dist VERSION=$v$DS RELEASE=snapshot | ||
45 | |||
46 | # May fail if file not generated - do not trap | ||
47 | mv *.gz $IN | ||
48 | |||
49 | rm -rf $COMPILE_DIR | ||
50 | # End ssh | ||
51 | EOF | ||
52 | } | ||
53 | |||
54 | # Set working variables | ||
55 | PROJECT=nagiosplug | ||
56 | |||
57 | # This is local to the compile server for faster compile | ||
58 | COMPILE_DIR=/tmp/tonvoon/tmp_snapshot | ||
59 | |||
60 | # Needs to be on NFS so gz file can be read on the compile shell server | ||
61 | IN=${HOME}/tmp_snapshot | ||
62 | |||
63 | # Where to place the generated files | ||
64 | OUT_SERVER="tonvoon@web.sourceforge.net" | ||
65 | OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot" | ||
66 | |||
67 | # Make sure prereqs are satisfied on server! | ||
68 | CF="localhost" | ||
69 | DS=`date -u +%Y%m%d%H%M` | ||
70 | |||
71 | # Setup home directory area | ||
72 | [[ ! -d $IN ]] && mkdir -p $IN | ||
73 | |||
74 | # Make dists for HEAD and any others in command parameters | ||
75 | make_dist | ||
76 | for i in $* ; do | ||
77 | make_dist $i | ||
78 | done | ||
79 | |||
80 | # Create MD5 sum | ||
81 | cd $IN | ||
82 | cat <<-END_README > README | ||
83 | This is the daily SVN snapshot of nagiosplug, consisting of the SVN trunk | ||
84 | and any other branches. | ||
85 | |||
86 | The nagios-plugins-HEAD.tar.gz link will always go to the latest trunk snapshot | ||
87 | (name kept for existing tinderbox scripts to link correctly). | ||
88 | |||
89 | The MD5SUM is: | ||
90 | END_README | ||
91 | md5sum *.gz | tee -a README > MD5SUM | ||
92 | |||
93 | |||
94 | # Check for *.gz files locally (expect NFS between cf shell server and $CF) | ||
95 | set -x | ||
96 | cd $IN | ||
97 | files=$(ls *.gz 2>/dev/null) | ||
98 | [[ -z $files ]] && die "No files created" | ||
99 | head_file=$(cd $IN && ls -rt *-trunk-*.gz | head -1 2>/dev/null) | ||
100 | cat <<-EOF > /tmp/batchfile.$$ | ||
101 | cd $OUT | ||
102 | rm *.gz | ||
103 | put *.gz | ||
104 | ln $head_file nagios-plugins-HEAD.tar.gz | ||
105 | put MD5SUM | ||
106 | put README readme | ||
107 | EOF | ||
108 | |||
109 | # Do the actual transfer | ||
110 | # Have to put README down as readme because SF's apache server appears to block README files | ||
111 | sftp -b /tmp/batchfile.$$ $OUT_SERVER | ||
112 | |||
113 | rm -f $files /tmp/batchfile.$$ | ||
114 | |||
115 | # Work out success or failure | ||
116 | expected=$(($# + 1)) | ||
117 | set -- $files | ||
118 | [[ $# -ne $expected ]] && die "Expected $expected, got $#" | ||
119 | exit 0 | ||
diff --git a/tools/sfsnapshot-upload b/tools/sfsnapshot-upload deleted file mode 100755 index d8ebcc5..0000000 --- a/tools/sfsnapshot-upload +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # sfsnapshot-upload - Snapshot upload script using sfsnapshotgit | ||
3 | # Original author: Thomas Guyot-Sionnest <tguyot@gmail.com> | ||
4 | # | ||
5 | # This script uses sfsnapshotgit to update the snapshot is needed and upload | ||
6 | # it to SourceForge. The branches to create snapshot from can be given as an | ||
7 | # argument, otherwise the default is master. | ||
8 | |||
9 | # Handle command errors (-e) and coder sleep deprivation issues (-u) | ||
10 | set -eu | ||
11 | trap 'echo "An error occurred in sfsnapshot-upload at line $LINENO"; exit 1' EXIT | ||
12 | |||
13 | # This can be used to override the default in sfsnapshotgit: | ||
14 | export SFSNAP_REPO=~/staging/nagiosplugins | ||
15 | export SFSNAP_ORIGIN=origin | ||
16 | export SFSNAP_DEST=~/staging/snapshot | ||
17 | |||
18 | ## Some stuff that shouldn't change often... | ||
19 | # The file we'll use to create the snapshot | ||
20 | sfsnapshot=~/bin/sfsnapshotgit | ||
21 | |||
22 | # Retention time for snapshots (in minutes), 0 for no retention. | ||
23 | CLEAN_TIME=1440 | ||
24 | |||
25 | # Where to place the generated files | ||
26 | OUT_SERVER="tonvoon@frs.sourceforge.net" | ||
27 | OUT_PATH="/home/groups/n/na/nagiosplug/htdocs/snapshot" | ||
28 | |||
29 | # Links to always point to the master branch for backwards-compatibility | ||
30 | COMPATLINKS="HEAD trunk-`date -u +%Y%m%d%H%M`" | ||
31 | # And compatibility links to always delete except the last one | ||
32 | COMPATCLEANUP="trunk-*" | ||
33 | |||
34 | # If one or more argument is given, this is the branches to create the snapshots from | ||
35 | if [ $# -eq 0 ] | ||
36 | then | ||
37 | HEADS='master' | ||
38 | else | ||
39 | HEADS=$@ | ||
40 | fi | ||
41 | |||
42 | # If we don't keep old snapshots we can clean up all links now | ||
43 | if [ $CLEAN_TIME -eq 0 ] | ||
44 | then | ||
45 | find $SFSNAP_DEST -type l -name '*.gz' -delete | ||
46 | fi | ||
47 | |||
48 | for head in $HEADS ; do | ||
49 | # This runs the actual snapshot code. It creates new snapshots if needed and always | ||
50 | # return the current snapshot file (even if it wasn't modified). | ||
51 | file=$($sfsnapshot $head) | ||
52 | # Create main head link | ||
53 | ln -sf $file $SFSNAP_DEST/nagios-plugins-$head.tar.gz | ||
54 | |||
55 | # Keep links by branch name too if we keep old snapshots, so we can keep tracks of them | ||
56 | if [ $CLEAN_TIME -gt 0 -a ! -e "$SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}" ] | ||
57 | then | ||
58 | ln -s $file $SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-} | ||
59 | fi | ||
60 | |||
61 | # Cleanup and re-create backward-compatibility links | ||
62 | if [ "$head" == "master" ] | ||
63 | then | ||
64 | for cclean in $COMPATCLEANUP | ||
65 | do | ||
66 | find $SFSNAP_DEST -type l -name "nagios-plugins-$cclean.tar.gz" -delete | ||
67 | done | ||
68 | for compat in $COMPATLINKS | ||
69 | do | ||
70 | ln -sf $file $SFSNAP_DEST/nagios-plugins-$compat.tar.gz | ||
71 | done | ||
72 | fi | ||
73 | done | ||
74 | |||
75 | cd $SFSNAP_DEST | ||
76 | |||
77 | # Clean up links older than $CLEAN_TIME if needed | ||
78 | if [ $CLEAN_TIME -gt 0 ] | ||
79 | then | ||
80 | find . -type l -name '*.gz' -mmin +$CLEAN_TIME -delete | ||
81 | fi | ||
82 | |||
83 | # Now clean up files that we don't need | ||
84 | # 1. loop over actual snapshots | ||
85 | for dest in `find . -type f -name '*.gz' |xargs -n 1 basename` | ||
86 | do | ||
87 | # 2. Loop over the list of linked-to files | ||
88 | for current in `find . -type l -name '*.gz' |xargs -n 1 readlink | sort | uniq` | ||
89 | do | ||
90 | if [ "$current" == "$dest" ] | ||
91 | then | ||
92 | # File is being linked to - don't delete (continue first loop) | ||
93 | continue 2 | ||
94 | fi | ||
95 | done | ||
96 | # No link to this file, we can drop it | ||
97 | rm -f $dest | ||
98 | done | ||
99 | |||
100 | # Create MD5 sum | ||
101 | cat <<-END_README > README | ||
102 | This is the latest snapshot of nagiosplug, consisting of the following | ||
103 | head(s): | ||
104 | $HEADS | ||
105 | |||
106 | The nagios-plugins-<head>.tar.gz link will always point to the latest | ||
107 | corresponding snapshot (nagios-plugins-<git-describe>.tar.gz). | ||
108 | |||
109 | For backward-compatibility, the nagios-plugins-HEAD.tar.gz and | ||
110 | nagios-plugins-trunk-<ts>.tar.gz point to their corresponding "master" | ||
111 | head. | ||
112 | |||
113 | The tarballs will only be updated when a change has been made. The | ||
114 | MD5SUM file is updated every time the snapshot script runs. | ||
115 | |||
116 | The MD5SUMs are: | ||
117 | END_README | ||
118 | md5sum *.gz | tee -a README > MD5SUM | ||
119 | |||
120 | # Sync the files | ||
121 | [ -n "$OUT_SERVER" ] && OUT_SERVER="$OUT_SERVER:" | ||
122 | rsync -a --exclude=.htaccess --exclude=HEADER.html --delete "$SFSNAP_DEST/" "$OUT_SERVER$OUT_PATH" | ||
123 | |||
124 | trap - EXIT | ||
125 | |||
diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit deleted file mode 100755 index 8bc19fc..0000000 --- a/tools/sfsnapshotgit +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # sfsnapshotgit - Snapshot script for Git repository | ||
3 | # Original author: Thomas Guyot-Sionnest <tguyot@gmail.com> | ||
4 | # | ||
5 | # Given an optional branch name (master by default), this script creates | ||
6 | # a snapshot from the tip of the branch and move it to ~/staging/. | ||
7 | # The repository, origin and destination directory can be overridden | ||
8 | # with environment variable (see below) | ||
9 | |||
10 | # Handle command errors (-e) and coder sleep deprivation issues (-u) | ||
11 | set -eu | ||
12 | trap 'echo "An error occurred in sfsnapshotgit at line $LINENO"; exit 1' EXIT | ||
13 | |||
14 | # Send all command output to STDERR while allowing us to write to STDOUT | ||
15 | # using fd 3 | ||
16 | exec 3>&1 1>&2 | ||
17 | |||
18 | # Git repository, origin and destination directory can be overridden by | ||
19 | # setting SFSNAP_REPO, SFSNAP_ORIGIN and SFSNAP_DEST respectively from the | ||
20 | # caller The defaults are: | ||
21 | SFSNAP_REPO=${SFSNAP_REPO-~/staging/nagiosplugins} | ||
22 | SFSNAP_ORIGIN=${SFSNAP_ORIGIN-origin} | ||
23 | SFSNAP_DEST=${SFSNAP_DEST-~/staging/snapshot} | ||
24 | |||
25 | # If one argument is given, this is the branch to create the snapshot from | ||
26 | if [ $# -eq 0 ] | ||
27 | then | ||
28 | HEAD='master' | ||
29 | elif [ $# -eq 1 ] | ||
30 | then | ||
31 | if [ -z "$1" ] | ||
32 | then | ||
33 | echo "If specified, the refspec must not be empty" | ||
34 | exit | ||
35 | fi | ||
36 | HEAD="$1" | ||
37 | else | ||
38 | echo "Too many arguments" | ||
39 | exit | ||
40 | fi | ||
41 | |||
42 | # Clean up and pull | ||
43 | cd "$SFSNAP_REPO" | ||
44 | # Sometimes "make dist" can modify versioned files so we must reset first | ||
45 | git reset --hard | ||
46 | git clean -qfdx | ||
47 | |||
48 | # Any branch used to create snapshots must already exist and be properly configured | ||
49 | git checkout "$HEAD" | ||
50 | |||
51 | # Get the remote tracking branch from config | ||
52 | origin=$(git config branch.$HEAD.remote) | ||
53 | ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||') | ||
54 | git fetch "$origin" | ||
55 | git reset --hard "$origin/$ref" | ||
56 | |||
57 | # Tags are important for git-describe, but take only the ones from the hard-coded origin | ||
58 | git fetch --tags "$SFSNAP_ORIGIN" | ||
59 | |||
60 | # Write our snapshot version string (similar to NP-VERSION-GEN) to "release" | ||
61 | VS=$(git describe --abbrev=4 HEAD) | ||
62 | VS=${VS#release-} | ||
63 | |||
64 | # Configure and dist only if needed | ||
65 | if [ ! -e "$SFSNAP_DEST/nagios-plugins-$VS.tar.gz" ] | ||
66 | then | ||
67 | tools/setup | ||
68 | ./configure | ||
69 | make dist VERSION=$VS RELEASE=snapshot | ||
70 | cp nagios-plugins-$VS.tar.gz "$SFSNAP_DEST/" | ||
71 | fi | ||
72 | |||
73 | # fd 3 goes to STDOUT; print the generated filename | ||
74 | echo "nagios-plugins-$VS.tar.gz" 1>&3 | ||
75 | |||
76 | trap - EXIT | ||
77 | |||
diff --git a/tools/sfupload b/tools/sfupload deleted file mode 100755 index 8925fcb..0000000 --- a/tools/sfupload +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # SYNTAX: | ||
3 | # sfupload {version} [username] | ||
4 | # Quick script to upload new nagiosplug tarball to SF | ||
5 | # Expects $1 = version number of tarball | ||
6 | # $2 to be username on SF, defaults to $USER | ||
7 | # Expects to be run from top level dir | ||
8 | |||
9 | function die { echo $1; exit 1; } | ||
10 | |||
11 | tarball="nagios-plugins-$1.tar.gz" | ||
12 | |||
13 | if [[ ! -e $tarball ]]; then | ||
14 | die "No tarball found: $tarball"; | ||
15 | fi | ||
16 | md5sum $tarball > $tarball.md5sum | ||
17 | |||
18 | user=${2:-$USER} | ||
19 | echo "Logging in as $user" | ||
20 | cat <<EOF | sftp $user@frs.sourceforge.net || die "Cannot upload to SF" | ||
21 | cd uploads | ||
22 | put $tarball | ||
23 | put $tarball.md5sum | ||
24 | EOF | ||
25 | |||
26 | echo "Finished uploading files to SF" | ||
27 | |||
diff --git a/tools/sfwebcron b/tools/sfwebcron deleted file mode 100755 index 0f31fcf..0000000 --- a/tools/sfwebcron +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | #! /bin/bash | ||
2 | # sfwebcron | ||
3 | |||
4 | # To update the developers-guidelines.html and put in html area | ||
5 | # | ||
6 | # Install in cron with something like: | ||
7 | # 47 7 * * * $HOME/bin/sfwebcron >/tmp/sfwebcron.log 2>&1 || cat /tmp/sfwebcron.log | ||
8 | |||
9 | set -eu | ||
10 | trap 'echo "Command failed at line $LINENO"' ERR | ||
11 | |||
12 | # Set working variables | ||
13 | PROJECT=nagiosplug | ||
14 | IN=${HOME}/sfwebcron | ||
15 | PROBE="developer-guidelines.html.last" | ||
16 | OUT_SERVER="tonvoon@frs.sourceforge.net" | ||
17 | OUT_PATH="/home/groups/n/na/nagiosplug/htdocs" | ||
18 | |||
19 | # Get latest dev guildelines | ||
20 | [[ ! -d $IN ]] && mkdir $IN | ||
21 | cd $IN | ||
22 | if [[ ! -d nagios-plugins ]] | ||
23 | then | ||
24 | git clone https://github.com/nagios-plugins/nagios-plugins.git nagios-plugins | ||
25 | fi | ||
26 | cd nagios-plugins/doc | ||
27 | git pull | ||
28 | |||
29 | make | ||
30 | if [[ ! -e $PROBE || developer-guidelines.html -nt $PROBE ]] | ||
31 | then | ||
32 | rsync -av developer-guidelines.{html,sgml} $OUT_SERVER:$OUT_PATH/ | ||
33 | touch $PROBE | ||
34 | fi | ||
35 | |||
diff --git a/tools/sync_website b/tools/sync_website deleted file mode 100755 index 8489bc5..0000000 --- a/tools/sync_website +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use strict; | ||
3 | use DBI; | ||
4 | #$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm | ||
5 | |||
6 | unless ($ENV{DRUPAL_PASSWORD}) { | ||
7 | die "Must set envvar for DRUPAL_PASSWORD"; | ||
8 | } | ||
9 | |||
10 | my $pid = open(F, "-|", qw(ssh -n -N -L 25555:127.0.0.1:3306 nagiosplugins.org)); | ||
11 | |||
12 | # Allow time for ssh tunnel to be created | ||
13 | sleep 2; | ||
14 | |||
15 | # To stop the death of ssh tunnel being defunct | ||
16 | $SIG{CHLD} = 'IGNORE'; | ||
17 | |||
18 | END { kill 'INT', $pid if $pid }; | ||
19 | |||
20 | my $dbh = DBI->connect("DBI:mysql:database=drupal;host=127.0.0.1;port=25555", "drupal", $ENV{DRUPAL_PASSWORD}); | ||
21 | |||
22 | my @plugin_paths; | ||
23 | push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) ); | ||
24 | |||
25 | foreach my $plugin_path (@plugin_paths) { | ||
26 | my $plugin = $plugin_path; | ||
27 | $plugin =~ s%.*/%%; | ||
28 | my $help_option = "--help"; | ||
29 | $help_option = "-h" if ($plugin eq "check_icmp"); | ||
30 | my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h"; | ||
31 | $help =~ s/</</g; | ||
32 | $help =~ s/>/>/g; | ||
33 | |||
34 | my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'"); | ||
35 | unless ($rows == 1) { | ||
36 | die "Cannot find $plugin in drupal to update - create book page first"; | ||
37 | } | ||
38 | |||
39 | $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'", | ||
40 | {}, | ||
41 | "<pre>".$help."</pre>"); | ||
42 | } | ||
43 | |||
44 | print "Finished\n"; | ||
diff --git a/tools/update_man_pages b/tools/update_man_pages deleted file mode 100755 index 5c4a901..0000000 --- a/tools/update_man_pages +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use strict; | ||
3 | use DBI; | ||
4 | #$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm | ||
5 | |||
6 | unless ($ENV{DRUPAL_PASSWORD}) { | ||
7 | die "Must set envvar for DRUPAL_PASSWORD"; | ||
8 | } | ||
9 | |||
10 | my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD}); | ||
11 | |||
12 | my @plugin_paths; | ||
13 | push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) ); | ||
14 | |||
15 | foreach my $plugin_path (@plugin_paths) { | ||
16 | my $plugin = $plugin_path; | ||
17 | $plugin =~ s%.*/%%; | ||
18 | my $help_option = "--help"; | ||
19 | $help_option = "-h" if ($plugin eq "check_icmp"); | ||
20 | my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h"; | ||
21 | $help =~ s/</</g; | ||
22 | $help =~ s/>/>/g; | ||
23 | |||
24 | my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'"); | ||
25 | unless ($rows == 1) { | ||
26 | die "Cannot find $plugin in drupal to update - create book page first"; | ||
27 | } | ||
28 | |||
29 | $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'", | ||
30 | {}, | ||
31 | "<pre>".$help."</pre>"); | ||
32 | } | ||
33 | |||
34 | print "Finished\n"; | ||