2022-03-15 09:40:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo >&2 "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# shellcheck disable=SC1007
|
2022-10-04 13:58:10 +00:00
|
|
|
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
|
|
# shellcheck source=../.environment.sh
|
|
|
|
. "${THIS_DIR}/../.environment.sh"
|
2022-03-15 09:40:01 +00:00
|
|
|
|
|
|
|
check_bats_core() {
|
|
|
|
if ! "${TEST_DIR}/lib/bats-core/bin/bats" --version >/dev/null 2>&1; then
|
2022-10-04 13:58:10 +00:00
|
|
|
die "ERROR: the bats-* submodules are required. Please run 'git submodule init; git submodule update' and retry."
|
2022-03-15 09:40:01 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-07-07 14:11:27 +00:00
|
|
|
check_curl() {
|
|
|
|
if ! command -v curl >/dev/null; then
|
|
|
|
die "missing required program 'curl'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-15 09:40:01 +00:00
|
|
|
check_python3() {
|
|
|
|
if ! command -v python3 >/dev/null; then
|
|
|
|
die "missing required program 'python3'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-04-20 13:05:34 +00:00
|
|
|
check_jq() {
|
|
|
|
if ! command -v jq >/dev/null; then
|
|
|
|
die "Missing required program 'jq'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-15 09:40:01 +00:00
|
|
|
check_nc() {
|
|
|
|
if ! command -v nc >/dev/null; then
|
|
|
|
die "missing required program 'nc' (package 'netcat-openbsd')"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-06-22 08:00:51 +00:00
|
|
|
check_base64() {
|
|
|
|
if ! command -v base64 >/dev/null; then
|
|
|
|
die "missing required program 'base64'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-10-31 09:02:51 +00:00
|
|
|
check_pkill() {
|
|
|
|
if ! command -v pkill >/dev/null; then
|
|
|
|
die "missing required program 'pkill'"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-15 09:40:01 +00:00
|
|
|
check_daemonizer() {
|
2022-08-04 09:25:34 +00:00
|
|
|
if ! command -v daemonize >/dev/null; then
|
|
|
|
die "missing required program 'daemonize' (package 'daemonize' or 'https://github.com/bmc/daemonize')"
|
|
|
|
fi
|
2022-03-15 09:40:01 +00:00
|
|
|
}
|
|
|
|
|
2023-06-28 08:07:05 +00:00
|
|
|
echo "Checking requirements..."
|
2022-06-08 14:05:52 +00:00
|
|
|
|
2023-06-28 08:07:05 +00:00
|
|
|
GOBIN=${TEST_DIR}/tools
|
|
|
|
export GOBIN
|
|
|
|
go install github.com/mikefarah/yq/v4@latest
|
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
|
|
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
2022-06-08 14:05:52 +00:00
|
|
|
|
2022-03-15 09:40:01 +00:00
|
|
|
check_bats_core
|
2022-07-07 14:11:27 +00:00
|
|
|
check_curl
|
2022-04-20 13:05:34 +00:00
|
|
|
check_daemonizer
|
|
|
|
check_jq
|
2022-03-15 09:40:01 +00:00
|
|
|
check_nc
|
2022-06-22 08:00:51 +00:00
|
|
|
check_base64
|
2022-04-20 13:05:34 +00:00
|
|
|
check_python3
|
2022-10-31 09:02:51 +00:00
|
|
|
check_pkill
|