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