-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathentry.sh
More file actions
executable file
·58 lines (44 loc) · 2.08 KB
/
entry.sh
File metadata and controls
executable file
·58 lines (44 loc) · 2.08 KB
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
#!/bin/sh
# Enhanced entry script for n8n with better error handling and configuration
set -e
echo "Starting n8n configuration..."
# Parse database URL if DATABASE_URL is provided
if [ ! -z "$DATABASE_URL" ]; then
echo "Configuring PostgreSQL connection from DATABASE_URL..."
# Extract components from DATABASE_URL
# Format: postgres://username:password@host:port/database
export DB_POSTGRESDB_DATABASE=$(echo $DATABASE_URL | sed -n 's/.*\/\([^?]*\).*/\1/p')
export DB_POSTGRESDB_HOST=$(echo $DATABASE_URL | sed -n 's/.*@\([^:]*\):.*/\1/p')
export DB_POSTGRESDB_PORT=$(echo $DATABASE_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p')
export DB_POSTGRESDB_USER=$(echo $DATABASE_URL | sed -n 's/.*\/\/\([^:]*\):.*/\1/p')
export DB_POSTGRESDB_PASSWORD=$(echo $DATABASE_URL | sed -n 's/.*:\/\/[^:]*:\([^@]*\)@.*/\1/p')
# Set default port if not specified
if [ -z "$DB_POSTGRESDB_PORT" ]; then
export DB_POSTGRESDB_PORT=5432
fi
echo "Database configured: host=$DB_POSTGRESDB_HOST, database=$DB_POSTGRESDB_DATABASE"
fi
# Check if encryption key is set (required for production)
if [ -z "$N8N_ENCRYPTION_KEY" ]; then
echo "WARNING: N8N_ENCRYPTION_KEY is not set!"
echo "Credentials will not be encrypted properly."
echo "Generate one with: openssl rand -hex 32"
fi
# Set webhook URL if not provided
if [ ! -z "$N8N_HOST" ] && [ -z "$WEBHOOK_URL" ]; then
export WEBHOOK_URL="https://$N8N_HOST/"
echo "Webhook URL set to: $WEBHOOK_URL"
fi
# Set editor base URL if not provided
if [ ! -z "$N8N_HOST" ] && [ -z "$N8N_EDITOR_BASE_URL" ]; then
export N8N_EDITOR_BASE_URL="https://$N8N_HOST/"
echo "Editor base URL set to: $N8N_EDITOR_BASE_URL"
fi
# Set permissions enforcement to avoid warnings
export N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
# Create .n8n directory if it doesn't exist
mkdir -p /home/node/.n8n
echo "Configuration complete. Starting n8n..."
# Execute the original n8n docker entrypoint with proper tini handling
# Use exec to replace the shell process with tini as PID 1
exec /sbin/tini -s -- /docker-entrypoint.sh "$@"