minor improvements
[distro-setup] / system-status
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
6
7 set -eE -o pipefail
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
9
10 f=/dev/shm/iank-status
11
12 write-status() {
13 chars=()
14
15 if test -e /nocow/btrfs-stale/*; then
16 chars+=("STALE!")
17 fi
18 if test -e /m/md/bounces/new/*; then
19 chars+=("BOUNCE!")
20 fi
21 if [[ -e /nocow/user/mailtest-failure ]]; then
22 chars+=("MAILPING!")
23 fi
24 if [[ -s /var/log/exim4/paniclog ]]; then
25 chars+=("PANIC!")
26 fi
27
28 cat /a/bin/bash_unpublished/source-state >$f
29
30 if [[ $chars ]]; then
31 echo "ps_char=\"${chars[*]} \$ps_char\"" >>$f
32 fi
33 }
34 write-status
35 if [[ $@ ]]; then
36 exit 0
37 fi
38 for ((i=1; i<=3; i++)); do
39 sleep 15
40 write-status
41 done