systemd: perform reload even in degraded state

This fixes #355, fixes #798, and fixes #909.
This commit is contained in:
Robert Helgesson 2019-11-17 21:16:28 +01:00
parent 9e716025b6
commit 9781f3766d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -242,15 +242,27 @@ in
'';
ensureRuntimeDir = "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}";
systemctl = "${ensureRuntimeDir} ${cfg.systemctlPath}";
in
''
if ${ensureRuntimeDir} ${cfg.systemctlPath} --quiet --user is-system-running 2> /dev/null; then
systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true)
if [[ $systemdStatus == 'running' || $systemdStatus == 'degraded' ]]; then
if [[ $systemdStatus == 'degraded' ]]; then
warnEcho "The user systemd session is degraded:"
systemctl --user --state=failed
warnEcho "Attempting to reload services anyway..."
fi
${ensureRuntimeDir} \
PATH=${dirOf cfg.systemctlPath}:$PATH \
${if cfg.startServices then autoReloadCmd else legacyReloadCmd}
else
echo "User systemd daemon not running. Skipping reload."
fi
unset systemdStatus
''
);
})