1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-27 03:21:32 +03:00
systemd-stable/test/testsuite-16.units/extend-timeout.sh
Zbigniew Jędrzejewski-Szmek 22d3cfe54c tests: add spdx license header to test unit/link/network/conf files
Those are all consumed by our parser, so they all support comments.
I was considering whether they should have a license header at all,
but in the end I decided to add it because those files are often created
by copying parts of real unit files. And if the real ones have a license,
then those might as well. It's easier to add it than to make an exception.
2021-10-18 09:04:45 +02:00

64 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# sleep interval (seconds)
sleep_interval="${sleep_interval:-1}"
# extend_timeout_interval second(s)
extend_timeout_interval="${extend_timeout_interval:-1}"
# number of sleep_intervals before READY=1
start_intervals="${start_intervals:-10}"
# number of sleep_intervals before exiting
stop_intervals="${stop_intervals:-10}"
# run intervals, number of sleep_intervals to run
run_intervals="${run_intervals:-7}"
# We convert to usec
extend_timeout_interval=$((extend_timeout_interval * 1000000))
# shellcheck disable=SC2064
trap "{ touch /${SERVICE}.terminated; exit 1; }" SIGTERM SIGABRT
rm -f "/${SERVICE}".*
touch "/${SERVICE}.startfail"
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
while [[ $start_intervals -gt 0 ]]
do
sleep "$sleep_interval"
start_intervals=$((start_intervals - 1))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
done
systemd-notify --ready --status="Waiting for your request"
touch "/${SERVICE}.runtimefail"
rm "/${SERVICE}.startfail"
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
while [[ $run_intervals -gt 0 ]]
do
sleep "$sleep_interval"
run_intervals=$((run_intervals - 1))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
done
systemd-notify STOPPING=1
touch "/${SERVICE}.stopfail"
rm "/${SERVICE}.runtimefail"
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
while [[ $stop_intervals -gt 0 ]]
do
sleep "$sleep_interval"
stop_intervals=$((stop_intervals - 1))
systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
done
touch "/${SERVICE}.success"
rm "/${SERVICE}.stopfail"
exit 0