[ovs-dev] [PATCH 32/33] fedora-spec: added systemd post/postun/pre/preun sections
Flavio Leitner
fbl at redhat.com
Thu Nov 6 18:45:50 UTC 2014
The systemd requires some actions when the package is
installed, upgraded or removed. This patch adds the
needed RPM sections with the missing systemd actions.
There is a change in behavior - the service is not enabled
or started by default.
Signed-off-by: Flavio Leitner <fbl at redhat.com>
---
rhel/openvswitch-fedora.spec.in | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index 67b7ca9..f90762d 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -158,9 +158,16 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
rm -rf $RPM_BUILD_ROOT
%preun
-# Package removal, not upgrade
-systemctl stop openvswitch.service
-systemctl disable openvswitch.service
+%if 0%{?systemd_preun:1}
+ %systemd_preun %{name}.service
+%else
+ if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
+ /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
+ fi
+%endif
+
%post
if test ! -e /etc/openvswitch/conf.db; then
@@ -175,11 +182,28 @@ if test ! -e /etc/openvswitch/conf.db; then
'[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
> /dev/null
fi
-# Initial installation
-systemctl enable openvswitch.service
-systemctl start openvswitch.service
+
+%if 0%{?systemd_post:1}
+ %systemd_post %{name}.service
+%else
+ # Package install, not upgrade
+ if [ $1 -eq 1 ]; then
+ /bin/systemctl daemon-reload >dev/null || :
+ fi
+%endif
+
%postun
+%if 0%{?systemd_postun_with_restart:1}
+ %systemd_postun_with_restart %{name}.service
+%else
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+ if [ "$1" -ge "1" ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
+ fi
+%endif
+
%files -n python-openvswitch
%{python_sitelib}/ovs
--
1.9.3
More information about the dev
mailing list