From a09d8f42e238a384f68bc3aa2dfa37748e22d57a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 3 Apr 2025 19:46:26 +0200 Subject: [PATCH] MT#62508 services: Remove any systemd broken service symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before running «systemctl preset-all» we remove all .wants dependency directories, because otherwise the preset-all command leaves obsolete files behind. But «systemctl preset-all» fails if there's any broken service symlink around, which means we end up with no dependency information whatsoever implying a severely broken system, that in addition is then unbootable. Remove any such broken symlinks before calling «systemctl preset-all». Change-Id: I58fe650cb04ddb140922563169a7fedb09a8ceac --- scripts/services | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/services b/scripts/services index 042b2e58..6673d1af 100755 --- a/scripts/services +++ b/scripts/services @@ -145,6 +145,10 @@ systemd_daemon_reload_preset() { log_debug "Running: systemctl daemon-reload 2>&1 || true" systemctl daemon-reload 2>&1 || true + log_debug "Removing any broken systemd service symlink" + find -L /etc/systemd/system -type l \ + | xargs -r rm + log_debug "systemd needs preset-all to enable/disable services (to start them on boot)" log_debug "Running: rm -rf /etc/systemd/system/*.wants/ || true" rm -rf /etc/systemd/system/*.wants/ || true