aboutsummaryrefslogtreecommitdiffstats
path: root/rpm/generic/zfs.spec.in
diff options
context:
space:
mode:
authorRalf Ertzinger <[email protected]>2014-01-19 15:36:49 +0100
committerBrian Behlendorf <[email protected]>2014-02-05 12:25:30 -0800
commit881f45c6a8f44486f76c4713ecef0d533d6601e8 (patch)
treec16967ad7be5fc917b7052a23fbc8020bf07cafd /rpm/generic/zfs.spec.in
parentc5cb66addcb947ae8843c40c6db134ccd821adb7 (diff)
Add systemd unit files for ZFS startup
This adds systemd unit files replacing the functionality offered by the SysV init script found in etc/init.d. It has been developed and tested on Fedora 19, Fedora 20 and openSuSE 13.1. Four unit files and one target are offered. zfs-import-cache.service: Import pools from /etc/zfs/zpool.cache. This unit will wait for udev to settle. zfs-import-scan.service: Import pools by scanning /dev/disk/by-id for zvols. This unit will only run if /etc/zfs/zpool.cache is not present. This unit will wait for udev to settle zfs-mount.service: Mount ZFS native filesystems. It contains a dependency to be loaded before local-fs.target. zfs-share.service: Share NFS/SMB filesystems. This unit contains a dependency that will cause it to be restarted whenever the smb or nfs-server unit is restarted, restoring the shares added. zfs.target: This target pulls in the other units in order to start ZFS. It's the only unit that can be enabled/disabled, all other services are static and pulled in by dependencies. It will honour zfs=off and zfs=no options on the kernel command line. Signed-off-by: Brian Behlendorf <[email protected]> Closes #2108
Diffstat (limited to 'rpm/generic/zfs.spec.in')
-rw-r--r--rpm/generic/zfs.spec.in51
1 files changed, 49 insertions, 2 deletions
diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
index 1e64ac18e..bbe2a7e50 100644
--- a/rpm/generic/zfs.spec.in
+++ b/rpm/generic/zfs.spec.in
@@ -10,7 +10,24 @@
%bcond_with debug
%bcond_with blkid
+%bcond_with systemd
+# Generic enable switch for systemd
+%if %{with systemd}
+%define _systemd 1
+%endif
+
+# Fedora >= 15 comes with systemd, but only >= 18 has
+# the proper macros
+%if 0%{?fedora} >= 18
+%define _systemd 1
+%endif
+
+# opensuse >= 12.1 comes with systemd, but only >= 13.1
+# has the proper macros
+%if 0%{?suse_version} >= 1310
+%define _systemd 1
+%endif
Name: @PACKAGE@
Version: @VERSION@
@@ -38,6 +55,12 @@ BuildRequires: libuuid-devel
BuildRequires: libblkid-devel
%endif
%endif
+%if 0%{?_systemd}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+BuildRequires: systemd
+%endif
%description
This package contains the ZFS command line utilities and libraries.
@@ -85,6 +108,11 @@ image which is ZFS aware.
%else
%define blkid --without-blkid
%endif
+%if 0%{?_systemd}
+ %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --disable-sysvinit
+%else
+ %define systemd --enable-sysvinit --disable-systemd
+%endif
%setup -q
@@ -95,7 +123,8 @@ image which is ZFS aware.
--with-dracutdir=%{_dracutdir} \
--disable-static \
%{debug} \
- %{blkid}
+ %{blkid} \
+ %{systemd}
make %{?_smp_mflags}
%install
@@ -105,16 +134,28 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
%post
/sbin/ldconfig
+%if 0%{?_systemd}
+%systemd_post zfs.target
+%else
[ -x /sbin/chkconfig ] && /sbin/chkconfig --add zfs
+%endif
exit 0
%preun
+%if 0%{?_systemd}
+%systemd_preun zfs.target
+%else
if [ $1 -eq 0 ] ; then
[ -x /sbin/chkconfig ] && /sbin/chkconfig --del zfs
fi
+%endif
exit 0
-%postun -p /sbin/ldconfig
+%postun
+/sbin/ldconfig
+%if 0%{?_systemd}
+%systemd_postun zfs.target
+%endif
%files
%doc AUTHORS COPYRIGHT DISCLAIMER
@@ -129,7 +170,13 @@ exit 0
%{_udevdir}/zvol_id
%{_udevdir}/rules.d/*
%config(noreplace) %{_sysconfdir}/%{name}
+%if 0%{?_systemd}
+/usr/lib/modules-load.d/*
+%{_unitdir}/*
+%{_presetdir}/*
+%else
%{_sysconfdir}/init.d/*
+%endif
%files devel
%{_libdir}/*.so