e0ab86b8f8
# Conflicts: # TASK.md # scripts/orchestra_e2e_healthcheck.sh
54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
readonly VERSION=1.0.0
|
|
readonly SUCCESS_MESSAGE='OK - all healthchecks passed'
|
|
readonly CHECKS=(script-runs)
|
|
|
|
# emit <format> <template> [args...]: the single output path.
|
|
# format: text or json print; none suppresses (--quiet). Explicit argument,
|
|
# never read from an enclosing variable.
|
|
emit() {
|
|
local format=$1
|
|
shift
|
|
[ "$format" = none ] || printf "$@"
|
|
}
|
|
|
|
main() {
|
|
local quiet=
|
|
local json=
|
|
for arg in "$@"; do
|
|
if [ "$arg" = --help ]; then
|
|
emit text 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
|
emit text 'Healthcheck script for Orchestra E2E tests.\n'
|
|
emit text 'Exits 0 with a success message if all checks pass.\n'
|
|
emit text ' --quiet Suppress the success message; still exits 0.\n'
|
|
emit text ' --list-checks Print the name of each check; exits 0.\n'
|
|
emit text 'Version: %s\n' "$VERSION"
|
|
exit 0
|
|
elif [ "$arg" = --list-checks ]; then
|
|
for name in "${CHECKS[@]}"; do
|
|
emit text '%s\n' "$name"
|
|
done
|
|
exit 0
|
|
elif [ "$arg" = --quiet ]; then
|
|
quiet=1
|
|
elif [ "$arg" = --json ]; then
|
|
json=1
|
|
fi
|
|
done
|
|
|
|
local format=text
|
|
[ -n "$quiet" ] && format=none
|
|
[ -n "$json" ] && format=json
|
|
|
|
if [ "$format" = json ]; then
|
|
emit "$format" '{"status":"ok","checks":%d}\n' "${#CHECKS[@]}"
|
|
exit 0
|
|
fi
|
|
|
|
emit "$format" '%s\n' "$SUCCESS_MESSAGE"
|
|
exit 0
|
|
}
|
|
|
|
main "$@"
|