packages/net/crowdsec-firewall-bouncer/files/crowdsec-firewall-bouncer.defaults
Kerma Gérald b4f48b5c23 crowdsec-firewall-bouncer: update to 0.0.21
Update crowdsec-firewall-bouncer to latest upstream release version 0.0.21

Makefile rework
- use tagged version for download

Fixes
- set API_KEY in firewall bouncer config file

Signed-off-by: Kerma Gérald <gandalf@gk2.net>
2022-01-09 13:44:20 -08:00

23 lines
781 B
Bash

#!/bin/sh
CONFIG=/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
## Gen&ConfigApiKey
if grep -q "{API_KEY}" "$CONFIG"; then
SUFFIX=`tr -dc A-Za-z0-9 </dev/urandom | head -c 8`
API_KEY=`/usr/bin/cscli bouncers add crowdsec-firewall-bouncer-${SUFFIX} -o raw`
sed -i "s,^\(\s*api_key\s*:\s*\).*\$,\1$API_KEY," $CONFIG
else
echo API key already registered...
fi
# unfortunately, UCI doesn't provide a nice way to add an anonymous section only if it doesn't already exist
if ! uci show firewall | grep -q firewall.cs; then
name="$(uci add firewall include)"
uci set "firewall.${name}.path=/etc/firewall.cs"
uci set "firewall.${name}.enabled=1"
uci set "firewall.${name}.reload=1"
echo -e "Adding the following UCI config:\n $(uci changes)"
uci commit
fi
exit 0