[RFC 3/3] systemd integration scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux