Skip to content

Commit c7b0bc4

Browse files
authored
add an option to pass the binary from cli
passing binary from cli allow shell to autocomplete the path of the binary, not the read . ( that's a things that frustrated me the first time, I doesn't know the exact path to my script )
1 parent aa0fa46 commit c7b0bc4

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

scripts/install.sh

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,40 @@ SYSTEMD_PATH_FILE="/etc/systemd/system/cs-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+
shift
31+
;;
32+
-h|--help)
33+
usage
34+
exit 0
35+
;;
36+
*) # unknown option
37+
echo "Unknown argument ${key}."
38+
usage
39+
exit 1
40+
;;
41+
esac
42+
done
43+
1044
gen_apikey() {
1145
which cscli > /dev/null
1246
if [[ $? == 0 ]]; then
@@ -48,7 +82,9 @@ fi
4882
echo "Installing cs-custom-bouncer"
4983
install_custom_bouncer
5084
gen_apikey
51-
gen_binary_path
85+
if ! [ -f "$BINARY_PATH" ]; then
86+
gen_binary_path
87+
fi
5288
gen_config_file
5389
systemctl enable cs-custom-bouncer.service
5490
if ! [ -f "$BINARY_PATH" ]; then

0 commit comments

Comments
 (0)