mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
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 <fbl@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
committed by
Ben Pfaff
parent
c846a5b2b0
commit
0447019df7
@@ -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
|
||||
|
Reference in New Issue
Block a user