-
Notifications
You must be signed in to change notification settings - Fork 16
/
docker-entrypoint.sh
executable file
·68 lines (55 loc) · 1.99 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
CONFIG_PATH="/data/options.json"
N8N_PATH="/data/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
# IF NODE_FUNCTION_ALLOW_EXTERNAL is set, install the required packages
if [ -n "${NODE_FUNCTION_ALLOW_EXTERNAL}" ]; then
echo "Installing external packages..."
IFS=',' read -r -a packages <<< "${NODE_FUNCTION_ALLOW_EXTERNAL}"
for package in "${packages[@]}"
do
echo "Installing ${package}..."
npm install -g "${package}"
done
fi
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 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}"
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 [ "$#" -gt 0 ]; then
# Got started with arguments
exec n8n "${N8N_CMD_LINE}"
else
# Got started without arguments
exec n8n start
fi