diff options
| -rwxr-xr-x | bin/check-mirrors | 47 | ||||
| -rw-r--r-- | etc/crontab | 1 |
2 files changed, 48 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 | |||
| 15 | set -e | ||
| 16 | set -u | ||
| 17 | umask 022 | ||
| 18 | |||
| 19 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | ||
| 20 | |||
| 21 | mirrors=' | ||
| 22 | ftp://ftp.fu-berlin.de/unix/network/nagios-plugins/ | ||
| 23 | ftp://ftp.lysator.liu.se/pub/nagios-plugins/ | ||
| 24 | ' | ||
| 25 | prefix='/home/plugins' | ||
| 26 | myself=${0##*/} | ||
| 27 | download_dir="$prefix/web/download" | ||
| 28 | temp_dir=$(mktemp -d "/tmp/$myself.XXXXXX") | ||
| 29 | |||
| 30 | trap 'rm -rf "$temp_dir"' EXIT | ||
| 31 | |||
| 32 | cd "$temp_dir" | ||
| 33 | date -d 'yesterday' '+%F' >'expected' | ||
| 34 | for mirror in $mirrors | ||
| 35 | do | ||
| 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 | ||
| 45 | done | ||
| 46 | cd "$OLDPWD" | ||
| 47 | date '+%F' >"$download_dir/timestamp" | ||
diff --git a/etc/crontab b/etc/crontab index 86bba49..0339f69 100644 --- a/etc/crontab +++ b/etc/crontab | |||
| @@ -5,3 +5,4 @@ | |||
| 5 | MAILTO=admin@monitoring-plugins.org | 5 | MAILTO=admin@monitoring-plugins.org |
| 6 | # | 6 | # |
| 7 | */10 * * * * $HOME/bin/git-mirror $HOME/repositories/nagios-*.git | 7 | */10 * * * * $HOME/bin/git-mirror $HOME/repositories/nagios-*.git |
| 8 | 44 4 * * * $HOME/bin/check-mirrors | ||
