aboutsummaryrefslogtreecommitdiffstats
path: root/etc/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'etc/systemd')
-rw-r--r--etc/systemd/Makefile.am1
-rw-r--r--etc/systemd/system/.gitignore3
-rw-r--r--etc/systemd/system/50-zfs.preset.in2
-rw-r--r--etc/systemd/system/Makefile.am31
-rw-r--r--etc/systemd/system/zfs-import-cache.service.in11
-rw-r--r--etc/systemd/system/zfs-import-scan.service.in11
-rw-r--r--etc/systemd/system/zfs-mount.service.in15
-rw-r--r--etc/systemd/system/zfs-share.service.in11
-rw-r--r--etc/systemd/system/zfs.target.in7
9 files changed, 92 insertions, 0 deletions
diff --git a/etc/systemd/Makefile.am b/etc/systemd/Makefile.am
new file mode 100644
index 000000000..d4008c0dd
--- /dev/null
+++ b/etc/systemd/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = system
diff --git a/etc/systemd/system/.gitignore b/etc/systemd/system/.gitignore
new file mode 100644
index 000000000..efada54ad
--- /dev/null
+++ b/etc/systemd/system/.gitignore
@@ -0,0 +1,3 @@
+*.service
+*.target
+*.preset
diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset.in
new file mode 100644
index 000000000..4efdd7200
--- /dev/null
+++ b/etc/systemd/system/50-zfs.preset.in
@@ -0,0 +1,2 @@
+# ZFS is enabled by default
+enable zfs.*
diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am
new file mode 100644
index 000000000..31521cecc
--- /dev/null
+++ b/etc/systemd/system/Makefile.am
@@ -0,0 +1,31 @@
+systemdpreset_DATA = \
+ $(top_srcdir)/etc/systemd/system/50-zfs.preset
+systemdunit_DATA = \
+ $(top_srcdir)/etc/systemd/system/zfs-import-scan.service \
+ $(top_srcdir)/etc/systemd/system/zfs-import-cache.service \
+ $(top_srcdir)/etc/systemd/system/zfs-mount.service \
+ $(top_srcdir)/etc/systemd/system/zfs-share.service \
+ $(top_srcdir)/etc/systemd/system/zfs.target
+
+EXTRA_DIST = \
+ $(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \
+ $(top_srcdir)/etc/systemd/system/zfs-import-cache.service.in \
+ $(top_srcdir)/etc/systemd/system/zfs-mount.service.in \
+ $(top_srcdir)/etc/systemd/system/zfs-share.service.in \
+ $(top_srcdir)/etc/systemd/system/zfs.target.in \
+ $(top_srcdir)/etc/systemd/system/50-zfs.preset.in
+
+$(systemdunit_DATA):
+ -$(SED) -e 's,@bindir\@,$(bindir),g' \
+ -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@sysconfdir\@,$(sysconfdir),g' \
+
+$(systemdpreset_DATA):
+ -$(SED) -e 's,@bindir\@,$(bindir),g' \
+ -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@sysconfdir\@,$(sysconfdir),g' \
+
+distclean-local::
+ -$(RM) $(systemdunit_DATA) $(systemdpreset_DATA)
diff --git a/etc/systemd/system/zfs-import-cache.service.in b/etc/systemd/system/zfs-import-cache.service.in
new file mode 100644
index 000000000..918a258a1
--- /dev/null
+++ b/etc/systemd/system/zfs-import-cache.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Import ZFS pools by cache file
+DefaultDependencies=no
+Requires=systemd-udev-settle.service
+After=systemd-udev-settle.service
+ConditionPathExists=@sysconfdir@/zfs/zpool.cache
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
diff --git a/etc/systemd/system/zfs-import-scan.service.in b/etc/systemd/system/zfs-import-scan.service.in
new file mode 100644
index 000000000..ab1b0f693
--- /dev/null
+++ b/etc/systemd/system/zfs-import-scan.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Import ZFS pools by device scanning
+DefaultDependencies=no
+Requires=systemd-udev-settle.service
+After=systemd-udev-settle.service
+ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@sbindir@/zpool import -d /dev/disk/by-id -aN
diff --git a/etc/systemd/system/zfs-mount.service.in b/etc/systemd/system/zfs-mount.service.in
new file mode 100644
index 000000000..f1056af31
--- /dev/null
+++ b/etc/systemd/system/zfs-mount.service.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=Mount ZFS filesystems
+DefaultDependencies=no
+Wants=zfs-import-cache.service
+Wants=zfs-import-scan.service
+Requires=systemd-udev-settle.service
+After=systemd-udev-settle.service
+After=zfs-import-cache.service
+After=zfs-import-scan.service
+Before=local-fs.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@sbindir@/zfs mount -a
diff --git a/etc/systemd/system/zfs-share.service.in b/etc/systemd/system/zfs-share.service.in
new file mode 100644
index 000000000..a21c9c663
--- /dev/null
+++ b/etc/systemd/system/zfs-share.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=ZFS file system shares
+After=nfs-server.service
+After=smb.service
+PartOf=nfs-server.service
+PartOf=smb.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@sbindir@/zfs share -a
diff --git a/etc/systemd/system/zfs.target.in b/etc/systemd/system/zfs.target.in
new file mode 100644
index 000000000..7d464873b
--- /dev/null
+++ b/etc/systemd/system/zfs.target.in
@@ -0,0 +1,7 @@
+[Unit]
+Description=ZFS startup target
+Requires=zfs-mount.service
+Requires=zfs-share.service
+
+[Install]
+WantedBy=multi-user.target