File tree 1 file changed +23
-18
lines changed
1 file changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -4,28 +4,33 @@ systemctl daemon-reload
4
4
5
5
START=0
6
6
7
- dpkg -l crowdsec | grep -q ^ii >/dev/null
8
-
9
- if [ "$?" -eq "0" ] ; then
10
- START=1
11
- echo "cscli/crowdsec is present, generating API key"
12
- unique=`date +%s`
13
- API_KEY=`cscli -oraw bouncers add CustomBouncer-${unique}`
14
- if [ $? -eq 1 ] ; then
15
- echo "failed to create API token, service won't be started."
16
- START=0
17
- API_KEY="<API_KEY>"
18
- else
19
- echo "API Key : ${API_KEY}"
7
+ if [ "$1" = "configure" ] && [ "$2" = "" ]; then
8
+
9
+ type cscli
10
+
11
+ if [ "$?" -eq "0" ] ; then
12
+ START=1
13
+ echo "cscli/crowdsec is present, generating API key"
14
+ unique=`date +%s`
15
+ API_KEY=`cscli -oraw bouncers add CustomBouncer-${unique}`
16
+ if [ $? -eq 1 ] ; then
17
+ echo "failed to create API token, service won't be started."
18
+ START=0
19
+ API_KEY="<API_KEY>"
20
+ else
21
+ echo "API Key : ${API_KEY}"
22
+ fi
23
+
24
+ TMP=`mktemp -p /tmp/`
25
+ cp /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml ${TMP}
26
+ API_KEY=${API_KEY} envsubst < ${TMP} > /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml
27
+ rm ${TMP}
20
28
fi
29
+ else
30
+ START=1
21
31
fi
22
32
23
33
24
- TMP=`mktemp -p /tmp/`
25
- cp /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml ${TMP}
26
- API_KEY=${API_KEY} envsubst < ${TMP} > /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml
27
- rm ${TMP}
28
-
29
34
if [ ${START} -eq 0 ] ; then
30
35
echo "no api key was generated"
31
36
fi
You can’t perform that action at this time.
0 commit comments