enable less service restarts to avoid nn bug master
authorIan Kelling <iank@fsf.org>
Fri, 16 May 2025 04:08:34 +0000 (00:08 -0400)
committerIan Kelling <iank@fsf.org>
Fri, 16 May 2025 04:08:34 +0000 (00:08 -0400)
fai/config/distro-install-common/bash-misc-funcs

index af8a6affd17c5f4824b53334691e7a14d0c9b58b..60b35babed33356191c6204256170b208384a402 100644 (file)
@@ -26,7 +26,7 @@
 # updates $reload to true if file updated is in /etc/systemd/system
 #
 u() {
-  local tmp tmpdir dest="$1"
+  local tmp tmpdir dest="$1" ser
   local base="${dest##*/}"
   local dir="${dest%/*}"
   if [[ $dir != "$base" ]]; then
@@ -45,6 +45,15 @@ u() {
     if [[ $dest == /etc/systemd/system/* ]]; then
       # shellcheck disable=SC2034 # intentional
       reload=true
+      if declare -p modified_services &>/dev/null; then
+        ser=${dest#/etc/systemd/system/}
+        ser=${ser%%/*}
+        ser=%{ser%.d}
+        if [[ $ser == *.service || $ser == *.timer ]]; then
+          # shellcheck disable=SC2004 # seems false positive: this isnt arithmetic.
+          modified_services[$ser]=t
+        fi
+      fi
     fi
   fi
   rm -rf $tmpdir