Files
MobilityOps/deploy/unraid/configure-env.sh
NuklearRabbit 24dcb3494c
MobilityOps acceptance / backend (push) Failing after 47s
MobilityOps acceptance / frontend (push) Successful in 29s
MobilityOps acceptance / e2e (push) Skipped
M41: harden trust boundaries and delivery
2026-08-21 17:06:59 +02:00

48 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
set -eu
public_url="${1:-https://fleetops.itworx.tech}"
n8n_webhook_url="${2:-https://n8n.itworx.tech/webhook/mobilityops-return}"
case "$public_url" in
https://*) ;;
*) echo "Production public URL must use HTTPS" >&2; exit 1 ;;
esac
if [ -e .env ]; then
echo "Refusing to overwrite existing .env" >&2
exit 1
fi
cp .env.example .env
chmod 0600 .env
db_password="$(openssl rand -hex 24)"
app_secret="$(openssl rand -hex 32)"
n8n_key="$(openssl rand -hex 32)"
n8n_password="$(openssl rand -hex 24)"
callback_token="$(openssl rand -hex 32)"
trigger_token="$(openssl rand -hex 32)"
mcp_token="$(openssl rand -hex 32)"
sed -i \
-e "s|^MOBILITYOPS_ENV=.*|MOBILITYOPS_ENV=production|" \
-e "s|^MOBILITYOPS_PUBLIC_URL=.*|MOBILITYOPS_PUBLIC_URL=${public_url}|" \
-e "s|^DATABASE_URL=.*|DATABASE_URL=postgresql+psycopg://mobilityops:${db_password}@db:5432/mobilityops|" \
-e "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=${db_password}|" \
-e "s|^APP_SECRET=.*|APP_SECRET=${app_secret}|" \
-e "s|^SESSION_COOKIE_SECURE=.*|SESSION_COOKIE_SECURE=true|" \
-e "s|^N8N_WEBHOOK_URL=.*|N8N_WEBHOOK_URL=${n8n_webhook_url}|" \
-e "s|^N8N_ENCRYPTION_KEY=.*|N8N_ENCRYPTION_KEY=${n8n_key}|" \
-e "s|^N8N_BASIC_AUTH_PASSWORD=.*|N8N_BASIC_AUTH_PASSWORD=${n8n_password}|" \
-e "s|^MOBILITYOPS_CALLBACK_TOKEN=.*|MOBILITYOPS_CALLBACK_TOKEN=${callback_token}|" \
-e "s|^MOBILITYOPS_WEBHOOK_TRIGGER_TOKEN=.*|MOBILITYOPS_WEBHOOK_TRIGGER_TOKEN=${trigger_token}|" \
-e "s|^KNOWLEDGE_PROVIDER=.*|KNOWLEDGE_PROVIDER=demo|" \
-e "s|^MCP_HUB_REGISTRATION_ENABLED=.*|MCP_HUB_REGISTRATION_ENABLED=false|" \
-e "s|^MCP_HUB_SERVICE_TOKEN=.*|MCP_HUB_SERVICE_TOKEN=${mcp_token}|" \
.env
unset db_password app_secret n8n_key n8n_password callback_token trigger_token mcp_token
echo "Created server .env for ${public_url} using n8n webhook ${n8n_webhook_url}"