Commit | Line | Data |
---|---|---|
f5f6d9ac MW |
1 | #! /bin/sh |
2 | ### | |
3 | ### Run everyday health checks on remote systems. | |
4 | ||
5 | set -e | |
6 | cd /usr/local/share/rcheck | |
7 | ||
8 | for host in "$@"; do | |
9 | ||
10 | { { { set +e | |
11 | tar czf - check check.d | | |
12 | ssh "$host" ' | |
13 | set -e | |
14 | cd /tmp | |
15 | ||
16 | i=0 | |
17 | while :; do | |
18 | tmpdir=check.$$.$i | |
19 | if mkdir -m700 $tmpdir >/dev/null 2>&1; then break; fi | |
20 | case $i in | |
21 | 500) echo >&2 "failed to create temporary directory"; exit 125 ;; | |
22 | esac | |
23 | i=$((i + 1)) | |
24 | done | |
25 | trap "cd /; rm -rf /tmp/$tmpdir" INT TERM QUIT HUP EXIT | |
26 | cd $tmpdir | |
27 | ||
28 | tar xzf - | |
29 | ./check' | |
30 | rc=$?; set -e | |
31 | case $rc in | |
32 | 0) ;; | |
33 | *) echo >&2 "remote check process failed (rc = $rc)" ;; | |
34 | esac | |
35 | } 1>&3; } 2>&1 | | |
36 | sed 's/^/!!! /' | |
37 | } 3>&1 | | |
38 | if read line; then | |
39 | cat <<EOF | |
40 | ###-------------------------------------------------------------------------- | |
41 | ### $host | |
42 | ||
43 | $line | |
44 | EOF | |
45 | cat | |
46 | fi | |
47 | done |