]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - scrub/e2scrub_fail.in
e2scrub: add service (cron, systemd) support
[thirdparty/e2fsprogs.git] / scrub / e2scrub_fail.in
1 #!/bin/bash
2
3 # Email logs of failed e2scrub unit runs when the systemd service fails.
4
5 recipient="$1"
6 test -z "${recipient}" && exit 0
7 device="$2"
8 test -z "${device}" && exit 0
9 hostname="$(hostname -f 2>/dev/null)"
10 test -z "${hostname}" && hostname="${HOSTNAME}"
11 if ! type sendmail > /dev/null 2>&1; then
12 echo "$0: sendmail program not found."
13 exit 1
14 fi
15
16 (cat << ENDL
17 To: $1
18 From: <e2scrub@${hostname}>
19 Subject: e2scrub failure on ${device}
20
21 So sorry, the automatic e2scrub of ${device} on ${hostname} failed.
22
23 A log of what happened follows:
24 ENDL
25 systemctl status --full --lines 4294967295 "e2scrub@${device}") | sendmail -t -i