-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·96 lines (78 loc) · 3.04 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·96 lines (78 loc) · 3.04 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -euo pipefail
echo "=== Open Integration Platform — Setup ==="
echo ""
if ! command -v docker &> /dev/null; then
echo "ERROR: docker is not installed. Install Docker first: https://docs.docker.com/get-docker/"
exit 1
fi
if ! docker compose version &> /dev/null 2>&1; then
echo "ERROR: docker compose plugin is not available."
echo "Install it: https://docs.docker.com/compose/install/"
exit 1
fi
ENV_FILE=".env"
if [ -f "$ENV_FILE" ]; then
echo "Found existing .env file, skipping generation."
else
echo "Generating .env file with secure random keys..."
gen_key() { python3 -c "import secrets; print(secrets.token_urlsafe($1))" 2>/dev/null || openssl rand -base64 "$1"; }
ENCRYPTION_KEY=$(python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())" 2>/dev/null || openssl rand -base64 32)
JWT_SECRET=$(gen_key 48)
DB_PASSWORD=$(gen_key 24)
INTERNAL_SECRET=$(gen_key 32)
ADMIN_SECRET=$(gen_key 32)
DASHBOARD_API_KEY="pk_live_$(gen_key 24)"
CONNECTOR_API_KEY="pk_conn_$(gen_key 24)"
cat > "$ENV_FILE" << EOF
# Open Integration Platform — Configuration
# Generated by setup.sh on $(date -u +%Y-%m-%dT%H:%M:%SZ)
# Database
DB_PASSWORD=${DB_PASSWORD}
# Encryption key for credential vault (DO NOT CHANGE — stored credentials become unreadable)
ENCRYPTION_KEY=${ENCRYPTION_KEY}
# Internal secret for connector-to-platform communication (/internal/* endpoints)
INTERNAL_SECRET=${INTERNAL_SECRET}
# Admin secret for admin-only API endpoints (enter via dashboard session prompt)
ADMIN_SECRET=${ADMIN_SECRET}
# Dashboard API key (auto-created tenant key)
PINQUARK_DASHBOARD_API_KEY=${DASHBOARD_API_KEY}
# API key used by connectors to authenticate against the platform
PINQUARK_CONNECTOR_API_KEY=${CONNECTOR_API_KEY}
EOF
echo "Created .env with generated secrets."
echo ""
echo "IMPORTANT: Back up your ENCRYPTION_KEY. If lost, all stored credentials"
echo " become unrecoverable."
fi
echo ""
echo "Starting services..."
docker compose -f docker-compose.prod.yml up -d
echo ""
echo "Waiting for platform to become healthy..."
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/health > /dev/null 2>&1; then
echo "Platform is healthy!"
break
fi
if [ "$i" -eq 60 ]; then
echo "WARNING: Platform did not become healthy within 60 seconds."
echo "Check logs: docker compose -f docker-compose.prod.yml logs platform"
exit 1
fi
sleep 1
done
echo ""
echo "=== Setup Complete ==="
echo ""
echo " Platform API: http://localhost:8080"
echo " Dashboard: http://localhost:3000"
echo " API Docs: http://localhost:8080/docs"
echo ""
echo "Your API key: $(grep PINQUARK_DASHBOARD_API_KEY .env | cut -d= -f2-)"
echo ""
echo "Next steps:"
echo " 1. Open the dashboard: http://localhost:3000"
echo " 2. Your API key is pre-configured — start adding connectors and credentials."
echo " 3. To use admin features, enter the ADMIN_SECRET from .env in the dashboard settings."
echo ""