Skip to content

Commit

Permalink
Merge pull request crowdsecurity#18 from crowdsecurity/dash_dance
Browse files Browse the repository at this point in the history
fix pkg upgrade
  • Loading branch information
buixor authored Jul 2, 2021
2 parents 700c192 + 495c994 commit 1855bcb
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,33 @@ systemctl daemon-reload

START=0

dpkg -l crowdsec | grep -q ^ii >/dev/null

if [ "$?" -eq "0" ] ; then
START=1
echo "cscli/crowdsec is present, generating API key"
unique=`date +%s`
API_KEY=`cscli -oraw bouncers add CustomBouncer-${unique}`
if [ $? -eq 1 ] ; then
echo "failed to create API token, service won't be started."
START=0
API_KEY="<API_KEY>"
else
echo "API Key : ${API_KEY}"
if [ "$1" = "configure" ] && [ "$2" = "" ]; then

type cscli

if [ "$?" -eq "0" ] ; then
START=1
echo "cscli/crowdsec is present, generating API key"
unique=`date +%s`
API_KEY=`cscli -oraw bouncers add CustomBouncer-${unique}`
if [ $? -eq 1 ] ; then
echo "failed to create API token, service won't be started."
START=0
API_KEY="<API_KEY>"
else
echo "API Key : ${API_KEY}"
fi

TMP=`mktemp -p /tmp/`
cp /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml ${TMP}
API_KEY=${API_KEY} envsubst < ${TMP} > /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml
rm ${TMP}
fi
else
START=1
fi


TMP=`mktemp -p /tmp/`
cp /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml ${TMP}
API_KEY=${API_KEY} envsubst < ${TMP} > /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml
rm ${TMP}

if [ ${START} -eq 0 ] ; then
echo "no api key was generated"
fi
Expand Down

0 comments on commit 1855bcb

Please sign in to comment.