Skip to content

Commit 3595a61

Browse files
authored
Merge pull request crowdsecurity#10 from thib3113/patch-2
add an option to pass the binary from cli
2 parents e3724ac + 2020a60 commit 3595a61

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

scripts/install.sh

+38-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@ SYSTEMD_PATH_FILE="/etc/systemd/system/crowdsec-custom-bouncer.service"
77
API_KEY=""
88
BINARY_PATH=""
99

10+
usage() {
11+
echo "Usage: ./install.sh [options]"
12+
echo " -h|--help Display this help message."
13+
echo " -b|--binary <path> Specify the binary path"
14+
15+
exit 0
16+
}
17+
18+
while [[ $# -gt 0 ]]
19+
do
20+
key="${1}"
21+
case ${key} in
22+
-b|--binary)
23+
if ! [ -f "${2}" ]; then
24+
echo "${key} need a path"
25+
usage
26+
exit 1
27+
fi
28+
BINARY_PATH="$2"
29+
shift # past argument
30+
BINARY_PATH=$(readlink -f $BINARY_PATH)
31+
shift
32+
;;
33+
-h|--help)
34+
usage
35+
exit 0
36+
;;
37+
*) # unknown option
38+
echo "Unknown argument ${key}."
39+
usage
40+
exit 1
41+
;;
42+
esac
43+
done
44+
1045
gen_apikey() {
1146
which cscli > /dev/null
1247
if [[ $? == 0 ]]; then
@@ -48,7 +83,9 @@ fi
4883
echo "Installing crowdsec-custom-bouncer"
4984
install_custom_bouncer
5085
gen_apikey
51-
gen_binary_path
86+
if ! [ -f "$BINARY_PATH" ]; then
87+
gen_binary_path
88+
fi
5289
gen_config_file
5390
systemctl enable crowdsec-custom-bouncer.service
5491
if ! [ -f "$BINARY_PATH" ]; then

0 commit comments

Comments
 (0)