github.com/crowdsecurity/crowdsec@v1.6.1/test/bin/check-requirements (about) 1 #!/usr/bin/env bash 2 3 set -eu 4 5 die() { 6 echo >&2 "$@" 7 exit 1 8 } 9 10 # shellcheck disable=SC1007 11 THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) 12 # shellcheck source=../.environment.sh 13 . "${THIS_DIR}/../.environment.sh" 14 15 check_bats_core() { 16 if ! "${TEST_DIR}/lib/bats-core/bin/bats" --version >/dev/null 2>&1; then 17 die "ERROR: the bats-* submodules are required. Please run 'git submodule init; git submodule update' and retry." 18 fi 19 } 20 21 check_curl() { 22 if ! command -v curl >/dev/null; then 23 die "missing required program 'curl'" 24 fi 25 } 26 27 check_python3() { 28 if ! command -v python3 >/dev/null; then 29 die "missing required program 'python3'" 30 fi 31 } 32 33 check_jq() { 34 if ! command -v jq >/dev/null; then 35 die "Missing required program 'jq'" 36 fi 37 } 38 39 check_base64() { 40 if ! command -v base64 >/dev/null; then 41 die "missing required program 'base64'" 42 fi 43 } 44 45 check_pkill() { 46 if ! command -v pkill >/dev/null; then 47 die "missing required program 'pkill'" 48 fi 49 } 50 51 check_daemonizer() { 52 if ! command -v daemonize >/dev/null; then 53 die "missing required program 'daemonize' (package 'daemonize' or 'https://github.com/bmc/daemonize')" 54 fi 55 } 56 57 echo "Checking requirements..." 58 59 check_bats_core 60 check_curl 61 check_daemonizer 62 check_jq 63 check_base64 64 check_python3 65 check_pkill