Files
pleno-vue/scripts/ci/with-systemd-inhibit.sh

29 lines
765 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [[ "$#" -eq 0 ]]; then
echo "Usage: $0 <command> [args...]" >&2
exit 64
fi
reason="${SYSTEMD_INHIBIT_REASON:-GitHub Actions frontend E2E job is running}"
can_use_systemd_inhibit() {
if ! command -v systemd-inhibit >/dev/null 2>&1; then
return 1
fi
if command -v timeout >/dev/null 2>&1; then
timeout 10s systemd-inhibit --what=sleep:shutdown --mode=block --who=frontend-ci --why="frontend-ci probe" true >/dev/null 2>&1
return
fi
systemd-inhibit --what=sleep:shutdown --mode=block --who=frontend-ci --why="frontend-ci probe" true >/dev/null 2>&1
}
if can_use_systemd_inhibit; then
exec systemd-inhibit --what=sleep:shutdown --mode=block --who=frontend-ci --why="$reason" "$@"
fi
exec "$@"