summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/check-mirrors47
1 files changed, 47 insertions, 0 deletions
diff --git a/bin/check-mirrors b/bin/check-mirrors
new file mode 100755
index 0000000..ed37c38
--- /dev/null
+++ b/bin/check-mirrors
@@ -0,0 +1,47 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17umask 022
18
19export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
20
21mirrors='
22 ftp://ftp.fu-berlin.de/unix/network/nagios-plugins/
23 ftp://ftp.lysator.liu.se/pub/nagios-plugins/
24'
25prefix='/home/plugins'
26myself=${0##*/}
27download_dir="$prefix/web/download"
28temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX")
29
30trap 'rm -rf "$temp_dir"' EXIT
31
32cd "$temp_dir"
33date -d 'yesterday' '+%F' >'expected'
34for mirror in $mirrors
35do
36 url="${mirror%/}/timestamp"
37
38 if curl -s -S -O "$url" >'curl.log' 2>&1
39 then
40 cmp -s 'expected' 'timestamp' \
41 || echo >&2 "$mirror is outdated ($(cat 'timestamp'))."
42 else
43 echo >&2 "Cannot fetch $url: $(cat 'curl.log')"
44 fi
45done
46cd "$OLDPWD"
47date '+%F' >"$download_dir/timestamp"