Skip to content

Commit

Permalink
fedora-spec: added systemd post/postun/pre/preun sections
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
fleitner authored and blp committed Nov 6, 2014
1 parent c846a5b commit 0447019
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions rhel/openvswitch-fedora.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0447019

Please sign in to comment.