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
'[{"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