chiark / gitweb /
check.d/50.updates: Output the list of updates.
[rcheck] / rcheck
CommitLineData
f5f6d9ac
MW
1#! /bin/sh
2###
3### Run everyday health checks on remote systems.
4
5set -e
0c159fe7
MW
6prog=$0
7while
8 case "$prog" in */*) ;; *) prog=./$prog ;; esac
9 cd "${prog%/*}"
10 [ -L "${prog##*/}" ]
11do
12 prog=$(readlink "${prog##*/}")
13done
f5f6d9ac 14
ff90728f
MW
15args=""
16usage () {
17 echo "usage: ${0##*/} [-[MIN-][MAX]] [HOST...]"
18}
19while :; do
20 case $# in 0) break ;; esac
21 case $1 in
22 -) break ;;
23 --) shift; break ;;
24 -*[!0-9]*-* | -*-*[!0-9]*) usage >&2; exit 1 ;;
25 -*-) a=${1#-}; a=${a%-}; args="$a" ;;
26 -*-*) a=${1#-}; b=${a#*-}; a=${a%-*}; args="$a $b" ;;
27 -*[!0-9]*) usage >&2; exit 1 ;;
28 -*) a=${1#-}; args="0 $a" ;;
29 *) break ;;
30 esac
31 shift
32done
66015b8c
MW
33case $# in 0) set -- $(expand-list /etc/slaves :rcheck_hosts) ;; esac
34
b742457e
MW
35exec 4>&1
36rc=0
f5f6d9ac 37for host in "$@"; do
b742457e
MW
38 nrc=$(
39 exec 5>&1
40 { { { set +e
41 tar czf - check check.d |
42 ssh "$host" '
f5f6d9ac
MW
43set -e
44cd /tmp
45
46i=0
47while :; do
48 tmpdir=check.$$.$i
49 if mkdir -m700 $tmpdir >/dev/null 2>&1; then break; fi
50 case $i in
51 500) echo >&2 "failed to create temporary directory"; exit 125 ;;
52 esac
53 i=$((i + 1))
54done
55trap "cd /; rm -rf /tmp/$tmpdir" INT TERM QUIT HUP EXIT
56cd $tmpdir
57
58tar xzf -
ff90728f 59./check'" $args"
b742457e
MW
60 rc=$?; set -e; echo $rc >&5
61 case $rc in
62 0) ;;
63 *) echo >&2 "remote check process failed (rc = $rc)" ;;
64 esac
65 } 1>&3; } 2>&1 |
66 sed 's/^/!!! /'
67 } 3>&1 |
68 if IFS= read -r line; then
69 cat <<EOF
f5f6d9ac
MW
70###--------------------------------------------------------------------------
71### $host
72
73$line
74EOF
b742457e
MW
75 cat
76 fi >&4
77 )
78 if [ $nrc -gt $rc ]; then rc=$nrc; fi
f5f6d9ac 79done
b742457e
MW
80
81exit $rc