]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - scrub/xfs_scrub_fail.in
Remove use of LFS64 interfaces
[thirdparty/xfsprogs-dev.git] / scrub / xfs_scrub_fail.in
CommitLineData
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
10recipient="$1"
11test -z "${recipient}" && exit 0
12mntpoint="$2"
13test -z "${mntpoint}" && exit 0
14hostname="$(hostname -f 2>/dev/null)"
15test -z "${hostname}" && hostname="${HOSTNAME}"
83535ee5
DW
16
17mailer="$(command -v sendmail)"
824b5807
DW
18if [ ! -x "${mailer}" ]; then
19 echo "${mailer}: Mailer program not found."
20 exit 1
21fi
22
595874f2
DW
23# Turn the mountpoint into a properly escaped systemd instance name
24scrub_svc="$(systemd-escape --template "@scrub_svcname@" --path "${mntpoint}")"
25
824b5807
DW
26(cat << ENDL
27To: $1
28From: <xfs_scrub@${hostname}>
29Subject: xfs_scrub failure on ${mntpoint}
2201a9d5
DW
30Content-Transfer-Encoding: 8bit
31Content-Type: text/plain; charset=UTF-8
824b5807
DW
32
33So sorry, the automatic xfs_scrub of ${mntpoint} on ${hostname} failed.
fd650873 34Please do not reply to this mesage.
824b5807
DW
35
36A log of what happened follows:
37ENDL
595874f2 38systemctl status --full --lines 4294967295 "${scrub_svc}") | "${mailer}" -t -i
731c9540 39exit "${PIPESTATUS[1]}"