#!/bin/sh # Build public URL from the HF Space host (SPACE_HOST is set automatically by HF) if [ -n "$SPACE_HOST" ]; then export N8N_HOST="$SPACE_HOST" export WEBHOOK_URL="https://$SPACE_HOST/" export N8N_EDITOR_BASE_URL="https://$SPACE_HOST/" fi # Map secrets -> n8n DB variables export DB_POSTGRESDB_HOST="${DB_POSTGRESDB_HOST:-}" export DB_POSTGRESDB_PORT="${DB_POSTGRESDB_PORT:-5432}" export DB_POSTGRESDB_DATABASE="${DB_POSTGRESDB_DATABASE:-postgres}" export DB_POSTGRESDB_USER="${DB_POSTGRESDB_USER:-postgres}" export DB_POSTGRESDB_SSL_ENABLED="${DB_POSTGRESDB_SSL_ENABLED:-true}" export DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED="${DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED:-false}" # If no Postgres host given, fall back to SQLite (data is LOST on restart) if [ -z "$DB_POSTGRESDB_HOST" ]; then echo "WARNING: No Postgres configured. Using SQLite - data will be lost on restart." export DB_TYPE=sqlite fi if [ -z "$N8N_ENCRYPTION_KEY" ]; then echo "WARNING: N8N_ENCRYPTION_KEY not set. Set it as a Space secret!" fi exec n8n start