2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
5 # usage: runs 4 times every 15 seconds unless any args are passed, then just runs once
7 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
10 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
12 status_file
=/dev
/shm
/iank-status
17 lo
() { /usr
/local
/bin
/log-once
-1 "$@"; }
22 glob
=(/nocow
/btrfs-stale
/*)
23 if [[ -e $glob ]] ; then
26 glob
=(/m
/md
/bounces
/new
/*)
27 if [[ -e $glob ]]; then
29 lo bounce
"message in /m/md/bounces/new"
31 glob
=(/m
/md
/alerts
/new
/* /m
/md
/alerts
/cur
/*)
32 if [[ -e $glob ]]; then
35 if [[ -e /nocow
/user
/mailtest-failure
]]; then
37 lo mailping
"mailtest-check didnt see mail from send-test-forward"
39 if [[ -s /var
/log
/exim
4/paniclog
]]; then
41 tail /var
/log
/exim
4/paniclog | lo paniclog
44 source /a
/bin
/bash_unpublished
/source-state
45 if [[ $MAIL_HOST == $HOSTNAME ]]; then
46 if [[ $
(systemctl is-active btrbk.timer
) != active
]]; then
47 chars
+=("BTRBK-TIMER!")
50 ## check if last snapshot was within an hour
52 snaps
=(/mnt
/root
/btrbk
/$vol.20*)
55 for s
in ${snaps[@]}; do
57 t
=$
(date -d $
(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${file#$vol.}) +%s
)
58 if (( t
> maxtime
)); then
62 if (( maxtime
< now
- 60*60 )); then
63 chars
+=("OLD-SNAPSHOT!")
67 cat /a
/bin
/bash_unpublished
/source-state
>$status_file
70 echo "ps_char=\"${chars[*]} \$ps_char\"" >>$status_file
79 for ((i
=1; i
<=3; i
++)); do