summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-27 21:10:53 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-27 21:10:53 (GMT)
commit9ae1cd8f91aa6b53404e66588679d852d3972bcd (patch)
tree1edc8a9ac8e36bf8fabeed7b7b3ad933d691438c /tools
parent983d10e0609175a26675a97129b9e7def18d5f35 (diff)
downloadmonitoring-plugins-9ae1cd8f91aa6b53404e66588679d852d3972bcd.tar.gz
tools: Remove Drupal/SourceForge scripts
We moved our web site away from Drupal and the snapshots/guidelines away from SourceForge. The new infrastructure scripts will be maintained in a separate repository together with the Markdown source of the new web site.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mail_error25
-rwxr-xr-xtools/np_build_from_sf11
-rwxr-xr-xtools/sfsnapshot119
-rwxr-xr-xtools/sfsnapshot-upload125
-rwxr-xr-xtools/sfsnapshotgit77
-rwxr-xr-xtools/sfupload27
-rwxr-xr-xtools/sfwebcron35
-rwxr-xr-xtools/sync_website44
-rwxr-xr-xtools/update_man_pages34
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
6function die { echo $1 ; exit 1; }
7
8# Must be export so that sfsnapshot uses correct versions
9# of GNU toolchain
10export PATH=$HOME/bin:$HOME/local/bin:$PATH
11
12while getopts "o:m:" c; do
13 case $c in
14 o) output_file=$OPTARG;;
15 m) email=$OPTARG;;
16 \*) echo "oops";;
17 esac
18done
19shift $(($OPTIND-1))
20
21[[ -z $1 ]] && die "Must specify command"
22
23if ! "$@" > $output_file 2>&1 ; then
24 mail -s "mail_error fail: $1" $email < $output_file
25fi
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
3set -xeu
4
5temp=$(mktemp -d)
6trap "cd $HOME; rm -rf $temp; exit 1" EXIT
7curl -sS http://nagiosplug.sourceforge.net/snapshot/nagios-plugins-HEAD.tar.gz|tar -C "$temp" --strip-components=1 -xzf -
8cd $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
13function die { echo $1; exit 1; }
14
15# This makes the distribution. Expects $1 as branches/name, otherwise uses trunk
16function 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
51EOF
52}
53
54# Set working variables
55PROJECT=nagiosplug
56
57# This is local to the compile server for faster compile
58COMPILE_DIR=/tmp/tonvoon/tmp_snapshot
59
60# Needs to be on NFS so gz file can be read on the compile shell server
61IN=${HOME}/tmp_snapshot
62
63# Where to place the generated files
64OUT_SERVER="tonvoon@web.sourceforge.net"
65OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot"
66
67# Make sure prereqs are satisfied on server!
68CF="localhost"
69DS=`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
75make_dist
76for i in $* ; do
77 make_dist $i
78done
79
80# Create MD5 sum
81cd $IN
82cat <<-END_README > README
83This is the daily SVN snapshot of nagiosplug, consisting of the SVN trunk
84and any other branches.
85
86The 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
89The MD5SUM is:
90END_README
91md5sum *.gz | tee -a README > MD5SUM
92
93
94# Check for *.gz files locally (expect NFS between cf shell server and $CF)
95set -x
96cd $IN
97files=$(ls *.gz 2>/dev/null)
98[[ -z $files ]] && die "No files created"
99head_file=$(cd $IN && ls -rt *-trunk-*.gz | head -1 2>/dev/null)
100cat <<-EOF > /tmp/batchfile.$$
101cd $OUT
102rm *.gz
103put *.gz
104ln $head_file nagios-plugins-HEAD.tar.gz
105put MD5SUM
106put README readme
107EOF
108
109# Do the actual transfer
110# Have to put README down as readme because SF's apache server appears to block README files
111sftp -b /tmp/batchfile.$$ $OUT_SERVER
112
113rm -f $files /tmp/batchfile.$$
114
115# Work out success or failure
116expected=$(($# + 1))
117set -- $files
118[[ $# -ne $expected ]] && die "Expected $expected, got $#"
119exit 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)
10set -eu
11trap '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:
14export SFSNAP_REPO=~/staging/nagiosplugins
15export SFSNAP_ORIGIN=origin
16export SFSNAP_DEST=~/staging/snapshot
17
18## Some stuff that shouldn't change often...
19# The file we'll use to create the snapshot
20sfsnapshot=~/bin/sfsnapshotgit
21
22# Retention time for snapshots (in minutes), 0 for no retention.
23CLEAN_TIME=1440
24
25# Where to place the generated files
26OUT_SERVER="tonvoon@frs.sourceforge.net"
27OUT_PATH="/home/groups/n/na/nagiosplug/htdocs/snapshot"
28
29# Links to always point to the master branch for backwards-compatibility
30COMPATLINKS="HEAD trunk-`date -u +%Y%m%d%H%M`"
31# And compatibility links to always delete except the last one
32COMPATCLEANUP="trunk-*"
33
34# If one or more argument is given, this is the branches to create the snapshots from
35if [ $# -eq 0 ]
36then
37 HEADS='master'
38else
39 HEADS=$@
40fi
41
42# If we don't keep old snapshots we can clean up all links now
43if [ $CLEAN_TIME -eq 0 ]
44then
45 find $SFSNAP_DEST -type l -name '*.gz' -delete
46fi
47
48for 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
73done
74
75cd $SFSNAP_DEST
76
77# Clean up links older than $CLEAN_TIME if needed
78if [ $CLEAN_TIME -gt 0 ]
79then
80 find . -type l -name '*.gz' -mmin +$CLEAN_TIME -delete
81fi
82
83# Now clean up files that we don't need
84# 1. loop over actual snapshots
85for dest in `find . -type f -name '*.gz' |xargs -n 1 basename`
86do
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
98done
99
100# Create MD5 sum
101cat <<-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
118md5sum *.gz | tee -a README > MD5SUM
119
120# Sync the files
121[ -n "$OUT_SERVER" ] && OUT_SERVER="$OUT_SERVER:"
122rsync -a --exclude=.htaccess --exclude=HEADER.html --delete "$SFSNAP_DEST/" "$OUT_SERVER$OUT_PATH"
123
124trap - 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)
11set -eu
12trap '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
16exec 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:
21SFSNAP_REPO=${SFSNAP_REPO-~/staging/nagiosplugins}
22SFSNAP_ORIGIN=${SFSNAP_ORIGIN-origin}
23SFSNAP_DEST=${SFSNAP_DEST-~/staging/snapshot}
24
25# If one argument is given, this is the branch to create the snapshot from
26if [ $# -eq 0 ]
27then
28 HEAD='master'
29elif [ $# -eq 1 ]
30then
31 if [ -z "$1" ]
32 then
33 echo "If specified, the refspec must not be empty"
34 exit
35 fi
36 HEAD="$1"
37else
38 echo "Too many arguments"
39 exit
40fi
41
42# Clean up and pull
43cd "$SFSNAP_REPO"
44# Sometimes "make dist" can modify versioned files so we must reset first
45git reset --hard
46git clean -qfdx
47
48# Any branch used to create snapshots must already exist and be properly configured
49git checkout "$HEAD"
50
51# Get the remote tracking branch from config
52origin=$(git config branch.$HEAD.remote)
53ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||')
54git fetch "$origin"
55git reset --hard "$origin/$ref"
56
57# Tags are important for git-describe, but take only the ones from the hard-coded origin
58git fetch --tags "$SFSNAP_ORIGIN"
59
60# Write our snapshot version string (similar to NP-VERSION-GEN) to "release"
61VS=$(git describe --abbrev=4 HEAD)
62VS=${VS#release-}
63
64# Configure and dist only if needed
65if [ ! -e "$SFSNAP_DEST/nagios-plugins-$VS.tar.gz" ]
66then
67 tools/setup
68 ./configure
69 make dist VERSION=$VS RELEASE=snapshot
70 cp nagios-plugins-$VS.tar.gz "$SFSNAP_DEST/"
71fi
72
73# fd 3 goes to STDOUT; print the generated filename
74echo "nagios-plugins-$VS.tar.gz" 1>&3
75
76trap - 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
9function die { echo $1; exit 1; }
10
11tarball="nagios-plugins-$1.tar.gz"
12
13if [[ ! -e $tarball ]]; then
14 die "No tarball found: $tarball";
15fi
16md5sum $tarball > $tarball.md5sum
17
18user=${2:-$USER}
19echo "Logging in as $user"
20cat <<EOF | sftp $user@frs.sourceforge.net || die "Cannot upload to SF"
21cd uploads
22put $tarball
23put $tarball.md5sum
24EOF
25
26echo "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
9set -eu
10trap 'echo "Command failed at line $LINENO"' ERR
11
12# Set working variables
13PROJECT=nagiosplug
14IN=${HOME}/sfwebcron
15PROBE="developer-guidelines.html.last"
16OUT_SERVER="tonvoon@frs.sourceforge.net"
17OUT_PATH="/home/groups/n/na/nagiosplug/htdocs"
18
19# Get latest dev guildelines
20[[ ! -d $IN ]] && mkdir $IN
21cd $IN
22if [[ ! -d nagios-plugins ]]
23then
24 git clone https://github.com/nagios-plugins/nagios-plugins.git nagios-plugins
25fi
26cd nagios-plugins/doc
27git pull
28
29make
30if [[ ! -e $PROBE || developer-guidelines.html -nt $PROBE ]]
31then
32 rsync -av developer-guidelines.{html,sgml} $OUT_SERVER:$OUT_PATH/
33 touch $PROBE
34fi
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
2use strict;
3use DBI;
4#$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm
5
6unless ($ENV{DRUPAL_PASSWORD}) {
7 die "Must set envvar for DRUPAL_PASSWORD";
8}
9
10my $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
13sleep 2;
14
15# To stop the death of ssh tunnel being defunct
16$SIG{CHLD} = 'IGNORE';
17
18END { kill 'INT', $pid if $pid };
19
20my $dbh = DBI->connect("DBI:mysql:database=drupal;host=127.0.0.1;port=25555", "drupal", $ENV{DRUPAL_PASSWORD});
21
22my @plugin_paths;
23push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) );
24
25foreach 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/</&lt;/g;
32 $help =~ s/>/&gt;/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
44print "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
2use strict;
3use DBI;
4#$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm
5
6unless ($ENV{DRUPAL_PASSWORD}) {
7 die "Must set envvar for DRUPAL_PASSWORD";
8}
9
10my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD});
11
12my @plugin_paths;
13push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) );
14
15foreach 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/</&lt;/g;
22 $help =~ s/>/&gt;/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
34print "Finished\n";