1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
systemctl daemon-reload
START=0
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
if [ ${START} -eq 0 ] ; then
echo "no api key was generated"
fi
echo "please enter the binary path in '/etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml' and start the bouncer via 'sudo systemctl start crowdsec-custom-bouncer' "
|