1#!/usr/bin/env bash 2# SPDX-License-Identifier: LGPL-2.1-or-later 3set -eux 4set -o pipefail 5 6systemctl --no-block start fail-on-restart.service 7active_state=$(systemctl show --value --property ActiveState fail-on-restart.service) 8while [[ "$active_state" == "activating" || "$active_state" =~ ^(in)?active$ ]]; do 9 sleep .5 10 active_state=$(systemctl show --value --property ActiveState fail-on-restart.service) 11done 12systemctl is-failed fail-on-restart.service || exit 1 13[[ "$(systemctl show --value --property NRestarts fail-on-restart.service)" -le 3 ]] || exit 1 14touch /testok 15