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
changes/69/23269/2
Alexander Lutay 8 years ago
parent e72faea77b
commit 89fd54e83f

@ -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

Loading…
Cancel
Save