ansible-edda/root/etc/systemd/system/zfs-scrub@.service
2022-08-30 20:27:32 +02:00

18 lines
563 B
Desktop File

[Unit]
Description=Zpool scrub on %i
Documentation=man:zpool-scrub(8)
Requires=zfs.target
After=zfs.target
ConditionACPower=true
ConditionPathIsDirectory=/sys/module/zfs
OnFailure=status-mail@%n.service
[Service]
EnvironmentFile=-/etc/default/zfs
ExecStart=/bin/sh -c '\
if /usr/sbin/zpool status %i | grep -q "scrub in progress"; then\
exec /usr/sbin/zpool wait -t scrub %i;\
else exec /usr/sbin/zpool scrub -w %i; fi'
ExecStop=-/bin/sh -c '/usr/sbin/zpool scrub -p %i 2>/dev/null || true'
ExecStopPost=/bin/sh -c '/usr/local/sbin/systemd-mail-zpool-status %i'