From b9159521f4b92fdd7425e38452d77815fb05adbc Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Fri, 2 Oct 2015 10:37:04 +0200 Subject: [PATCH] ceph.spec.in: Do not always restart the daemons on removal There is no need to restart the daemons when removing ceph-selinux package if SELinux is not enabled. Fixes: #13061 Signed-off-by: Boris Ranto --- ceph.spec.in | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ceph.spec.in b/ceph.spec.in index 239a0fa7da09e..1a3a3993346e8 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1177,6 +1177,18 @@ exit 0 %postun selinux if [ $1 -eq 0 ]; then + # Remove the module + %{_sbindir}/semodule -n -r ceph + + # Reload the policy if SELinux is enabled + if %{_sbindir}/selinuxenabled ; then + %{_sbindir}/load_policy + else + # Do not relabel if SELinux is not enabled + exit 0 + fi + + # Check whether the daemons are running %if 0%{?_with_systemd} /usr/bin/systemctl status ceph.target > /dev/null 2>&1 %else @@ -1184,6 +1196,7 @@ if [ $1 -eq 0 ]; then %endif STATUS=$? + # Stop the daemons if they were running if test $STATUS -eq 0; then %if 0%{?_with_systemd} /usr/bin/systemctl stop ceph.target > /dev/null 2>&1 @@ -1192,12 +1205,10 @@ if [ $1 -eq 0 ]; then %endif fi - %{_sbindir}/semodule -n -r ceph - if %{_sbindir}/selinuxenabled ; then - %{_sbindir}/load_policy - %relabel_files - fi; + # Now, relabel the files + %relabel_files + # Start the daemons if they were running before if test $STATUS -eq 0; then %if 0%{?_with_systemd} /usr/bin/systemctl start ceph.target > /dev/null 2>&1 || : -- 2.39.5