Skip to content

Commit 1855bcb

Browse files
authored
Merge pull request crowdsecurity#18 from crowdsecurity/dash_dance
fix pkg upgrade
2 parents 700c192 + 495c994 commit 1855bcb

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

debian/postinst

+23-18
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,33 @@ systemctl daemon-reload
44

55
START=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
2131
fi
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-
2934
if [ ${START} -eq 0 ] ; then
3035
echo "no api key was generated"
3136
fi

0 commit comments

Comments
 (0)