From 62ec56d717ba284b2228053653669c14b3eb7798 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Wed, 23 Mar 2022 13:27:26 +0000 Subject: [PATCH 1/2] Handle missing http.d include --- root/etc/cont-init.d/98-crowdsec | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/root/etc/cont-init.d/98-crowdsec b/root/etc/cont-init.d/98-crowdsec index 44191f3..e480cc9 100644 --- a/root/etc/cont-init.d/98-crowdsec +++ b/root/etc/cont-init.d/98-crowdsec @@ -56,8 +56,22 @@ sed -ir "s|SECRET_KEY=.*$|SECRET_KEY=${CROWDSEC_SECRET_KEY}|" "${CONFIG_PATH}cro sed -ir "s|SITE_KEY=.*$|SITE_KEY=${CROWDSEC_SITE_KEY}|" "${CONFIG_PATH}crowdsec-nginx-bouncer.conf" # Sed in crowdsec include -if grep -q '#include /etc/nginx/http.d/\*.conf;' '/config/nginx/nginx.conf'; then - sed -i 's|#include /etc/nginx/http.d/\*.conf;|include /etc/nginx/http.d/\*.conf;|' /config/nginx/nginx.conf +if ! grep -q '[^#]include /etc/nginx/http.d/\*.conf;' '/config/nginx/nginx.conf'; then + if grep -q '#include /etc/nginx/http.d/\*.conf;' '/config/nginx/nginx.conf'; then + # Enable http.d include + sed -i 's|#include /etc/nginx/http.d/\*.conf;|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 bouncer will not function until this is done. * + ***************************************************************" + fi fi # Clean up From 6d58f64dc4815aa0d3bce0d966568756df101da3 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Wed, 23 Mar 2022 13:32:30 +0000 Subject: [PATCH 2/2] Make message more explicit --- root/etc/cont-init.d/98-crowdsec | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/root/etc/cont-init.d/98-crowdsec b/root/etc/cont-init.d/98-crowdsec index e480cc9..4d24842 100644 --- a/root/etc/cont-init.d/98-crowdsec +++ b/root/etc/cont-init.d/98-crowdsec @@ -63,14 +63,14 @@ 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 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