File tree Expand file tree Collapse file tree 1 file changed +23
-18
lines changed Expand file tree Collapse file tree 1 file changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -4,28 +4,33 @@ systemctl daemon-reload
44
55START=0
66
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}
2028 fi
29+ else
30+ START=1
2131fi
2232
2333
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-
2934if [ ${START} -eq 0 ] ; then
3035 echo "no api key was generated"
3136fi
You can’t perform that action at this time.
0 commit comments