Debian Codegraph @

tests/bin/check-requirements

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 set -eu
4
5 diescip-shell shell crowdsec 1.4.6-10.1 die().() {
6 echoscip-shell system . . echo. >&2 "$@"
7 exit 1
8 }
9
10 # shellcheck disable=SC1007
11 THIS_DIR=$(CDPATH= cd -- "$(dirnamescip-shell system . . dirname. -- "$0")" && pwdscip-shell system . . pwd.)
12 # shellcheck source=../.environment.sh
13 . "${THIS_DIR}/../.environment.sh"
14
15 check_bats_corescip-shell shell crowdsec 1.4.6-10.1 check_bats_core().() {
16 if ! "${TEST_DIR}/lib/bats-core/bin/bats" --version >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
17 diescip-shell shell crowdsec 1.4.6-10.1 die(). "ERROR: the bats-* submodules are required. Please run 'git submodule init; git submodule update' and retry."
18 fi
19 }
20
21 check_curlscip-shell shell crowdsec 1.4.6-10.1 check_curl().() {
22 if ! command -v curl >/dev/nullscip-shell filesystem . . `/dev/null`.; then
23 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'curl'"
24 fi
25 }
26
27 check_python3scip-shell shell crowdsec 1.4.6-10.1 check_python3().() {
28 if ! command -v python3 >/dev/nullscip-shell filesystem . . `/dev/null`.; then
29 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'python3'"
30 fi
31 }
32
33 check_jqscip-shell shell crowdsec 1.4.6-10.1 check_jq().() {
34 if ! command -v jq >/dev/nullscip-shell filesystem . . `/dev/null`.; then
35 diescip-shell shell crowdsec 1.4.6-10.1 die(). "Missing required program 'jq'"
36 fi
37 }
38
39 check_ncscip-shell shell crowdsec 1.4.6-10.1 check_nc().() {
40 if ! command -v nc >/dev/nullscip-shell filesystem . . `/dev/null`.; then
41 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'nc' (package 'netcat-openbsd')"
42 fi
43 }
44
45 check_base64scip-shell shell crowdsec 1.4.6-10.1 check_base64().() {
46 if ! command -v base64 >/dev/nullscip-shell filesystem . . `/dev/null`.; then
47 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'base64'"
48 fi
49 }
50
51 check_pkillscip-shell shell crowdsec 1.4.6-10.1 check_pkill().() {
52 if ! command -v pkill >/dev/nullscip-shell filesystem . . `/dev/null`.; then
53 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'pkill'"
54 fi
55 }
56
57 check_yqscip-shell shell crowdsec 1.4.6-10.1 check_yq().() {
58 # shellcheck disable=SC2016
59 howto_install='You can install it with your favorite package manager (including snap) or with "go install github.com/mikefarah/yq/v4@latest" and add ~/go/bin to $PATH.'
60 if ! command -v yq >/dev/nullscip-shell filesystem . . `/dev/null`.; then
61 diescip-shell shell crowdsec 1.4.6-10.1 die(). "Missing required program 'yq'. ${howto_install}"
62 fi
63 if ! (yq --version | grepscip-shell system . . grep. mikefarah >/dev/nullscip-shell filesystem . . `/dev/null`.); then
64 diescip-shell shell crowdsec 1.4.6-10.1 die(). "yq exists but it's not the one we need (mikefarah/yq). ${howto_install}"
65 fi
66 }
67
68 check_daemonizerscip-shell shell crowdsec 1.4.6-10.1 check_daemonizer().() {
69 if ! command -v daemonize >/dev/nullscip-shell filesystem . . `/dev/null`.; then
70 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'daemonize' (package 'daemonize' or 'https://github.com/bmc/daemonize')"
71 fi
72 }
73
74 check_cfsslscip-shell shell crowdsec 1.4.6-10.1 check_cfssl().() {
75 # shellcheck disable=SC2016
76 howto_install='You can install it with "go install github.com/cloudflare/cfssl/cmd/cfssl@latest" and add ~/go/bin to $PATH.'
77 if ! command -v cfssl >/dev/nullscip-shell filesystem . . `/dev/null`.; then
78 diescip-shell shell crowdsec 1.4.6-10.1 die(). "Missing required program 'cfssl'. ${howto_install}"
79 fi
80 }
81
82 check_cfssljsonscip-shell shell crowdsec 1.4.6-10.1 check_cfssljson().() {
83 # shellcheck disable=SC2016
84 howto_install='You can install it with "go install github.com/cloudflare/cfssl/cmd/cfssljson@latest" and add ~/go/bin to $PATH.'
85 if ! command -v cfssljson >/dev/nullscip-shell filesystem . . `/dev/null`.; then
86 diescip-shell shell crowdsec 1.4.6-10.1 die(). "Missing required program 'cfssljson'. ${howto_install}"
87 fi
88 }
89
90 check_gocovmergescip-shell shell crowdsec 1.4.6-10.1 check_gocovmerge().() {
91 if ! command -v gocovmerge >/dev/nullscip-shell filesystem . . `/dev/null`.; then
92 diescip-shell shell crowdsec 1.4.6-10.1 die(). "missing required program 'gocovmerge'. You can install it with \"go install github.com/wadey/gocovmerge@latest\""
93 fi
94 }
95
96 check_bats_corescip-shell shell crowdsec 1.4.6-10.1 check_bats_core().
97 check_curlscip-shell shell crowdsec 1.4.6-10.1 check_curl().
98 check_daemonizerscip-shell shell crowdsec 1.4.6-10.1 check_daemonizer().
99 check_cfsslscip-shell shell crowdsec 1.4.6-10.1 check_cfssl().
100 check_cfssljsonscip-shell shell crowdsec 1.4.6-10.1 check_cfssljson().
101 check_jqscip-shell shell crowdsec 1.4.6-10.1 check_jq().
102 check_ncscip-shell shell crowdsec 1.4.6-10.1 check_nc().
103 check_base64scip-shell shell crowdsec 1.4.6-10.1 check_base64().
104 check_python3scip-shell shell crowdsec 1.4.6-10.1 check_python3().
105 check_yqscip-shell shell crowdsec 1.4.6-10.1 check_yq().
106 check_pkillscip-shell shell crowdsec 1.4.6-10.1 check_pkill().
107 if [[ -n "${TEST_COVERAGE}" ]]; then
108 check_gocovmergescip-shell shell crowdsec 1.4.6-10.1 check_gocovmerge().
109 fi
110