Skip to content

Commit aa0fa46

Browse files
authored
Merge pull request crowdsecurity#4 from crowdsecurity/installer_imp
improve installer :
2 parents 35e9802 + 66f642f commit aa0fa46

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

scripts/install.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ API_KEY=""
88
BINARY_PATH=""
99

1010
gen_apikey() {
11-
SUFFIX=`tr -dc A-Za-z0-9 </dev/urandom | head -c 8`
12-
API_KEY=`cscli bouncers add cs-custom-bouncer-${SUFFIX} -o raw`
11+
which cscli > /dev/null
12+
if [[ $? == 0 ]]; then
13+
echo "cscli found, generating bouncer api key."
14+
SUFFIX=`tr -dc A-Za-z0-9 </dev/urandom | head -c 8`
15+
API_KEY=`cscli bouncers add cs-custom-bouncer-${SUFFIX} -o raw`
16+
READY="yes"
17+
else
18+
echo "cscli not found, you will need to generate api key."
19+
READY="no"
20+
fi
1321
}
1422

1523
gen_binary_path() {
@@ -34,7 +42,7 @@ gen_config_file() {
3442

3543

3644
if ! [ $(id -u) = 0 ]; then
37-
log_err "Please run the install script as root or with sudo"
45+
echo "Please run the install script as root or with sudo"
3846
exit 1
3947
fi
4048
echo "Installing cs-custom-bouncer"
@@ -48,5 +56,11 @@ if ! [ -f "$BINARY_PATH" ]; then
4856
echo "Please edit ${CONFIG_DIR}cs-custom-bouncer.yaml with a real binary path and run 'sudo systemctl start cs-custom-bouncer'."
4957
exit 1
5058
fi
51-
systemctl start cs-custom-bouncer.service
59+
60+
if [ "$READY" = "yes" ]; then
61+
systemctl start cs-custom-bouncer.service
62+
else
63+
echo "service not started. You need to get an API key and configure it in ${CONFIG_DIR}cs-firewall-bouncer.yaml"
64+
fi
65+
5266
echo "cs-custom-bouncer service has been installed!"

0 commit comments

Comments
 (0)