mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-30 02:52:29 +00:00
added support to use environment variables instead of set file in data drive.
This commit is contained in:
parent
58ae5a1559
commit
c56e64bce2
@ -2,25 +2,43 @@
|
|||||||
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status.
|
set -e # Exit immediately if a command exits with a non-zero status.
|
||||||
|
|
||||||
mkdir -p /data/crowdsec/templates
|
function set_properties() {
|
||||||
echo "Deploy Crowdsec Openresty Bouncer.."
|
sed -i "s/^$1=.*/$1=$2/" "${3}"
|
||||||
sed -i 's|/defaults/crowdsec|/data/crowdsec|' /etc/nginx/conf.d/crowdsec_openresty.conf
|
}
|
||||||
|
|
||||||
if [ -f /data/crowdsec/crowdsec-openresty-bouncer.conf ]; then
|
echo "Deploy Crowdsec Openresty Bouncer.."
|
||||||
echo "Patch crowdsec-openresty-bouncer.conf .."
|
if [ -n "${CROWDSEC_OPENRESTY_BOUNCER}" ]; then
|
||||||
sed "s/=.*//g" /data/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec.conf.raw
|
while IFS= read -r line
|
||||||
sed "s/=.*//g" /defaults/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec-openresty-bouncer.conf.raw
|
do
|
||||||
if grep -vf /tmp/crowdsec.conf.raw /tmp/crowdsec-openresty-bouncer.conf.raw ; then
|
if ! [[ "$line" != "^#" ]] || [[ "$line" != "^\n" ]]; then
|
||||||
grep -vf /tmp/crowdsec.conf.raw /tmp/crowdsec-openresty-bouncer.conf.raw > /tmp/config.newvals
|
name=$(echo "$line" | cut -d "=" -f1)
|
||||||
cp /data/crowdsec/crowdsec-openresty-bouncer.conf /data/crowdsec/crowdsec-openresty-bouncer.conf.bak
|
value=$(echo "$line" | cut -d "=" -f2)
|
||||||
grep -f /tmp/config.newvals /defaults/crowdsec/crowdsec-openresty-bouncer.conf >> /data/crowdsec/crowdsec-openresty-bouncer.conf
|
if grep -q "${name}" /defaults/crowdsec/crowdsec-openresty-bouncer.conf ; then
|
||||||
fi
|
set_properties "${name}" "${value}" "/defaults/crowdsec/crowdsec-openresty-bouncer.conf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <<< "${CROWDSEC_OPENRESTY_BOUNCER}"
|
||||||
else
|
else
|
||||||
echo "Deploy new crowdsec-openresty-bouncer.conf .."
|
mkdir -p /data/crowdsec/templates
|
||||||
cp /defaults/crowdsec/crowdsec-openresty-bouncer.conf /data/crowdsec/crowdsec-openresty-bouncer.conf
|
sed -i 's|/defaults/crowdsec|/data/crowdsec|' /etc/nginx/conf.d/crowdsec_openresty.conf
|
||||||
|
|
||||||
|
if [ -f /data/crowdsec/crowdsec-openresty-bouncer.conf ]; then
|
||||||
|
echo "Patch crowdsec-openresty-bouncer.conf .."
|
||||||
|
sed "s/=.*//g" /data/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec.conf.raw
|
||||||
|
sed "s/=.*//g" /defaults/crowdsec/crowdsec-openresty-bouncer.conf > /tmp/crowdsec-openresty-bouncer.conf.raw
|
||||||
|
if grep -vf /tmp/crowdsec.conf.raw /tmp/crowdsec-openresty-bouncer.conf.raw ; then
|
||||||
|
grep -vf /tmp/crowdsec.conf.raw /tmp/crowdsec-openresty-bouncer.conf.raw > /tmp/config.newvals
|
||||||
|
cp /data/crowdsec/crowdsec-openresty-bouncer.conf /data/crowdsec/crowdsec-openresty-bouncer.conf.bak
|
||||||
|
grep -f /tmp/config.newvals /defaults/crowdsec/crowdsec-openresty-bouncer.conf >> /data/crowdsec/crowdsec-openresty-bouncer.conf
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Deploy new crowdsec-openresty-bouncer.conf .."
|
||||||
|
cp /defaults/crowdsec/crowdsec-openresty-bouncer.conf /data/crowdsec/crowdsec-openresty-bouncer.conf
|
||||||
|
fi
|
||||||
|
#Make sure the config location is where we get the config from instead of /default/
|
||||||
|
sed -i 's|/defaults/crowdsec|/data/crowdsec|' /data/crowdsec/crowdsec-openresty-bouncer.conf
|
||||||
fi
|
fi
|
||||||
#Make sure the config location is where we get the config from instead of /default/
|
|
||||||
sed -i 's|/defaults/crowdsec|/data/crowdsec|' /data/crowdsec/crowdsec-openresty-bouncer.conf
|
|
||||||
echo "Deploy Crowdsec Templates .."
|
echo "Deploy Crowdsec Templates .."
|
||||||
#Make sure we only copy files that don't exist in /data/crowdsec.
|
#Make sure we only copy files that don't exist in /data/crowdsec.
|
||||||
cd /defaults/crowdsec/templates/
|
cd /defaults/crowdsec/templates/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user