This commit is contained in:
hl committed 2024-11-18 05:40:24 +08:00
1 parent 10f9b2f4f9
commit d3b6f75599
6 files changed
+96 -77

No files matched your search

+13 -13
View File
@@ -4,19 +4,19 @@ set -e
OS_ARCH=$(dpkg --print-architecture) || (echo "Not Debian Based Distro" && exit 1)
OS_CODE=$(source /etc/os-release && echo "$VERSION_CODENAME")
SCRIPT=$(readlink -f "$0")
AWD=$(dirname "$SCRIPT")
main(){
echo "deb https://packagecloud.io/crowdsec/crowdsec/debian/ $OS_CODE main" | \
tee /etc/apt/sources.list.d/crowdsec_crowdsec.list
curl -fsSL "https://packagecloud.io/crowdsec/crowdsec/gpgkey" | \
gpg --dearmor | tee /etc/apt/trusted.gpg.d/crowdsec_crowdsec-archive-keyring.gpg > /dev/null
command="nala"
command -v $command &>/dev/null || command="apt"
$command update
$command install -y crowdsec crowdsec-firewall-bouncer-iptables
echo "crowdsec crowdsec-firewall-bouncer-iptables" | $AWD/install.sh
}
config(){
setup(){
echo -e "db_config:
use_wal: true" | tee /etc/crowdsec/config.yaml.local
@@ -36,7 +36,7 @@ whitelist:
# - "'foo.com' in evt.Meta.source_ip.reverse"
" | tee /etc/crowdsec/parsers/s02-enrich/custom-whitelists.yaml
sed -i -r "s/# - DOCKER-USER/ - DOCKER-USER/g" /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
sed -i -r "s/.*DOCKER-USER.*/ - DOCKER-USER/g" /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
systemctl reload crowdsec
}
@@ -44,14 +44,14 @@ whitelist:
usage(){
echo "Usage: $0 [OPTIONS]";
echo "OPTIONS:";
echo " -i install only";
echo " -s skip setup";
}
INSTALL_ONLY=0;
NO_SETUP=false;
while getopts ":i" OPT; do
case $OPT in
i)
INSTALL_ONLY=1;
s)
NO_SETUP=true;
;;
?)
echo "Invalid Option: -$OPTARG";
@@ -60,7 +60,7 @@ while getopts ":i" OPT; do
esac;
done;
main;
if [ $INSTALL_ONLY -eq 0 ]; then
config;
main
if ! $NO_SETUP; then
setup
fi;