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
9 source /a
/bin
/errhandle
/err
10 status_file
=/dev
/shm
/iank-status
15 lo
() { /usr
/local
/bin
/log-once
"$@"; }
20 glob
=(/nocow
/btrfs-stale
/*)
21 if [[ -e $glob ]] ; then
24 glob
=(/m
/md
/bounces
/new
/*)
25 if [[ -e $glob ]]; then
27 lo
-1 bounce
"message in /m/md/bounces/new"
29 glob
=(/m
/md
/alerts
/new
/* /m
/md
/alerts
/cur
/*)
30 if [[ -e $glob ]]; then
33 if [[ -e /nocow
/user
/mailtest-failure
]]; then
36 if [[ -s /var
/log
/exim
4/paniclog
]]; then
38 tail /var
/log
/exim
4/paniclog | lo
-1 paniclog
41 source /a
/bin
/bash_unpublished
/source-state
42 if [[ $MAIL_HOST == $HOSTNAME ]]; then
43 if [[ $
(systemctl is-active btrbk.timer
) != active
]]; then
44 chars
+=("BTRBK.TIMER!")
45 lo
-60 btrbk.timer
"btrbk.timer not enabled"
48 ## check if last snapshot was within an hour
50 snaps
=(/mnt
/root
/btrbk
/$vol.20*)
53 for s
in ${snaps[@]}; do
55 t
=$
(date -d $
(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${file#$vol.}) +%s
)
56 if (( t
> maxtime
)); then
60 if (( maxtime
< now
- 60*60 )); then
61 chars
+=("OLD-SNAPSHOT!")
62 lo
-1 old-snapshot
"/o snapshot older than 1 hour"
66 cat /a
/bin
/bash_unpublished
/source-state
>$status_file
69 echo "ps_char=\"${chars[*]} \$ps_char\"" >>$status_file
78 for ((i
=1; i
<=3; i
++)); do