43 lines
1016 B
Bash
Executable File
43 lines
1016 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# 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'
|
|
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":1}\n'
|
|
exit 0
|
|
fi
|
|
|
|
emit "$format" 'OK - all healthchecks passed\n'
|
|
exit 0
|
|
}
|
|
|
|
main "$@"
|