From 42b4c3fcdefb3b6a1308b5fe4a730aa89c21a0b9 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 7 Aug 2024 15:54:58 -0700 Subject: [PATCH] debian: enable xfs_scrubbed on the root filesystem by default Now that we're finished building autonomous repair, enable the service on the root filesystem by default. The root filesystem is mounted by the initrd prior to starting systemd, which is why the udev rule cannot autostart the service for the root filesystem. dh_installsystemd won't activate a template service (aka one with an at-sign in the name) even if it provides a DefaultInstance directive to make that possible. Use a fugly shim for this. Signed-off-by: Darrick J. Wong --- debian/control | 2 +- debian/postinst | 8 ++++++++ debian/prerm | 13 +++++++++++++ scrub/xfs_scrubbed@.service.in | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 debian/prerm diff --git a/debian/control b/debian/control index 31773e53a..e4b3de3ee 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Homepage: https://xfs.wiki.kernel.org/ Package: xfsprogs Depends: ${shlibs:Depends}, ${misc:Depends}, python3-dbus, python3:any Provides: fsck-backend -Suggests: xfsdump, acl, attr, quota +Suggests: xfsdump, acl, attr, quota, python3-jsonschema Breaks: xfsdump (<< 3.0.0) Replaces: xfsdump (<< 3.0.0) Architecture: linux-any diff --git a/debian/postinst b/debian/postinst index 2ad917465..4ba2e0c43 100644 --- a/debian/postinst +++ b/debian/postinst @@ -24,5 +24,13 @@ case "${1}" in esac #DEBHELPER# +# +# dh_installsystemd doesn't handle template services even if we supply a +# default instance, so we'll install it here. +if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ] ; then + if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + /bin/systemctl enable xfs_scrubbed@.service || true + fi +fi exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 000000000..48e8e94c4 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +# dh_installsystemd doesn't handle template services even if we supply a +# default instance, so we'll install it here. +if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then + /bin/systemctl disable xfs_scrubbed@.service || true +fi + +#DEBHELPER# + +exit 0 diff --git a/scrub/xfs_scrubbed@.service.in b/scrub/xfs_scrubbed@.service.in index 937876f28..a8ea6712c 100644 --- a/scrub/xfs_scrubbed@.service.in +++ b/scrub/xfs_scrubbed@.service.in @@ -19,7 +19,7 @@ RequiresMountsFor=%f Type=exec Environment=SERVICE_MODE=1 ExecCondition=@pkg_libexec_dir@/xfs_scrubbed --check %f -ExecStart=@pkg_libexec_dir@/xfs_scrubbed --log %f +ExecStart=@pkg_libexec_dir@/xfs_scrubbed --autofsck --log %f SyslogIdentifier=%N # Run scrub with minimal CPU and IO priority so that nothing else will starve. -- 2.50.1