1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2021-2022 Gerald Kerma <gandalf@gk2.net>
6 NAME
=crowdsec-firewall-bouncer
7 PROG
=/usr
/bin
/cs-firewall-bouncer
8 CONFIG
=/etc
/crowdsec
/bouncers
/crowdsec-firewall-bouncer.yaml
10 VARCONFIGDIR
=/var
/etc
/crowdsec
/bouncers
11 VARCONFIG
=/var
/etc
/crowdsec
/bouncers
/crowdsec-firewall-bouncer.yaml
15 procd_add_reload_trigger crowdsec-firewall-bouncer
21 which iptables
> /dev
/null
23 if [[ $?
!= 0 ]]; then
24 echo "iptables is not present"
33 if [[ $?
!= 0 ]]; then
34 echo "nftables is not present"
41 if [ "$nftables" = "true" -a "$iptables" = "true" ]; then
42 echo "Found nftables(default) and iptables..."
45 if [ "$FW_BACKEND" = "iptables" ]; then
46 which ipset
> /dev
/null
47 if [[ $?
!= 0 ]]; then
48 echo "ipset not found, install it !"
53 # Create tmp dir & permissions if needed
54 if [ ! -d "${VARCONFIGDIR}" ]; then
55 mkdir
-m 0755 -p "${VARCONFIGDIR}"
60 sed -i "s,^\(\s*mode\s*:\s*\).*\$,\1$BACKEND," $VARCONFIG
67 procd_set_param
command "$PROG" -c "$VARCONFIG"