From: Boris Ranto Date: Wed, 26 Aug 2015 11:53:38 +0000 (+0200) Subject: ceph.spec.in: Restart services only if they are running X-Git-Tag: v9.1.0~295^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c318129ba1889942341d26d3614c6ab2a794faba;p=ceph.git ceph.spec.in: Restart services only if they are running Signed-off-by: Boris Ranto --- diff --git a/ceph.spec.in b/ceph.spec.in index 0dd64221ba0..dfae17854d3 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1119,10 +1119,19 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1 %post selinux %if 0%{?_with_systemd} - /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 || : + /usr/bin/systemctl status ceph.target > /dev/null 2>&1 %else - /sbin/service ceph stop >/dev/null 2>&1 || : + /sbin/service ceph status >/dev/null 2>&1 %endif +STATUS=$? + +if test $STATUS -eq 0; then +%if 0%{?_with_systemd} + /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 +%else + /sbin/service ceph stop >/dev/null 2>&1 +%endif +fi OLD_POLVER=$(%{_sbindir}/semodule -l | grep -P '^ceph[\t ]' | awk '{print $2}') %{_sbindir}/semodule -n -i %{_datadir}/selinux/packages/ceph.pp @@ -1134,34 +1143,51 @@ if %{_sbindir}/selinuxenabled; then fi fi +# Start iff it was started before +if test $STATUS -eq 0; then %if 0%{?_with_systemd} /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : %else /sbin/service ceph start >/dev/null 2>&1 || : %endif +fi + exit 0 %postun selinux if [ $1 -eq 0 ]; then %if 0%{?_with_systemd} - /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 || : + /usr/bin/systemctl status ceph.target > /dev/null 2>&1 %else - /sbin/service ceph stop >/dev/null 2>&1 || : + /sbin/service ceph status >/dev/null 2>&1 %endif + STATUS=$? + + if test $STATUS -eq 0; then + %if 0%{?_with_systemd} + /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 + %else + /sbin/service ceph stop >/dev/null 2>&1 + %endif + fi + %{_sbindir}/semodule -n -r ceph if %{_sbindir}/selinuxenabled ; then %{_sbindir}/load_policy %relabel_files fi; + + if test $STATUS -eq 0; then %if 0%{?_with_systemd} /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : %else /sbin/service ceph start >/dev/null 2>&1 || : %endif -fi; + fi +fi exit 0 -%endif +%endif # with selinux ################################################################################# %if 0%{with libs_compat}