73 lines
1.5 KiB
Bash
Executable file
73 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
die() {
|
|
echo >&2 "$@"
|
|
exit 1
|
|
}
|
|
|
|
# shellcheck disable=SC1007
|
|
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
# shellcheck source=../.environment.sh
|
|
. "${THIS_DIR}/../.environment.sh"
|
|
|
|
check_bats_core() {
|
|
if ! "${TEST_DIR}/lib/bats-core/bin/bats" --version >/dev/null 2>&1; then
|
|
die "ERROR: the bats-* submodules are required. Please run 'git submodule init; git submodule update' and retry."
|
|
fi
|
|
}
|
|
|
|
check_curl() {
|
|
if ! command -v curl >/dev/null; then
|
|
die "missing required program 'curl'"
|
|
fi
|
|
}
|
|
|
|
check_python3() {
|
|
if ! command -v python3 >/dev/null; then
|
|
die "missing required program 'python3'"
|
|
fi
|
|
}
|
|
|
|
check_jq() {
|
|
if ! command -v jq >/dev/null; then
|
|
die "Missing required program 'jq'"
|
|
fi
|
|
}
|
|
|
|
check_nc() {
|
|
if ! command -v nc >/dev/null; then
|
|
die "missing required program 'nc' (package 'netcat-openbsd')"
|
|
fi
|
|
}
|
|
|
|
check_base64() {
|
|
if ! command -v base64 >/dev/null; then
|
|
die "missing required program 'base64'"
|
|
fi
|
|
}
|
|
|
|
check_pkill() {
|
|
if ! command -v pkill >/dev/null; then
|
|
die "missing required program 'pkill'"
|
|
fi
|
|
}
|
|
|
|
check_daemonizer() {
|
|
if ! command -v daemonize >/dev/null; then
|
|
die "missing required program 'daemonize' (package 'daemonize' or 'https://github.com/bmc/daemonize')"
|
|
fi
|
|
}
|
|
|
|
echo "Checking requirements..."
|
|
|
|
check_bats_core
|
|
check_curl
|
|
check_daemonizer
|
|
check_jq
|
|
check_nc
|
|
check_base64
|
|
check_python3
|
|
check_pkill
|