diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-27 23:10:53 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-27 23:10:53 +0200 |
commit | 9ae1cd8f91aa6b53404e66588679d852d3972bcd (patch) | |
tree | 1edc8a9ac8e36bf8fabeed7b7b3ad933d691438c /tools | |
parent | 983d10e0609175a26675a97129b9e7def18d5f35 (diff) | |
download | monitoring-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-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 aabb579c..00000000 --- a/tools/mail_error +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# mail_error -o file -m email_address command -# Runs command from cron and redirects all output to file -# If command rc != 0, sends output to email_address - -function die { echo $1 ; exit 1; } - -# Must be export so that sfsnapshot uses correct versions -# of GNU toolchain -export PATH=$HOME/bin:$HOME/local/bin:$PATH - -while getopts "o:m:" c; do - case $c in - o) output_file=$OPTARG;; - m) email=$OPTARG;; - \*) echo "oops";; - esac -done -shift $(($OPTIND-1)) - -[[ -z $1 ]] && die "Must specify command" - -if ! "$@" > $output_file 2>&1 ; then - mail -s "mail_error fail: $1" $email < $output_file -fi diff --git a/tools/np_build_from_sf b/tools/np_build_from_sf deleted file mode 100755 index 7ba349a6..00000000 --- a/tools/np_build_from_sf +++ /dev/null @@ -1,11 +0,0 @@ -#!/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 - diff --git a/tools/sfsnapshot b/tools/sfsnapshot deleted file mode 100755 index 3b71219a..00000000 --- a/tools/sfsnapshot +++ /dev/null @@ -1,119 +0,0 @@ -#! /bin/bash - -# Butchered version of snapshot -# Can only run on the shell compile farm server -# Will always create a snapshot of HEAD -# If want multiple snapshots, just run with "sfsnapshot [branch ...]" -# Assumes: -# ssh setup to send to shell.sf.net and $CF without password prompt -# the compile server has all the prerequisites stated at http://nagiosplug.sourceforge.net/developer-guidelines.html -# Install in cron with something like: -# 47 * * * * $HOME/bin/mail_error -o $HOME/sfsnapshot.out -m tonvoon@users.sf.net sfsnapshot r1_3_0 - -function die { echo $1; exit 1; } - -# This makes the distribution. Expects $1 as branches/name, otherwise uses trunk -function make_dist { - if [[ -n $1 ]] ; then - svn_url_suffix=$1 - name=${1##*/} - else - svn_url_suffix="trunk" - name="trunk" - fi - v="$name-" - - # Get compile server to do the work - # Variables will be expanded locally before being run on $CF - ssh $CF <<EOF - set -x - PATH=$PATH:/usr/local/bin - [[ ! -d $COMPILE_DIR/$name ]] && mkdir -p $COMPILE_DIR/$name - cd $COMPILE_DIR/$name - - # Cannot use cvs export due to conflicts on second run - think this is better for cvs server - svn export https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/$svn_url_suffix $PROJECT - - cd $PROJECT - - tools/setup - - ./configure - - # Make the Nagiosplug dist tarball - make dist VERSION=$v$DS RELEASE=snapshot - - # May fail if file not generated - do not trap - mv *.gz $IN - - rm -rf $COMPILE_DIR - # End ssh -EOF -} - -# Set working variables -PROJECT=nagiosplug - -# This is local to the compile server for faster compile -COMPILE_DIR=/tmp/tonvoon/tmp_snapshot - -# Needs to be on NFS so gz file can be read on the compile shell server -IN=${HOME}/tmp_snapshot - -# Where to place the generated files -OUT_SERVER="tonvoon@web.sourceforge.net" -OUT="/home/groups/n/na/nagiosplug/htdocs/snapshot" - -# Make sure prereqs are satisfied on server! -CF="localhost" -DS=`date -u +%Y%m%d%H%M` - -# Setup home directory area -[[ ! -d $IN ]] && mkdir -p $IN - -# Make dists for HEAD and any others in command parameters -make_dist -for i in $* ; do - make_dist $i -done - -# Create MD5 sum -cd $IN -cat <<-END_README > README -This is the daily SVN snapshot of nagiosplug, consisting of the SVN trunk -and any other branches. - -The nagios-plugins-HEAD.tar.gz link will always go to the latest trunk snapshot -(name kept for existing tinderbox scripts to link correctly). - -The MD5SUM is: -END_README -md5sum *.gz | tee -a README > MD5SUM - - -# Check for *.gz files locally (expect NFS between cf shell server and $CF) -set -x -cd $IN -files=$(ls *.gz 2>/dev/null) -[[ -z $files ]] && die "No files created" -head_file=$(cd $IN && ls -rt *-trunk-*.gz | head -1 2>/dev/null) -cat <<-EOF > /tmp/batchfile.$$ -cd $OUT -rm *.gz -put *.gz -ln $head_file nagios-plugins-HEAD.tar.gz -put MD5SUM -put README readme -EOF - -# Do the actual transfer -# Have to put README down as readme because SF's apache server appears to block README files -sftp -b /tmp/batchfile.$$ $OUT_SERVER - -rm -f $files /tmp/batchfile.$$ - -# Work out success or failure -expected=$(($# + 1)) -set -- $files -[[ $# -ne $expected ]] && die "Expected $expected, got $#" -exit 0 diff --git a/tools/sfsnapshot-upload b/tools/sfsnapshot-upload deleted file mode 100755 index d8ebcc54..00000000 --- a/tools/sfsnapshot-upload +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash -# sfsnapshot-upload - Snapshot upload script using sfsnapshotgit -# Original author: Thomas Guyot-Sionnest <tguyot@gmail.com> -# -# This script uses sfsnapshotgit to update the snapshot is needed and upload -# it to SourceForge. The branches to create snapshot from can be given as an -# argument, otherwise the default is master. - -# Handle command errors (-e) and coder sleep deprivation issues (-u) -set -eu -trap 'echo "An error occurred in sfsnapshot-upload at line $LINENO"; exit 1' EXIT - -# This can be used to override the default in sfsnapshotgit: -export SFSNAP_REPO=~/staging/nagiosplugins -export SFSNAP_ORIGIN=origin -export SFSNAP_DEST=~/staging/snapshot - -## Some stuff that shouldn't change often... -# The file we'll use to create the snapshot -sfsnapshot=~/bin/sfsnapshotgit - -# Retention time for snapshots (in minutes), 0 for no retention. -CLEAN_TIME=1440 - -# Where to place the generated files -OUT_SERVER="tonvoon@frs.sourceforge.net" -OUT_PATH="/home/groups/n/na/nagiosplug/htdocs/snapshot" - -# Links to always point to the master branch for backwards-compatibility -COMPATLINKS="HEAD trunk-`date -u +%Y%m%d%H%M`" -# And compatibility links to always delete except the last one -COMPATCLEANUP="trunk-*" - -# If one or more argument is given, this is the branches to create the snapshots from -if [ $# -eq 0 ] -then - HEADS='master' -else - HEADS=$@ -fi - -# If we don't keep old snapshots we can clean up all links now -if [ $CLEAN_TIME -eq 0 ] -then - find $SFSNAP_DEST -type l -name '*.gz' -delete -fi - -for head in $HEADS ; do - # This runs the actual snapshot code. It creates new snapshots if needed and always - # return the current snapshot file (even if it wasn't modified). - file=$($sfsnapshot $head) - # Create main head link - ln -sf $file $SFSNAP_DEST/nagios-plugins-$head.tar.gz - - # Keep links by branch name too if we keep old snapshots, so we can keep tracks of them - if [ $CLEAN_TIME -gt 0 -a ! -e "$SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-}" ] - then - ln -s $file $SFSNAP_DEST/nagios-plugins-$head-${file#nagios-plugins-} - fi - - # Cleanup and re-create backward-compatibility links - if [ "$head" == "master" ] - then - for cclean in $COMPATCLEANUP - do - find $SFSNAP_DEST -type l -name "nagios-plugins-$cclean.tar.gz" -delete - done - for compat in $COMPATLINKS - do - ln -sf $file $SFSNAP_DEST/nagios-plugins-$compat.tar.gz - done - fi -done - -cd $SFSNAP_DEST - -# Clean up links older than $CLEAN_TIME if needed -if [ $CLEAN_TIME -gt 0 ] -then - find . -type l -name '*.gz' -mmin +$CLEAN_TIME -delete -fi - -# Now clean up files that we don't need -# 1. loop over actual snapshots -for dest in `find . -type f -name '*.gz' |xargs -n 1 basename` -do - # 2. Loop over the list of linked-to files - for current in `find . -type l -name '*.gz' |xargs -n 1 readlink | sort | uniq` - do - if [ "$current" == "$dest" ] - then - # File is being linked to - don't delete (continue first loop) - continue 2 - fi - done - # No link to this file, we can drop it - rm -f $dest -done - -# Create MD5 sum -cat <<-END_README > README - This is the latest snapshot of nagiosplug, consisting of the following - head(s): - $HEADS - - The nagios-plugins-<head>.tar.gz link will always point to the latest - corresponding snapshot (nagios-plugins-<git-describe>.tar.gz). - - For backward-compatibility, the nagios-plugins-HEAD.tar.gz and - nagios-plugins-trunk-<ts>.tar.gz point to their corresponding "master" - head. - - The tarballs will only be updated when a change has been made. The - MD5SUM file is updated every time the snapshot script runs. - - The MD5SUMs are: - END_README -md5sum *.gz | tee -a README > MD5SUM - -# Sync the files -[ -n "$OUT_SERVER" ] && OUT_SERVER="$OUT_SERVER:" -rsync -a --exclude=.htaccess --exclude=HEADER.html --delete "$SFSNAP_DEST/" "$OUT_SERVER$OUT_PATH" - -trap - EXIT - diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit deleted file mode 100755 index 8bc19fce..00000000 --- a/tools/sfsnapshotgit +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# sfsnapshotgit - Snapshot script for Git repository -# Original author: Thomas Guyot-Sionnest <tguyot@gmail.com> -# -# Given an optional branch name (master by default), this script creates -# a snapshot from the tip of the branch and move it to ~/staging/. -# The repository, origin and destination directory can be overridden -# with environment variable (see below) - -# Handle command errors (-e) and coder sleep deprivation issues (-u) -set -eu -trap 'echo "An error occurred in sfsnapshotgit at line $LINENO"; exit 1' EXIT - -# Send all command output to STDERR while allowing us to write to STDOUT -# using fd 3 -exec 3>&1 1>&2 - -# Git repository, origin and destination directory can be overridden by -# setting SFSNAP_REPO, SFSNAP_ORIGIN and SFSNAP_DEST respectively from the -# caller The defaults are: -SFSNAP_REPO=${SFSNAP_REPO-~/staging/nagiosplugins} -SFSNAP_ORIGIN=${SFSNAP_ORIGIN-origin} -SFSNAP_DEST=${SFSNAP_DEST-~/staging/snapshot} - -# If one argument is given, this is the branch to create the snapshot from -if [ $# -eq 0 ] -then - HEAD='master' -elif [ $# -eq 1 ] -then - if [ -z "$1" ] - then - echo "If specified, the refspec must not be empty" - exit - fi - HEAD="$1" -else - echo "Too many arguments" - exit -fi - -# Clean up and pull -cd "$SFSNAP_REPO" -# Sometimes "make dist" can modify versioned files so we must reset first -git reset --hard -git clean -qfdx - -# Any branch used to create snapshots must already exist and be properly configured -git checkout "$HEAD" - -# Get the remote tracking branch from config -origin=$(git config branch.$HEAD.remote) -ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||') -git fetch "$origin" -git reset --hard "$origin/$ref" - -# Tags are important for git-describe, but take only the ones from the hard-coded origin -git fetch --tags "$SFSNAP_ORIGIN" - -# Write our snapshot version string (similar to NP-VERSION-GEN) to "release" -VS=$(git describe --abbrev=4 HEAD) -VS=${VS#release-} - -# Configure and dist only if needed -if [ ! -e "$SFSNAP_DEST/nagios-plugins-$VS.tar.gz" ] -then - tools/setup - ./configure - make dist VERSION=$VS RELEASE=snapshot - cp nagios-plugins-$VS.tar.gz "$SFSNAP_DEST/" -fi - -# fd 3 goes to STDOUT; print the generated filename -echo "nagios-plugins-$VS.tar.gz" 1>&3 - -trap - EXIT - diff --git a/tools/sfupload b/tools/sfupload deleted file mode 100755 index 8925fcb5..00000000 --- a/tools/sfupload +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# SYNTAX: -# sfupload {version} [username] -# Quick script to upload new nagiosplug tarball to SF -# Expects $1 = version number of tarball -# $2 to be username on SF, defaults to $USER -# Expects to be run from top level dir - -function die { echo $1; exit 1; } - -tarball="nagios-plugins-$1.tar.gz" - -if [[ ! -e $tarball ]]; then - die "No tarball found: $tarball"; -fi -md5sum $tarball > $tarball.md5sum - -user=${2:-$USER} -echo "Logging in as $user" -cat <<EOF | sftp $user@frs.sourceforge.net || die "Cannot upload to SF" -cd uploads -put $tarball -put $tarball.md5sum -EOF - -echo "Finished uploading files to SF" - diff --git a/tools/sfwebcron b/tools/sfwebcron deleted file mode 100755 index 0f31fcfb..00000000 --- a/tools/sfwebcron +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/bash -# sfwebcron - -# To update the developers-guidelines.html and put in html area -# -# Install in cron with something like: -# 47 7 * * * $HOME/bin/sfwebcron >/tmp/sfwebcron.log 2>&1 || cat /tmp/sfwebcron.log - -set -eu -trap 'echo "Command failed at line $LINENO"' ERR - -# Set working variables -PROJECT=nagiosplug -IN=${HOME}/sfwebcron -PROBE="developer-guidelines.html.last" -OUT_SERVER="tonvoon@frs.sourceforge.net" -OUT_PATH="/home/groups/n/na/nagiosplug/htdocs" - -# Get latest dev guildelines -[[ ! -d $IN ]] && mkdir $IN -cd $IN -if [[ ! -d nagios-plugins ]] -then - git clone https://github.com/nagios-plugins/nagios-plugins.git nagios-plugins -fi -cd nagios-plugins/doc -git pull - -make -if [[ ! -e $PROBE || developer-guidelines.html -nt $PROBE ]] -then - rsync -av developer-guidelines.{html,sgml} $OUT_SERVER:$OUT_PATH/ - touch $PROBE -fi - diff --git a/tools/sync_website b/tools/sync_website deleted file mode 100755 index 8489bc54..00000000 --- a/tools/sync_website +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 $pid = open(F, "-|", qw(ssh -n -N -L 25555:127.0.0.1:3306 nagiosplugins.org)); - -# Allow time for ssh tunnel to be created -sleep 2; - -# To stop the death of ssh tunnel being defunct -$SIG{CHLD} = 'IGNORE'; - -END { kill 'INT', $pid if $pid }; - -my $dbh = DBI->connect("DBI:mysql:database=drupal;host=127.0.0.1;port=25555", "drupal", $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"; diff --git a/tools/update_man_pages b/tools/update_man_pages deleted file mode 100755 index 5c4a901e..00000000 --- a/tools/update_man_pages +++ /dev/null @@ -1,34 +0,0 @@ -#!/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"; |