summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-12-28 23:39:07 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-12-28 23:39:07 (GMT)
commit049ef89f61d90b253c7dfdddde830054c385b78a (patch)
tree8064ce562dc008d55ea96ac8888ab0e4c53f411f /bin
parent9f4dadf606fd54c59fe7f02f714227655527ade6 (diff)
downloadsite-049ef89f61d90b253c7dfdddde830054c385b78a.tar.gz
Let Cron check our FTP mirrors
Add a daily job that updates a timestamp file in our download area and checks whether the FTP mirrors fetched the one from yesterday.
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"