Bundle bouncer at build time, add versioning, update docs

This commit is contained in:
thespad
2024-09-11 18:23:53 +01:00
parent df09bd2160
commit 9f1f5909ea
4 changed files with 76 additions and 42 deletions
@@ -5,12 +5,6 @@ CONFIG_PATH="/config/crowdsec/"
LIB_PATH="/usr/local/lua/crowdsec/"
DATA_PATH="/var/lib/crowdsec/lua/"
if [[ ${DOCKER_MODS_DEBUG_CURL,,} = "true" ]]; then
CURL_NOISE_LEVEL="-v"
else
CURL_NOISE_LEVEL="--silent"
fi
echo "**** Configuring CrowdSec nginx Bouncer ****"
# If API keys are missing, disable mod and exit
@@ -28,29 +22,11 @@ echo "\
lua-sec \
nginx-mod-http-lua" >> /mod-repo-packages-to-install.list
# Download nginx bouncer
if [[ -z ${CROWDSEC_VERSION+x} ]]; then \
CROWDSEC_VERSION=$(curl -s "https://api.github.com/repos/crowdsecurity/cs-nginx-bouncer/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]');
fi
if [[ -z ${CROWDSEC_VERSION+x} ]]; then \
echo "**** Could not fetch current bouncer version from Github ****"
exit 1
fi
curl "${CURL_NOISE_LEVEL}" -Lo \
/tmp/crowdsec.tar.gz -L \
"https://github.com/crowdsecurity/cs-nginx-bouncer/releases/download/${CROWDSEC_VERSION}/crowdsec-nginx-bouncer.tgz"
# Extract nginx bouncer
mkdir -p /tmp/crowdsec
if ! tar -tzf /tmp/crowdsec.tar.gz >/dev/null 2>&1; then
echo "**** Invalid tarball, could not download crowdsec bouncer ****"
exit 1
fi
tar xf \
/tmp/crowdsec.tar.gz -C \
/crowdsec-nginx-bouncer.tgz -C \
/tmp/crowdsec --strip-components=1
mkdir -p "${CONFIG_PATH}"
@@ -97,20 +73,35 @@ if ! grep -q '[^#]include /etc/nginx/http.d/\*.conf;' '/config/nginx/nginx.conf'
else
# Warn about missing http.d include
echo "
********************************************************************
* Warning: Your nginx.conf is missing required settings *
* Please add: *
* include /etc/nginx/http.d/*.conf; *
* to the http{} block and restart the container. *
* *
* The CrowdSec bouncer will not function until this is done. *
********************************************************************"
┌──────────────────────────────────────────────────────────────────┐
Warning: Your nginx.conf is missing required settings
Please add:
include /etc/nginx/http.d/*.conf;
to the http{} block and restart the container.
│ │
The CrowdSec bouncer will not function until this is done.
└──────────────────────────────────────────────────────────────────┘
"
fi
fi
# Clean up
rm -rf \
/tmp/crowdsec \
/tmp/crowdsec.tar.gz
/crowdsec-nginx-bouncer.tgz
if [[ -n ${CROWDSEC_VERSION} ]]; then
echo "
┌─────────────────────────────────────────────────────────────────────────┐
│ !! ATTENTION !! │
│ │
│ This mod will ignore the │
│ CROWDSEC_VERSION environment variable │
│ │
│ Versioning is now handled by mod tags │
│ See https://hub.docker.com/r/linuxserver/mods/tags?name=swag-crowdsec-v │
│ For a list of all available tags │
└─────────────────────────────────────────────────────────────────────────┘"
fi
echo "**** Successfully configured CrowdSec nginx Bouncer ${CROWDSEC_VERSION} ****"