[debian-edu-commits] [Git][debian-edu/debian-edu-config][personal/gber/fix-debian-edu-restart-services] Add systemd support to debian-edu-restart-services

Guido Berhörster (@gber) gitlab at salsa.debian.org
Thu Aug 3 09:43:46 BST 2023



Guido Berhörster pushed to branch personal/gber/fix-debian-edu-restart-services at Debian Edu / debian-edu-config


Commits:
a5dc5093 by Guido Berhoerster at 2023-08-03T10:43:24+02:00
Add systemd support to debian-edu-restart-services

This uses a list of service units which was compiled on a main server + ltsp
installation. Uses stop and start to force restart reverse-dependencies. It
also makes sure that drop in files are recognized. Closes: #1042940

- - - - -


1 changed file:

- sbin/debian-edu-restart-services


Changes:

=====================================
sbin/debian-edu-restart-services
=====================================
@@ -5,63 +5,116 @@
 
 set -e 
 
-echo "info: Stopping services in sequence."
-for ALL in /etc/rc1.d/K* ; do 
-  if [ -h $ALL ] ; then 
-    SERVICE=$(basename $(readlink $ALL))
-  else
-    SERVICE=$(basename $ALL)
-  fi
-  echo "info: Stopping $SERVICE"
-  $ALL stop || /bin/true
-done
+sysvinit_restart_services () {
+    echo "info: Stopping services in sequence."
+    for ALL in /etc/rc1.d/K* ; do 
+      if [ -h $ALL ] ; then 
+        SERVICE=$(basename $(readlink $ALL))
+      else
+        SERVICE=$(basename $ALL)
+      fi
+      echo "info: Stopping $SERVICE"
+      $ALL stop || /bin/true
+    done
 
-for service in \
-    slapd \
-    rpcbind \
-    apache \
-    ;
-    do
-  if [ "$(pidof $service)" ] ; then
-      echo "info: '$service' still running, sending HUP."
-      pkill $service || /bin/true
-  fi
-done
+    for service in \
+        slapd \
+        rpcbind \
+        apache \
+        ;
+        do
+      if [ "$(pidof $service)" ] ; then
+          echo "info: '$service' still running, sending HUP."
+          pkill $service || /bin/true
+      fi
+    done
 
-echo "info: Checking what's still running"
-ps aux | while read LINE ; do 
-  echo "info: $LINE"
-done
+    echo "info: Checking what's still running"
+    ps aux | while read LINE ; do 
+      echo "info: $LINE"
+    done
 
-for service in \
-    slapd \
-    rpcbind \
-    apache \
-    ;
-    do
-  if [ "$(pidof $service)" ] ; then
-      echo "info: '$service' still running, sending KILL."
-      pkill -9 $service || /bin/true
-  fi
-done
+    for service in \
+        slapd \
+        rpcbind \
+        apache \
+        ;
+        do
+      if [ "$(pidof $service)" ] ; then
+          echo "info: '$service' still running, sending KILL."
+          pkill -9 $service || /bin/true
+      fi
+    done
+
+    echo "info: Checking what's still running"
+    ps aux | while read LINE ; do 
+      echo "info: $LINE"
+    done
+
+    echo "Info: Restarting networking"
+    /etc/init.d/networking restart || /bin/true
 
-echo "info: Checking what's still running"
-ps aux | while read LINE ; do 
-  echo "info: $LINE"
-done
+    echo "info: Starting services in sequence."
+    for ALL in /etc/rc2.d/S* ; do 
+      if [ -h $ALL ] ; then 
+        SERVICE=$(basename $(readlink $ALL))
+      else
+        SERVICE=$(basename $ALL)
+      fi
+      echo "info: Starting $SERVICE"
+      $ALL start || /bin/true
+    done
+}
 
-echo "Info: Restarting networking"
-/etc/init.d/networking restart || /bin/true
+systemd_restart_services () {
+    systemctl daemon-reload
+
+    systemctl restart networking.service
+
+    for service in \
+        apache2.service \
+        cups.service \
+        dovecot.service \
+        exim4.service \
+        icinga2.service \
+        inetd.service \
+        isc-dhcp-server.service \
+        krb5-admin-server.service \
+        krb5-kdc.service \
+        ltsp.service \
+        mariadb.service \
+        munin-node.service \
+        munin.service \
+        nagios-nrpe-server.service \
+        named.service \
+        nfs-server.service \
+        nmbd.service \
+        nscd.service \
+        nslcd.service \
+        ntpsec.service \
+        rsyslog.service \
+        sitesummary-client.service \
+        slapd.service \
+        smbd.service \
+        squid.service \
+        sudo-ldap.service \
+        tftpd-hpa.service \
+        x2goserver.service \
+        xrdp.service \
+        xrdp-sesman.service
+    do
+        if systemctl is-active --quiet $service; then
+            active="$active $service"
+        fi
+    done
+    systemctl stop $active || true
+    systemctl start $active
+}
 
-echo "info: Starting services in sequence."
-for ALL in /etc/rc2.d/S* ; do 
-  if [ -h $ALL ] ; then 
-    SERVICE=$(basename $(readlink $ALL))
-  else
-    SERVICE=$(basename $ALL)
-  fi
-  echo "info: Starting $SERVICE"
-  $ALL start || /bin/true
-done
+if [ -e /run/systemd/system/ ]; then
+    systemd_restart_services
+else
+    sysvinit_restart_services
+fi
 
 exit 0



View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/a5dc509324c97e420f7fd0e47083b3bce74716fa

-- 
View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/commit/a5dc509324c97e420f7fd0e47083b3bce74716fa
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20230803/a07e9a45/attachment-0001.htm>


More information about the debian-edu-commits mailing list