Whamcloud - gitweb
e2scrub: use WantedBy=multi-user.target in e2scrub_reap.service
[tools/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 device="$1"
6 test -z "${device}" && exit 0
7
8 if ! type sendmail > /dev/null 2>&1; then
9         echo "$0: sendmail program not found."
10         exit 1
11 fi
12
13 if test -f /etc/e2scrub.conf ; then
14    . /etc/e2scrub.conf
15 fi
16
17 hostname="$(hostname -f 2>/dev/null)"
18 test -z "${hostname}" && hostname="${HOSTNAME}"
19 service_name="e2scrub@$(systemd-escape ${device})"
20
21 if test -z "${recipient}" ; then
22     recipient="root"
23 fi
24
25 if test -z "${sender}" ; then
26     sender="<e2scrub@${hostname}>"
27 fi
28
29 (cat << ENDL
30 To: ${recipient}
31 From: ${sender}
32 Subject: e2scrub failure on ${device}
33
34 So sorry, the automatic e2scrub of ${device} on ${hostname} failed.
35
36 A log of what happened follows:
37 ENDL
38 systemctl status --full --lines 4294967295 "${service_name}") | sendmail -t -i