diff options
author | Michael Niewöhner <[email protected]> | 2019-04-03 02:14:39 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-04-02 17:14:39 -0700 |
commit | ce4432c5424eb9aa4d00833ee7529cf24491bdde (patch) | |
tree | 90a31dd531a2d3f12d868816bd9e9fc05bae5726 | |
parent | f72ecb8d2779ef8b3e8892280c8c8756a419e461 (diff) |
Move dracut specifics to dracut module
Dracut depends on the environment variable BOOTFS to be set after pool
import. This dracut specific systemd ExecStartPost command should not be
called for any non-dracut systems, so let's move it to a static systemd
unit that.
Reviewed-by: Manuel Amador (Rudd-O) <[email protected]>
Reviewed-by: Matthew Thode <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Michael Niewöhner <[email protected]>
Closes #8510
-rw-r--r-- | contrib/dracut/90zfs/.gitignore | 1 | ||||
-rw-r--r-- | contrib/dracut/90zfs/Makefile.am | 10 | ||||
-rwxr-xr-x | contrib/dracut/90zfs/module-setup.sh.in | 3 | ||||
-rw-r--r-- | contrib/dracut/90zfs/zfs-env-bootfs.service.in | 14 | ||||
-rw-r--r-- | etc/systemd/system/zfs-import-cache.service.in | 1 | ||||
-rw-r--r-- | etc/systemd/system/zfs-import-scan.service.in | 1 |
6 files changed, 25 insertions, 5 deletions
diff --git a/contrib/dracut/90zfs/.gitignore b/contrib/dracut/90zfs/.gitignore index eb41fce4f..85c23f75e 100644 --- a/contrib/dracut/90zfs/.gitignore +++ b/contrib/dracut/90zfs/.gitignore @@ -6,3 +6,4 @@ zfs-generator.sh zfs-lib.sh zfs-load-key.sh zfs-needshutdown.sh +zfs-env-bootfs.service diff --git a/contrib/dracut/90zfs/Makefile.am b/contrib/dracut/90zfs/Makefile.am index afcd51022..0a557f57f 100644 --- a/contrib/dracut/90zfs/Makefile.am +++ b/contrib/dracut/90zfs/Makefile.am @@ -9,6 +9,9 @@ pkgdracut_SCRIPTS = \ zfs-needshutdown.sh \ zfs-lib.sh +pkgdracut_DATA = \ + zfs-env-bootfs.service + EXTRA_DIST = \ $(top_srcdir)/contrib/dracut/90zfs/export-zfs.sh.in \ $(top_srcdir)/contrib/dracut/90zfs/module-setup.sh.in \ @@ -17,9 +20,10 @@ EXTRA_DIST = \ $(top_srcdir)/contrib/dracut/90zfs/zfs-generator.sh.in \ $(top_srcdir)/contrib/dracut/90zfs/zfs-load-key.sh.in \ $(top_srcdir)/contrib/dracut/90zfs/zfs-needshutdown.sh.in \ - $(top_srcdir)/contrib/dracut/90zfs/zfs-lib.sh.in + $(top_srcdir)/contrib/dracut/90zfs/zfs-lib.sh.in \ + $(top_srcdir)/contrib/dracut/90zfs/zfs-env-bootfs.service.in -$(pkgdracut_SCRIPTS):%:%.in +$(pkgdracut_SCRIPTS) $(pkgdracut_DATA) :%:%.in -$(SED) -e 's,@bindir\@,$(bindir),g' \ -e 's,@sbindir\@,$(sbindir),g' \ -e 's,@udevdir\@,$(udevdir),g' \ @@ -30,4 +34,4 @@ $(pkgdracut_SCRIPTS):%:%.in $< >'$@' distclean-local:: - -$(RM) $(pkgdracut_SCRIPTS) + -$(RM) $(pkgdracut_SCRIPTS) $(pkgdracut_DATA) diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in index f595a369c..4efc4b018 100755 --- a/contrib/dracut/90zfs/module-setup.sh.in +++ b/contrib/dracut/90zfs/module-setup.sh.in @@ -98,6 +98,9 @@ install() { type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service fi done + inst "${moddir}"/zfs-env-bootfs.service "${systemdsystemunitdir}"/zfs-env-bootfs.service + ln -s ../zfs-env-bootfs.service "${initdir}/${systemdsystemunitdir}/zfs-import.target.wants"/zfs-env-bootfs.service + type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-env-bootfs.service dracut_install systemd-ask-password dracut_install systemd-tty-ask-password-agent mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants" diff --git a/contrib/dracut/90zfs/zfs-env-bootfs.service.in b/contrib/dracut/90zfs/zfs-env-bootfs.service.in new file mode 100644 index 000000000..3cdf69100 --- /dev/null +++ b/contrib/dracut/90zfs/zfs-env-bootfs.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=Set BOOTFS environment for dracut +Documentation=man:zpool(8) +DefaultDependencies=no +After=zfs-import-cache.service +After=zfs-import-scan.service +Before=zfs-import.target + +[Service] +Type=oneshot +ExecStart=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')" + +[Install] +WantedBy=zfs-import.target diff --git a/etc/systemd/system/zfs-import-cache.service.in b/etc/systemd/system/zfs-import-cache.service.in index 8087a294d..cacb53651 100644 --- a/etc/systemd/system/zfs-import-cache.service.in +++ b/etc/systemd/system/zfs-import-cache.service.in @@ -13,7 +13,6 @@ ConditionPathExists=@sysconfdir@/zfs/zpool.cache Type=oneshot RemainAfterExit=yes ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN -ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')" [Install] WantedBy=zfs-import.target diff --git a/etc/systemd/system/zfs-import-scan.service.in b/etc/systemd/system/zfs-import-scan.service.in index 802328da3..4aae9f06e 100644 --- a/etc/systemd/system/zfs-import-scan.service.in +++ b/etc/systemd/system/zfs-import-scan.service.in @@ -12,7 +12,6 @@ ConditionPathExists=!@sysconfdir@/zfs/zpool.cache Type=oneshot RemainAfterExit=yes ExecStart=@sbindir@/zpool import -aN -o cachefile=none -ExecStartPost=/bin/sh -c "/bin/systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')" [Install] WantedBy=zfs-import.target |