autofs-5.0.6 - systemd support fixes
From: Ian Kent <raven@themaw.net>
Fix up some of in spec file systemd scriptlets.
The pre-system package verion uninstall scriptlet has been commented
out in the tar spec file. It's is an example of what might need to
be done in a distro spec file.
---
CHANGELOG | 1 +
autofs.spec | 35 +++++++++++++++++++++++++++--------
samples/autofs.service.in | 1 +
3 files changed, 29 insertions(+), 8 deletions(-)
--- autofs-5.0.6.orig/CHANGELOG
+++ autofs-5.0.6/CHANGELOG
@@ -29,6 +29,7 @@
- reinstate singleton mount probe.
- rework error return handling in rpc code.
- catch EHOSTUNREACH and bail out early.
+- systemd support fixes.
28/06/2011 autofs-5.0.6
-----------------------
--- autofs-5.0.6.orig/autofs.spec
+++ autofs-5.0.6/autofs.spec
@@ -105,27 +105,36 @@ install -m 644 redhat/autofs.sysconfig $
%post
%if %{with_systemd}
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -eq 1 ]; then
+ %{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || :
+ # autofs has been approved to be enabled by default
+ %{_bindir}systemctl enable %{name}.service >/dev/null 2>&1 || :
+fi
%else
-chkconfig --add autofs
+if [ $1 -eq 1 ]; then
+ chkconfig --add autofs
+fi
%endif
%preun
-if [ "$1" = 0 ] ; then
%if %{with_systemd}
- /bin/systemctl --no-reload disable autofs.service > /dev/null 2>&1 || :
- /bin/systemctl stop autofs.service > /dev/null 2>&1 || :
+if [ $1 -eq 0 ] ; then
+ %{_bindir}/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
+ %{_bindir}/systemctl stop %{name}.service > /dev/null 2>&1 || :
+fi
%else
+if [ $1 -eq 0 ] ; then
/sbin/service autofs stop > /dev/null 2>&1 || :
/sbin/chkconfig --del autofs
-%endif
fi
+%endif
%postun
%if %{with_systemd}
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%{_bindir}/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
- /bin/systemctl try-restart autofs.service >/dev/null 2>&1 || :
+ # Package upgrade, not removal
+ /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
fi
%else
if [ $1 -ge 1 ] ; then
@@ -133,6 +142,16 @@ if [ $1 -ge 1 ] ; then
fi
%endif
+#%triggerun -- %{name} < $bla release
+## Save the current service runlevel info
+## User must manually run systemd-sysv-convert --apply %{name}
+## to migrate them to systemd targets
+#%{_bindir}/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||:
+#
+## Run these because the SysV package being removed won't do them
+#%{_sbindir}/chkconfig --del %{name} >/dev/null 2>&1 || :
+#%{_bindir}/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root)
%doc CREDITS CHANGELOG INSTALL COPY* README* samples/ldap* samples/autofs.schema samples/autofs_ldap_auth.conf
--- autofs-5.0.6.orig/samples/autofs.service.in
+++ autofs-5.0.6/samples/autofs.service.in
@@ -7,6 +7,7 @@ Type=forking
PIDFile=@@autofspiddir@@/autofs.pid
EnvironmentFile=-@@autofsconfdir@@/autofs
ExecStart=@@sbindir@@/automount ${OPTIONS} --pid-file @@autofspiddir@@/autofs.pid
+ExecReload=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target