@@ -6,57 +6,21 @@ log() {
6
6
echo " [cont-init.d] $( basename $0 ) : $* "
7
7
}
8
8
9
- CROWDSEC_OPENRESTY_BOUNCER_VERSION=${CROWDSEC_BOUNCER_VERSION}
10
- CROWDSEC_OPENRESTY_BOUNCER_URL=https://github.com/crowdsecurity/cs-openresty-bouncer/releases/download/v${CROWDSEC_OPENRESTY_BOUNCER_VERSION:= 0.1.1} /crowdsec-openresty-bouncer.tgz
11
-
12
- if [ ${CROWDSEC_BOUNCER} == " 1" ]; then
13
- # Create required folders if they don't exist
14
- mkdir -p /tmp/crowdsec/ /config/crowdsec/templates /config/crowdsec/static_package
15
- # Download the Crowdsec Openresty Bouncer if a static package is not found, this is useful for testing new versions or if we don't want to update
16
- if [ -f /config/crowdsec/static_package/crowdsec-openresty-bouncer.tgz ]; then
17
- tar -xf /config/crowdsec/static_package/crowdsec-openresty-bouncer.tgz --strip=1 -C /tmp/crowdsec/
18
- else
19
- wget ${CROWDSEC_OPENRESTY_BOUNCER_URL} -O /tmp/crowdsec-openresty-bouncer.tgz
20
- tar -xf /tmp/crowdsec-openresty-bouncer.tgz --strip=1 -C /tmp/crowdsec/
21
- rm /tmp/crowdsec-openresty-bouncer.tgz
22
- fi
23
-
24
- # Manually Deploy Crowdsec Openresty Bouncer, this will be done by the install.sh script in crowdsec-openresty-bouncer in future.
25
- # https://github.com/crowdsecurity/cs-openresty-bouncer/pull/18
26
- if grep ' docker' /tmp/crowdsec/install.sh; then
27
- cd /tmp/crowdsec && bash ./install.sh --NGINX_CONF_DIR=/etc/nginx/conf.d --LIB_PATH=/var/lib/nginx/lualib --CONFIG_PATH=/config/crowdsec --DATA_PATH=/config/crowdsec --docker
28
- else
29
- echo " Deploy Crowdsec Openresty Bouncer manually.."
30
- echo " Patching crowdsec_openresty.conf.."
31
- # this will be handled by the installer but due to the current manual process this has to happen.
32
- sed -i ' s|/etc/crowdsec/bouncers/crowdsec-openresty-bouncer.conf|/config/crowdsec/crowdsec-openresty-bouncer.conf|' /tmp/crowdsec/openresty/crowdsec_openresty.conf
33
- sed -i ' s|/usr/local/openresty/lualib/plugins/crowdsec|/var/lib/nginx/lualib/plugins/crowdsec|' /tmp/crowdsec/openresty/crowdsec_openresty.conf
34
- sed -i ' s|${SSL_CERTS_PATH}|/etc/ssl/certs/ca-certificates.crt|' /tmp/crowdsec/openresty/crowdsec_openresty.conf
35
- sed -i ' s|resolver local=on ipv6=off;||' /tmp/crowdsec/openresty/crowdsec_openresty.conf
36
- echo " Deploy crowdsec_openresty.conf.."
37
- cp /tmp/crowdsec/openresty/crowdsec_openresty.conf /etc/nginx/conf.d/
38
- echo " Deploy lau files.."
39
- cp -r /tmp/crowdsec/lua/lib/* /var/lib/nginx/lualib/
40
- if [ -f /config/crowdsec/crowdsec-openresty-bouncer.conf ]; then
41
- echo " Patch crowdsec-openresty-bouncer.conf .."
42
- sed " s/=.*//g" /config/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec.conf.raw
43
- sed " s/=.*//g" /tmp/crowdsec/config/config_example.conf > /tmp/config_example.conf.raw
44
- if grep -vf /tmp/crowdsec.conf.raw /tmp/config_example.conf.raw ; then
45
- grep -vf /tmp/crowdsec.conf.raw /tmp/config_example.conf.raw > /tmp/config_example.newvals
46
- cp /config/crowdsec/crowdsec-openresty-bouncer.conf /config/crowdsec/crowdsec-openresty-bouncer.conf.bak
47
- grep -f /tmp/config_example.newvals /tmp/crowdsec/config/config_example.conf >> /config/crowdsec/crowdsec-openresty-bouncer.conf
48
- fi
49
- else
50
- echo " Deploy new crowdsec-openresty-bouncer.conf .."
51
- cp /tmp/crowdsec/config/config_example.conf /config/crowdsec/crowdsec-openresty-bouncer.conf
52
-
53
- fi
54
- echo " Deploy Templates .."
55
- sed -i ' s|/var/lib/crowdsec/lua/templates|/config/crowdsec/templates|' /config/crowdsec/crowdsec-openresty-bouncer.conf
56
- cp -r /tmp/crowdsec/templates/* /config/crowdsec/templates/
9
+ mkdir -p /config/crowdsec
10
+ echo " Deploy Crowdsec Openresty Bouncer manually.."
11
+ if [ -f /config/crowdsec/crowdsec-openresty-bouncer.conf ]; then
12
+ echo " Patch crowdsec-openresty-bouncer.conf .."
13
+ sed " s/=.*//g" /config/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec.conf.raw
14
+ sed " s/=.*//g" /defaults/crowdsec/config_example.conf > /tmp/config_example.conf.raw
15
+ if grep -vf /tmp/crowdsec.conf.raw /tmp/config_example.conf.raw ; then
16
+ grep -vf /tmp/crowdsec.conf.raw /tmp/config_example.conf.raw > /tmp/config_example.newvals
17
+ cp /config/crowdsec/crowdsec-openresty-bouncer.conf /config/crowdsec/crowdsec-openresty-bouncer.conf.bak
18
+ grep -f /tmp/config_example.newvals /defaults/crowdsec/config_example.conf >> /config/crowdsec/crowdsec-openresty-bouncer.conf
57
19
fi
58
-
59
- [ -n " ${CROWDSEC_APIKEY} " ] && sed -i ' s|API_KEY=.*|API_KEY= ' ${CROWDSEC_APIKEY} ' | ' /config/ crowdsec/crowdsec -openresty-bouncer.conf
60
- [ -n " ${CROWDSEC_HOSTNAME} " ] && sed -i ' s|API_URL=.*|API_URL= ' ${CROWDSEC_HOSTNAME} ' | ' /config/crowdsec/crowdsec-openresty-bouncer.conf
20
+ else
21
+ echo " Deploy new crowdsec-openresty-bouncer.conf .. "
22
+ cp /defaults/crowdsec/config_example.conf /config/crowdsec/crowdsec-openresty-bouncer.conf
61
23
fi
62
- exit 0
24
+ echo " Deploy Templates .."
25
+ sed -i ' s|/defaults/crowdsec/templates|/config/crowdsec/templates|' /config/crowdsec/crowdsec-openresty-bouncer.conf
26
+ cp -r /defaults/crowdsec/templates/* /config/crowdsec/templates/
0 commit comments