#!/bin/bash # # check if container services are running UNITS="/var/containers/systemd" FAILED="" check_service() { local service=$1 systemctl is-active --user --machine=container@ $service >/dev/null if [ $? -ne 0 ]; then FAILED="$FAILED $service" fi } check() { local type=$1 for i in $UNITS/$type/*.socket; do check_service $(basename $i) done for i in $UNITS/$type/*.container; do check_service $(basename $i .container).service done } check user check system if [ -z "$FAILED" ]; then echo "OK All services are running" exit 0 else echo "#" >&2 echo "# ERROR some services are not running:" >&2 echo "#" >&2 echo "# $FAILED" >&2 echo "#" >&2 exit 1 fi