%post
%if 0%{?_systemd}
+%if 0%{?systemd_post:1}
%systemd_post %{systemd_svcs}
%else
+if [ "$1" = "1" -o "$1" = "install" ] ; then
+ # Initial installation
+ systemctl preset %{systemd_svcs} >/dev/null || true
+fi
+%endif
+%else
if [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --add zfs-import
/sbin/chkconfig --add zfs-mount
%preun
%if 0%{?_systemd}
+%if 0%{?systemd_preun:1}
%systemd_preun %{systemd_svcs}
%else
-if [ "$1" = "0" ] && [ -x /sbin/chkconfig ]; then
+if [ "$1" = "0" -o "$1" = "remove" ] ; then
+ # Package removal, not upgrade
+ systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
+ systemctl stop %{systemd_svcs} >/dev/null || true
+fi
+%endif
+%else
+if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --del zfs-import
/sbin/chkconfig --del zfs-mount
/sbin/chkconfig --del zfs-share
%postun
%if 0%{?_systemd}
+%if 0%{?systemd_postun:1}
%systemd_postun %{systemd_svcs}
+%else
+systemctl --system daemon-reload >/dev/null || true
+%endif
%endif
%files