From 0447019df7c6cec4cf94e1d4d56ed9ddbcd0402d Mon Sep 17 00:00:00 2001 From: Flavio Leitner Date: Thu, 6 Nov 2014 16:45:50 -0200 Subject: [PATCH] fedora-spec: added systemd post/postun/pre/preun sections 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 Signed-off-by: Ben Pfaff --- 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 67b7ca905..f90762d3c 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 -- 2.20.1