]>
Commit | Line | Data |
---|---|---|
824b5807 DW |
1 | #!/bin/bash |
2 | ||
eb62fcca DW |
3 | # SPDX-License-Identifier: GPL-2.0-or-later |
4 | # | |
5 | # Copyright (C) 2018-2024 Oracle. All Rights Reserved. | |
6 | # Author: Darrick J. Wong <djwong@kernel.org> | |
7 | ||
824b5807 DW |
8 | # Email logs of failed xfs_scrub unit runs |
9 | ||
824b5807 DW |
10 | recipient="$1" |
11 | test -z "${recipient}" && exit 0 | |
12 | mntpoint="$2" | |
13 | test -z "${mntpoint}" && exit 0 | |
14 | hostname="$(hostname -f 2>/dev/null)" | |
15 | test -z "${hostname}" && hostname="${HOSTNAME}" | |
83535ee5 DW |
16 | |
17 | mailer="$(command -v sendmail)" | |
824b5807 DW |
18 | if [ ! -x "${mailer}" ]; then |
19 | echo "${mailer}: Mailer program not found." | |
20 | exit 1 | |
21 | fi | |
22 | ||
595874f2 DW |
23 | # Turn the mountpoint into a properly escaped systemd instance name |
24 | scrub_svc="$(systemd-escape --template "@scrub_svcname@" --path "${mntpoint}")" | |
25 | ||
824b5807 DW |
26 | (cat << ENDL |
27 | To: $1 | |
28 | From: <xfs_scrub@${hostname}> | |
29 | Subject: xfs_scrub failure on ${mntpoint} | |
2201a9d5 DW |
30 | Content-Transfer-Encoding: 8bit |
31 | Content-Type: text/plain; charset=UTF-8 | |
824b5807 DW |
32 | |
33 | So sorry, the automatic xfs_scrub of ${mntpoint} on ${hostname} failed. | |
fd650873 | 34 | Please do not reply to this mesage. |
824b5807 DW |
35 | |
36 | A log of what happened follows: | |
37 | ENDL | |
595874f2 | 38 | systemctl status --full --lines 4294967295 "${scrub_svc}") | "${mailer}" -t -i |
731c9540 | 39 | exit "${PIPESTATUS[1]}" |