From 89fd54e83f2c17fb2afeea4e82b49d702178576b Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Thu, 6 Sep 2018 16:03:41 +0200 Subject: [PATCH] TT#44061 Always reload systemd daemon and preset all units Previously 'systemd daemon-reload' and 'systemctl preset-all' were executed only if changes detected in configs. Otherwise the early exit happened if no .service files were triggered: > DEBUG: No services file(s) reported - nothing to do. Move the code into the function systed_daemon_reload_preset and execute it on the top of the script. Also print info message informing users about reloaded systemd and newly preset units. It should provide better visibility here. Change-Id: I992af9fb274ea93a37b812a51cebcd7af5c54133 --- scripts/services | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/services b/scripts/services index 63d0351b..811acae4 100755 --- a/scripts/services +++ b/scripts/services @@ -97,6 +97,22 @@ execute() { ngcp-service queue-run } +systed_daemon_reload_preset() { + if [ -d "/run/systemd/system" ]; then + log_info "Reloading systemd daemon and preset all services" + + log_debug "systemd needs daemon-reload so the unit files loaded are in sync" + log_debug "Running: systemctl daemon-reload 2>&1 || true" + systemctl daemon-reload 2>&1 || true + + log_debug "systemd needs preset-all to enable/disabe services (to start them on boot)" + log_debug "Running: rm -rf /etc/systemd/system/*.wants/ || true" + rm -rf /etc/systemd/system/*.wants/ || true + log_debug "Running: systemctl preset-all 2>&1 || true" + systemctl preset-all 2>&1 || true + fi +} + # main script DRYRUN='false' @@ -109,6 +125,9 @@ elif [[ -n "${1:-}" ]] ; then fi log_debug "DRYRUN = $DRYRUN" +log_debug "systed_daemon_reload_preset function" +systed_daemon_reload_preset + TMPFILE="$(mktemp)" log_debug "TMPFILE = $TMPFILE" @@ -141,18 +160,6 @@ if ! [ -s "$TMPFILE" ] ; then exit 0 fi -if [ -d "/run/systemd/system" ]; then - log_debug "systemd needs daemon-reload so the unit files loaded are in sync" - log_debug "Running: systemctl daemon-reload 2>&1 || true" - systemctl daemon-reload 2>&1 || true - - log_debug "systemd needs preset-all to enable/disabe services (to start them on boot)" - log_debug "Running: rm -rf /etc/systemd/system/*.wants/ || true" - rm -rf /etc/systemd/system/*.wants/ || true - log_debug "Running: systemctl preset-all 2>&1 || true" - systemctl preset-all 2>&1 || true -fi - log_debug "normalize_files function" normalize_files