|
@@ -76,13 +76,13 @@ if [ "$GID" != "" ]; then
|
|
fi
|
|
fi
|
|
|
|
|
|
if [ "$USE_TLS" != "" ]; then
|
|
if [ "$USE_TLS" != "" ]; then
|
|
- yq -i eval ".api.server.tls.cert_file = \"$CERT_FILE\"" "$CS_CONFIG_FILE"
|
|
|
|
- yq -i eval ".api.server.tls.key_file = \"$KEY_FILE\"" "$CS_CONFIG_FILE"
|
|
|
|
- yq -i eval '... comments=""' "$CS_CONFIG_FILE"
|
|
|
|
|
|
+ yq -i eval ".api.server.tls.cert_file = \"$CERT_FILE\"" "$CS_CONFIG_FILE"
|
|
|
|
+ yq -i eval ".api.server.tls.key_file = \"$KEY_FILE\"" "$CS_CONFIG_FILE"
|
|
|
|
+ yq -i eval '... comments=""' "$CS_CONFIG_FILE"
|
|
fi
|
|
fi
|
|
|
|
|
|
if [ "$PLUGIN_DIR" != "/usr/local/lib/crowdsec/plugins/" ]; then
|
|
if [ "$PLUGIN_DIR" != "/usr/local/lib/crowdsec/plugins/" ]; then
|
|
- yq -i eval ".config_paths.plugin_dir = \"$PLUGIN_DIR\"" "$CS_CONFIG_FILE"
|
|
|
|
|
|
+ yq -i eval ".config_paths.plugin_dir = \"$PLUGIN_DIR\"" "$CS_CONFIG_FILE"
|
|
fi
|
|
fi
|
|
|
|
|
|
## Install collections, parsers, scenarios & postoverflows
|
|
## Install collections, parsers, scenarios & postoverflows
|
|
@@ -117,6 +117,36 @@ if [ "$DISABLE_POSTOVERFLOWS" != "" ]; then
|
|
cscli -c "$CS_CONFIG_FILE" postoverflows remove $DISABLE_POSTOVERFLOWS
|
|
cscli -c "$CS_CONFIG_FILE" postoverflows remove $DISABLE_POSTOVERFLOWS
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+function register_bouncer {
|
|
|
|
+ if ! cscli -c "$CS_CONFIG_FILE" bouncers list -o json | jq -r .[].name | grep -q "${NAME}"; then
|
|
|
|
+ if cscli -c "$CS_CONFIG_FILE" bouncers add "${NAME}" -k "${KEY}" > /dev/null; then
|
|
|
|
+ echo "Registered bouncer for ${NAME}"
|
|
|
|
+ else
|
|
|
|
+ echo "Failed to register bouncer for ${NAME}"
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+## Register bouncers via env
|
|
|
|
+for BOUNCER in $(compgen -A variable | grep -i BOUNCER_KEY); do
|
|
|
|
+ KEY=$(printf '%s' "${!BOUNCER}")
|
|
|
|
+ NAME=$(printf '%s' "$BOUNCER" | cut -d_ -f2-)
|
|
|
|
+ if [[ -n $KEY ]] && [[ -n $NAME ]]; then
|
|
|
|
+ register_bouncer
|
|
|
|
+ fi
|
|
|
|
+done
|
|
|
|
+
|
|
|
|
+## Register bouncers via secrets
|
|
|
|
+shopt -s nullglob extglob
|
|
|
|
+for BOUNCER in /run/secrets/@(bouncer_key|BOUNCER_KEY)* ; do
|
|
|
|
+ KEY=$(cat "${BOUNCER}")
|
|
|
|
+ NAME=$(echo "${BOUNCER}" | awk -F "/" '{printf $NF}' | cut -d_ -f2-)
|
|
|
|
+ if [[ -n $KEY ]] && [[ -n $NAME ]]; then
|
|
|
|
+ register_bouncer
|
|
|
|
+ fi
|
|
|
|
+done
|
|
|
|
+shopt -u nullglob extglob
|
|
|
|
+
|
|
ARGS=""
|
|
ARGS=""
|
|
if [ "$CONFIG_FILE" != "" ]; then
|
|
if [ "$CONFIG_FILE" != "" ]; then
|
|
ARGS="-c $CONFIG_FILE"
|
|
ARGS="-c $CONFIG_FILE"
|