aboutsummaryrefslogtreecommitdiff
path: root/lang/lua-cs-bouncer/files
diff options
context:
space:
mode:
authorKerma Gérald <gandalf@gk2.net>2022-01-21 10:59:00 +0100
committerRosen Penev <rosenp@gmail.com>2022-02-14 17:26:16 -0800
commit846df82a84b7586173d9fa04f7745cd977e27d40 (patch)
tree181bb3d723e1b602409ec0df2e79e5464c8df935 /lang/lua-cs-bouncer/files
parent4137429a2586ce19f48466aaa3ea0d4b77d7e685 (diff)
lua-cs-bouncer: initial package
Lua Crowdsec Bouncer module Lua module to allow ip (or not) from CrowdSec API. https://github.com/crowdsecurity/lua-cs-bouncer required for crowdsec-nginx-bouncer Signed-off-by: Kerma Gérald <gandalf@gk2.net>
Diffstat (limited to 'lang/lua-cs-bouncer/files')
-rw-r--r--lang/lua-cs-bouncer/files/lua-cs-bouncer.defaults13
1 files changed, 13 insertions, 0 deletions
diff --git a/lang/lua-cs-bouncer/files/lua-cs-bouncer.defaults b/lang/lua-cs-bouncer/files/lua-cs-bouncer.defaults
new file mode 100644
index 000000000..12e4a9988
--- /dev/null
+++ b/lang/lua-cs-bouncer/files/lua-cs-bouncer.defaults
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+CONFIG=/usr/lib/lua/crowdsec/crowdsec.conf
+## Gen&ConfigApiKey
+if grep -q "{API_KEY}" "$CONFIG"; then
+ SUFFIX=`tr -dc A-Za-z0-9 </dev/urandom | head -c 8`
+ API_KEY=`/usr/bin/cscli bouncers add lua-cs-bouncer-${SUFFIX} -o raw`
+ sed -i "s,^\(\s*API_KEY\s*=\s*\).*\$,\1$API_KEY," $CONFIG
+else
+ echo API key already registered...
+fi
+
+exit 0