crowdsec-nginx-bouncer : init
This commit is contained in:
parent
585d05ccfb
commit
354d837c25
120
crowdsec-nginx-bouncer/install.sh
Normal file
120
crowdsec-nginx-bouncer/install.sh
Normal file
File diff suppressed because it is too large
Load Diff
45
crowdsec-nginx-bouncer/upgrade.sh
Normal file
45
crowdsec-nginx-bouncer/upgrade.sh
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LUA_MOD_DIR="./lua-mod"
|
||||||
|
NGINX_CONF="crowdsec_nginx.conf"
|
||||||
|
NGINX_CONF_DIR="/etc/nginx/conf.d/"
|
||||||
|
ACCESS_FILE="access.lua"
|
||||||
|
LIB_PATH="/usr/local/lua/"
|
||||||
|
CONFIG_PATH="/etc/crowdsec/bouncers/"
|
||||||
|
CONFIG_FILE="${CONFIG_PATH}crowdsec-nginx-bouncer.conf"
|
||||||
|
OLD_CONFIG_FILE="/etc/crowdsec/crowdsec-nginx-bouncer.conf"
|
||||||
|
DATA_PATH="/var/lib/crowdsec/lua/"
|
||||||
|
|
||||||
|
install() {
|
||||||
|
mkdir -p ${LIB_PATH}/plugins/crowdsec/
|
||||||
|
mkdir -p ${DATA_PATH}/templates/
|
||||||
|
|
||||||
|
cp nginx/${NGINX_CONF} ${NGINX_CONF_DIR}/${NGINX_CONF}
|
||||||
|
cp -r ${LUA_MOD_DIR}/lib/* ${LIB_PATH}/
|
||||||
|
cp -r ${LUA_MOD_DIR}/templates/* ${DATA_PATH}/templates/
|
||||||
|
}
|
||||||
|
|
||||||
|
migrate_conf() {
|
||||||
|
if [ -f "$CONFIG_FILE" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ ! -f "$OLD_CONFIG_FILE" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Found $OLD_CONFIG_FILE, but no $CONFIG_FILE. Migrating it."
|
||||||
|
mv "$OLD_CONFIG_FILE" "$CONFIG_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! [ $(id -u) = 0 ]; then
|
||||||
|
log_err "Please run the upgrade script as root or with sudo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "${CONFIG_PATH}" ]; then
|
||||||
|
echo "crowdsec-nginx-bouncer is not installed, please run the ./install.sh script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install
|
||||||
|
migrate_conf
|
||||||
|
echo "crowdsec-nginx-bouncer upgraded successfully"
|
@ -10,7 +10,7 @@ bash ~/nginx_scriptbox.sh
|
|||||||
|
|
||||||
#### Note : don't forgot to add necessary `lua_package_path` directive to `nginx.conf`, in the http context. else Nginx won't run.
|
#### Note : don't forgot to add necessary `lua_package_path` directive to `nginx.conf`, in the http context. else Nginx won't run.
|
||||||
```lua
|
```lua
|
||||||
lua_package_path "/opt/nginx-lua-module/lib/lua/?.lua;;";
|
lua_package_path "/usr/local/lua/?.lua;;';
|
||||||
```
|
```
|
||||||
|
|
||||||
systemd Template:
|
systemd Template:
|
||||||
|
@ -59,10 +59,12 @@ mkdir -p /opt/nginx-lua-module/
|
|||||||
git clone https://github.com/openresty/lua-resty-core $HOMEDIRECTORY/nginx-lua/lua-resty-core
|
git clone https://github.com/openresty/lua-resty-core $HOMEDIRECTORY/nginx-lua/lua-resty-core
|
||||||
git clone https://github.com/openresty/lua-resty-lrucache $HOMEDIRECTORY/nginx-lua/lua-resty-lrucache
|
git clone https://github.com/openresty/lua-resty-lrucache $HOMEDIRECTORY/nginx-lua/lua-resty-lrucache
|
||||||
git clone https://github.com/openresty/luajit2 $HOMEDIRECTORY/nginx-lua/luajit2
|
git clone https://github.com/openresty/luajit2 $HOMEDIRECTORY/nginx-lua/luajit2
|
||||||
|
git clone https://github.com/openresty/lua-resty-string $HOMEDIRECTORY/nginx-lua/lua-resty-string
|
||||||
|
|
||||||
cd $HOMEDIRECTORY/nginx-lua/luajit2 && make && make install PREFIX=/opt/nginx-lua-module/luajit2
|
cd $HOMEDIRECTORY/nginx-lua/luajit2 && make && make install PREFIX=/opt/nginx-lua-module/luajit2
|
||||||
cd $HOMEDIRECTORY/nginx-lua/lua-resty-core && make install PREFIX=/opt/nginx-lua-module/
|
cd $HOMEDIRECTORY/nginx-lua/lua-resty-core && make install PREFIX=/usr/local/lua LUA_LIB_DIR=/usr/local/lua
|
||||||
cd $HOMEDIRECTORY/nginx-lua/lua-resty-lrucache && make install PREFIX=/opt/nginx-lua-module/
|
cd $HOMEDIRECTORY/nginx-lua/lua-resty-lrucache && make install PREFIX=/usr/local/lua LUA_LIB_DIR=/usr/local/lua
|
||||||
|
cd $HOMEDIRECTORY/nginx-lua/lua-resty-string && make install PREFIX=/usr/local/lua LUA_LIB_DIR=/usr/local/lua
|
||||||
|
|
||||||
export LUAJIT_LIB=/opt/nginx-lua-module/luajit2/lib
|
export LUAJIT_LIB=/opt/nginx-lua-module/luajit2/lib
|
||||||
export LUAJIT_INC=/opt/nginx-lua-module/luajit2/include/luajit-2.1
|
export LUAJIT_INC=/opt/nginx-lua-module/luajit2/include/luajit-2.1
|
||||||
|
Loading…
Reference in New Issue
Block a user