Fix systemd

This commit is contained in:
Alexander Schäferdiek 2019-01-25 19:59:38 +01:00
parent 0ad9690aa9
commit fde200fec8

View file

@ -74,21 +74,18 @@ done < "$SYSTEMD_CHECK_LIST_FILE"
function checkService() { function checkService() {
local SERVICE=$1; local SERVICE=$1;
local MESSAGE="$SERVICE is not running for user $SYSTEMD_CHECK_USER"; local MESSAGE="$SERVICE is not running for user $SYSTEMD_CHECK_USER";
local ROOT_COMMAND="systemctl is-active --quiet $SERVICE";
local USER_COMMAND="systemctl --user is-active --quiet $SERVICE";
local RESULT=1; local RESULT=1;
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then
local USER_COMMAND="systemctl --user is-active --quiet $SERVICE"; if [ $($USER_COMMAND) ]; then
RESULT=$($USER_COMMAND);
if [ -z "$RESULT" ]; then
RESULT=0; RESULT=0;
fi fi
else else
local ROOT_COMMAND="systemctl is-active --quiet $SERVICE"; if [ $($ROOT_COMMAND) ] || [ $($USER_COMMAND) ]; then
local USER_COMMAND="systemctl --user is-active --quiet $SERVICE";
local RESULT_ROOT_COMMAND=$($ROOT_COMMAND);
local RESULT_USER_COMMAND=$($USER_COMMAND);
if [ -z "$RESULT_ROOT_COMMAND" ] || [ -z "$RESULT_USER_COMMAND" ]; then
RESULT=0; RESULT=0;
fi fi
fi fi