From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>
Subject: [RFC 3/3] systemd integration scripts
Date: Fri, 21 Jul 2017 17:33:10 -0700 [thread overview]
Message-ID: <20170722003310.GG4211@magnolia> (raw)
In-Reply-To: <20170722002643.GD4211@magnolia>
Here's the systemd stuff. I haven't bothered to supply a cronjob,
since it's trivial to create a cron.weekly entry that runs
/sbin/online-fsck-all.
--D
/lib/systemd/system/online-fsck-all.service:
[Unit]
Description=Scrub Filesystem Metadata
ConditionACPower=true
[Service]
Type=oneshot
Environment=SERVICE_MODE=1
ExecStart=/sbin/online-fsck-all
/lib/systemd/system/online-fsck-all.timer:
[Unit]
Description=Scrub Filesystem Metadata Periodically
[Timer]
# Run on Sunday at 3:30am, to avoid running afoul of DST changes
OnCalendar=Sun *-*-* 03:30:00
RandomizedDelaySec=60
Persistent=true
[Install]
WantedBy=timers.target
/lib/systemd/system/online-fsck-fail@.service:
[Unit]
Description=Scrub Filesystem Metadata Failure Reporting for %I
[Service]
Type=oneshot
Environment=EMAIL_ADDR=root@localhost
ExecStart=/usr/lib/online-fsck/online-scrub-fail "${EMAIL_ADDR}" %I
User=mail
Group=mail
SupplementaryGroups=systemd-journal
/lib/systemd/system/online-fsck@.service:
[Unit]
Description=Scrub Filesystem Metadata for %I
OnFailure=online-fsck-fail@%i.service
[Service]
Type=oneshot
WorkingDirectory=/
PrivateNetwork=true
ProtectSystem=true
ProtectHome=read-only
PrivateTmp=yes
AmbientCapabilities=CAP_SYS_ADMIN CAP_SYS_RAWIO
NoNewPrivileges=yes
User=root
IOSchedulingClass=idle
CPUSchedulingPolicy=idle
Environment=SERVICE_MODE=1
ExecStart=/sbin/online-fsck -t %I
/usr/lib/online-fsck/online-scrub-fail:
#!/bin/bash
# Email logs of failed online-fsck unit runs
mailer=/usr/sbin/sendmail
recipient="$1"
test -z "${recipient}" && exit 0
dev="$2"
test -z "${dev}" && exit 0
hostname="$(hostname -f 2>/dev/null)"
test -z "${hostname}" && hostname="${HOSTNAME}"
if [ ! -x "${mailer}" ]; then
echo "${mailer}: Mailer program not found."
exit 1
fi
(cat << ENDL
To: $1
From: <online-fsck@${hostname}>
Subject: online-fsck failure on ${dev}
So sorry, the automatic online-fsck of ${dev} on ${hostname} failed.
A log of what happened follows:
ENDL
systemctl status --full --lines 4294967295 "online-fsck@${dev}") | "${mailer}" -t -i
prev parent reply other threads:[~2017-07-22 0:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-22 0:26 [RFC] online scrub for ext4 Darrick J. Wong
2017-07-22 0:29 ` [RFC 1/3] scripts to create and fsck a snapshot Darrick J. Wong
2017-07-22 0:30 ` [RFC 2/3] scripts to find eligible lv ext4 filesystems Darrick J. Wong
2017-07-22 0:33 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170722003310.GG4211@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).