]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.spec.in: Standardize systemd preun and postun scripts
authorNathan Cutler <ncutler@suse.com>
Tue, 8 Sep 2015 08:09:35 +0000 (10:09 +0200)
committerNathan Cutler <ncutler@suse.com>
Tue, 6 Oct 2015 13:18:25 +0000 (15:18 +0200)
Currently, the main ceph package and the ceph-radosgw behave
differently on upgrade. This commit unifies their behavior
to the following:

On package removal, disable and stop all related systemd units.

On package upgrade, do nothing unless there is a file /etc/sysconfig/ceph
containing a parameter CEPH_AUTO_RESTART_ON_UPGRADE. If parameter is set
to "yes", restart the systemd units iff they are running.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
ceph.spec.in

index 1b28abcbfe03396468711c9b87789d43e2428ad9..1086e9d564b9be26301cae05f6dab1e92e8e7d50 100644 (file)
@@ -698,11 +698,7 @@ rm -rf $RPM_BUILD_ROOT
   %if 0%{?suse_version}
     %service_del_preun ceph.target
   %endif
-  # Need a special case here when removing the RPM to disable specific
-  # service instance, or stale symlinks will be left lying around in
-  # /etc/systemd/system.  May as well stop them too for completeness
-  # (although strictly service_del_preun would do that anyway by dint
-  # of stopping ceph.target)
+  # Disable and stop on removal.
   if [ $1 = 0 ] ; then
     SERVICE_LIST=$(systemctl | grep -E '^ceph-mon@|^ceph-create-keys@|^ceph-osd@|^ceph-mds@|^ceph-disk-'  | cut -d' ' -f1)
     if [ -n "$SERVICE_LIST" ]; then
@@ -723,6 +719,24 @@ rm -rf $RPM_BUILD_ROOT
 
 %postun
 /sbin/ldconfig
+%if 0%{?_with_systemd}
+  if [ $1 = 1 ] ; then
+    # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to
+    # "yes". In any case: if units are not running, do not touch them.
+    SYSCONF_CEPH=/etc/sysconfig/ceph
+    if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then
+      source $SYSCONF_CEPH
+    fi
+    if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then
+      SERVICE_LIST=$(systemctl | grep -E '^ceph-mon@|^ceph-create-keys@|^ceph-osd@|^ceph-mds@|^ceph-disk-'  | cut -d' ' -f1)
+      if [ -n "$SERVICE_LIST" ]; then
+        for SERVICE in $SERVICE_LIST; do
+          /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || :
+        done
+      fi
+    fi
+  fi
+%endif
 
 #################################################################################
 # files
@@ -963,24 +977,36 @@ fi
 
 %preun radosgw
 %if 0%{?_with_systemd}
-  SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@'  | cut -d' ' -f1)
-  if [ -n "$SERVICE_LIST" ]; then
-    for SERVICE in $SERVICE_LIST; do
-      /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || :
-      /usr/bin/systemctl stop $SERVICE > /dev/null 2>&1 || :
-    done
+  # Disable and stop on removal.
+  if [ $1 = 0 ] ; then
+    SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@'  | cut -d' ' -f1)
+    if [ -n "$SERVICE_LIST" ]; then
+      for SERVICE in $SERVICE_LIST; do
+        /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || :
+        /usr/bin/systemctl stop $SERVICE > /dev/null 2>&1 || :
+      done
+    fi
   fi
 %endif
 
 %postun radosgw
 /sbin/ldconfig
 %if 0%{?_with_systemd}
-  SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@'  | cut -d' ' -f1)
-  if [ -n "$SERVICE_LIST" ]; then
-    for SERVICE in $SERVICE_LIST; do
-      /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || :
-      /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || :
-    done
+  if [ $1 = 1 ] ; then
+    # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to
+    # "yes". In any case: if units are not running, do not touch them.
+    SYSCONF_CEPH=/etc/sysconfig/ceph
+    if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then
+      source $SYSCONF_CEPH
+    fi
+    if [ "X$CEPH_AUTO_RESTART_ON_UPGRADE" = "Xyes" ] ; then
+      SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@'  | cut -d' ' -f1)
+      if [ -n "$SERVICE_LIST" ]; then
+        for SERVICE in $SERVICE_LIST; do
+          /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || :
+        done
+      fi
+    fi
   fi
 %endif