X-Git-Url: https://code.delx.au/monosys/blobdiff_plain/59185ada1235549e0b345413adc80f8d6648225b..dec9bbdffee0e781fac53cf40409351280838c15:/healthcheck/systemd-user-units diff --git a/healthcheck/systemd-user-units b/healthcheck/systemd-user-units index ddc1551..4322734 100755 --- a/healthcheck/systemd-user-units +++ b/healthcheck/systemd-user-units @@ -1,9 +1,34 @@ #!/bin/bash -if systemctl --user is-system-running > /dev/null; then - exit 0 -fi +users="$(systemctl list-units | \ + sed -nE 's/.*user@([0-9]+)\.service .*loaded active running.*/\1/p' | \ + xargs -n1 id -un)" -echo -e "# systemctl --user --failed" -systemctl --user --failed -exit 1 +error=0 +for user in $users; do + homedir="$(getent passwd "$user"|cut -d: -f6)" + for timer in "$homedir"/.config/systemd/user/*.timer; do + if ! [ -f "$timer" ]; then + continue + fi + timerunit="$(basename "$timer")" + if ! systemctl --user -M"$user@" is-enabled "$timerunit" > /dev/null; then + echo "disabled timer $timer" + error=1 + fi + if ! systemctl --user -M"$user@" is-active "$timerunit" > /dev/null; then + echo "inactive timer $timer" + error=1 + fi + done + + if systemctl --user -M "$user@" is-system-running > /dev/null; then + continue + fi + + echo -e "# systemctl --user -M "$user@" --failed" + systemctl --user -M "$user@" --failed + error=1 +done + +exit "$error"