]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - scrub/e2scrub_fail.in
libext2fs: hide struct ext2fs_hashmap as an internal implementation detail
[thirdparty/e2fsprogs.git] / scrub / e2scrub_fail.in
CommitLineData
a2df5894
DW
1#!/bin/bash
2
3# Email logs of failed e2scrub unit runs when the systemd service fails.
4
48cc0079 5device="$1"
a2df5894 6test -z "${device}" && exit 0
48cc0079 7
a2df5894
DW
8if ! type sendmail > /dev/null 2>&1; then
9 echo "$0: sendmail program not found."
10 exit 1
11fi
12
48cc0079
TT
13if test -f /etc/e2scrub.conf ; then
14 . /etc/e2scrub.conf
15fi
16
17hostname="$(hostname -f 2>/dev/null)"
18test -z "${hostname}" && hostname="${HOSTNAME}"
19service_name="e2scrub@$(systemd-escape ${device})"
20
21if test -z "${recipient}" ; then
22 recipient="root"
23fi
24
25if test -z "${sender}" ; then
26 sender="<e2scrub@${hostname}>"
27fi
28
a2df5894 29(cat << ENDL
48cc0079
TT
30To: ${recipient}
31From: ${sender}
a2df5894
DW
32Subject: e2scrub failure on ${device}
33
34So sorry, the automatic e2scrub of ${device} on ${hostname} failed.
35
36A log of what happened follows:
37ENDL
48cc0079 38systemctl status --full --lines 4294967295 "${service_name}") | sendmail -t -i