Fixed docker-entrypoint.sh

This commit is contained in:
2023-10-20 15:17:36 +00:00
parent 982d8a2bc9
commit befc135829
+30 -14
View File
@@ -1,47 +1,63 @@
#!/bin/sh
#!/bin/bash
CONFIG_PATH="/data/options.json"
N8N_PATH="/data/n8n"
mkdir -p "${N8N_PATH}/.n8n"
mkdir -p "${N8N_PATH}/.n8n/.cache"
#####################
## USER PARAMETERS ##
#####################
# REQUIRED
# Extract the values from env_vars_list
values=$(jq -r '.env_vars_list | .[]' "$CONFIG_PATH")
# Convert the values to an array
IFS=$'\n' read -r -d '' -a array <<< "$values"
# Export keys and values
for element in "${array[@]}"
do
key="${element%%:*}"
value="${element#*:}"
value=$(echo "$value" | xargs) # Remove leading and trailing whitespace
export "$key"="$value"
echo "exported ${key}=${value}"
done
export N8N_BASIC_AUTH_ACTIVE="$(jq --raw-output '.auth // empty' $CONFIG_PATH)"
export N8N_BASIC_AUTH_USER="$(jq --raw-output '.auth_username // empty' $CONFIG_PATH)"
export N8N_BASIC_AUTH_PASSWORD="$(jq --raw-output '.auth_password // empty' $CONFIG_PATH)"
export N8N_HOST="$(jq --raw-output '.n8n_host // empty' $CONFIG_PATH)"
export N8N_PORT="$(jq --raw-output '.n8n_port // empty' $CONFIG_PATH)"
export NODE_ENV="$(jq --raw-output '.mode_env // empty' $CONFIG_PATH)"
export WEBHOOK_TUNNEL_URL="$(jq --raw-output '.webhook_tunnel_url // empty' $CONFIG_PATH)"
export GENERIC_TIMEZONE="$(jq --raw-output '.timezone // empty' $CONFIG_PATH)"
export N8N_PROTOCOL="$(jq --raw-output '.protocol // empty' $CONFIG_PATH)"
export N8N_SSL_CERT="/ssl/$(jq --raw-output '.certfile // empty' $CONFIG_PATH)"
export N8N_SSL_KEY="/ssl/$(jq --raw-output '.keyfile // empty' $CONFIG_PATH)"
export N8N_CMD_LINE="$(jq --raw-output '.cmd_line_args // empty' $CONFIG_PATH)"
export N8N_USER_FOLDER="${N8N_PATH}"
export N8N_HOST="$(jq --raw-output '.n8n_host // empty' $CONFIG_PATH)"
export N8N_PORT="$(jq --raw-output '.n8n_port // empty' $CONFIG_PATH)"
export NODE_ENV="$(jq --raw-output '.mode_env // empty' $CONFIG_PATH)"
export WEBHOOK_TUNNEL_URL="$(jq --raw-output '.webhook_tunnel_url // empty' $CONFIG_PATH)"
if [ -z "${N8N_BASIC_AUTH_USER}" ] || [ -z "${N8N_BASIC_AUTH_ACTIVE}" ]; then
export N8N_BASIC_AUTH_ACTIVE=false
unset N8N_BASIC_AUTH_USER
unset N8N_BASIC_AUTH_PASSWORD
fi
###########
## MAIN ##
###########
if [ -d ${N8N_PATH} ] ; then
chmod o+rx ${N8N_PATH}
chown -R node ${N8N_PATH}/.n8n
ln -s ${N8N_PATH}/.n8n /home/node/
if [ "$#" -gt 0 ]; then
# Got started with arguments
exec n8n "${N8N_CMD_LINE}"
else
# Got started without arguments
exec n8n start
fi
chown -R node /home/node