-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-passwords.ps1
More file actions
199 lines (176 loc) · 7.9 KB
/
generate-passwords.ps1
File metadata and controls
199 lines (176 loc) · 7.9 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# ========================================
# SteerDock Password Generator
# Generates secure passwords for all services
# ========================================
Write-Host ""
Write-Host "SteerDock Password Generator" -ForegroundColor Cyan
Write-Host "=================================" -ForegroundColor Cyan
Write-Host ""
# Function to generate secure password
function New-SecurePassword {
param(
[int]$Length = 32
)
# Character set: a-z, A-Z, 0-9 (no special chars to avoid escaping issues)
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
$password = ""
for ($i = 0; $i -lt $Length; $i++) {
$password += $chars[(Get-Random -Maximum $chars.Length)]
}
return $password
}
# Generate all passwords
$passwords = @{
"SQL_TYPE" = "mysql"
"POSTGRES_USER" = "steerdock"
"POSTGRES_PASSWORD" = New-SecurePassword
"POSTGRES_DB" = "steerdock"
"MYSQL_USER" = "steerdock"
"MYSQL_PASSWORD" = New-SecurePassword
"MYSQL_ROOT_PASSWORD" = New-SecurePassword
"MYSQL_DATABASE" = "steerdock"
"MONGO_INITDB_ROOT_USERNAME" = "steerdock"
"MONGO_INITDB_ROOT_PASSWORD" = New-SecurePassword
"MONGO_INITDB_DATABASE" = "steerdock"
"REDIS_PASSWORD" = New-SecurePassword
"JWT_SECRET" = New-SecurePassword -Length 64
"ENCRYPTION_KEY" = New-SecurePassword -Length 64
"ALLOWED_ORIGINS" = "http://localhost:8383,http://localhost:5151,http://192.168.100.100:8383,http://192.168.100.100:5151,http://172.0.0.0:8383,http://172.0.0.0:5151"
"FRONTEND_PORT" = "5151"
"BASE_URL" = "http://localhost:8383"
}
Write-Host "Generating secure passwords..." -ForegroundColor Yellow
Write-Host ""
# ========================================
# Create .env file
# ========================================
Write-Host "Creating .env file..." -ForegroundColor Green
$envContent = @"
# ========================================
# SteerDock Environment Configuration
# Auto-generated by generate-passwords.ps1
# ========================================
# Frontend Configuration
# ========================================
FRONTEND_PORT=$($passwords['FRONTEND_PORT'])
BASE_URL=$($passwords['BASE_URL'])
# Database Configuration
# ========================================
SQL_TYPE=$($passwords['SQL_TYPE'])
# For standalone binary (connects to Docker containers)
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_URL=mysql://steerdock:$($passwords['MYSQL_PASSWORD'])@localhost:3306/steerdock
# For Docker Compose (internal network)
# DATABASE_HOST=mysql
# DATABASE_URL=mysql://steerdock:$($passwords['MYSQL_PASSWORD'])@mysql:3306/steerdock
# ========================================
# PostgreSQL Database
# ========================================
# For standalone binary (connects to Docker containers)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=$($passwords['POSTGRES_USER'])
POSTGRES_PASSWORD=$($passwords['POSTGRES_PASSWORD'])
POSTGRES_DB=$($passwords['POSTGRES_DB'])
POSTGRES_URL=postgres://steerdock:$($passwords['POSTGRES_PASSWORD'])@localhost:5432/steerdock
# For Docker Compose (internal network)
# POSTGRES_HOST=postgres
# POSTGRES_URL=postgres://steerdock:$($passwords['POSTGRES_PASSWORD'])@postgres:5432/steerdock
# ========================================
# MySQL Database
# ========================================
# For standalone binary (connects to Docker containers)
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=$($passwords['MYSQL_USER'])
MYSQL_PASSWORD=$($passwords['MYSQL_PASSWORD'])
MYSQL_ROOT_PASSWORD=$($passwords['MYSQL_ROOT_PASSWORD'])
MYSQL_DATABASE=$($passwords['MYSQL_DATABASE'])
MYSQL_URL=mysql://steerdock:$($passwords['MYSQL_PASSWORD'])@localhost:3306/steerdock
# For Docker Compose (internal network)
# MYSQL_HOST=mysql
# MYSQL_URL=mysql://steerdock:$($passwords['MYSQL_PASSWORD'])@mysql:3306/steerdock
# ========================================
# MongoDB Database
# ========================================
# For standalone binary (connects to Docker containers)
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_INITDB_ROOT_USERNAME=$($passwords['MONGO_INITDB_ROOT_USERNAME'])
MONGO_INITDB_ROOT_PASSWORD=$($passwords['MONGO_INITDB_ROOT_PASSWORD'])
MONGO_INITDB_DATABASE=$($passwords['MONGO_INITDB_DATABASE'])
MONGO_URL=mongodb://steerdock:$($passwords['MONGO_INITDB_ROOT_PASSWORD'])@localhost:27017/steerdock
# For Docker Compose (internal network)
# MONGO_HOST=mongo
# MONGO_URL=mongodb://steerdock:$($passwords['MONGO_INITDB_ROOT_PASSWORD'])@mongo:27017/steerdock
# ========================================
# Redis Cache
# ========================================
# For standalone binary (connects to Docker containers)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=$($passwords['REDIS_PASSWORD'])
REDIS_URL=redis://:$($passwords['REDIS_PASSWORD'])@localhost:6379/0
# For Docker Compose (internal network)
# REDIS_HOST=redis
# REDIS_URL=redis://:$($passwords['REDIS_PASSWORD'])@redis:6379/0
# ========================================
# Security
# ========================================
JWT_SECRET=$($passwords['JWT_SECRET'])
ENCRYPTION_KEY=$($passwords['ENCRYPTION_KEY'])
ALLOWED_ORIGINS=$($passwords['ALLOWED_ORIGINS'])
# ========================================
# AI Configuration (optional)
# ========================================
# Supported providers: mock, deepseek, zhipu, openai, ollama
AI_PROVIDER=mock
AI_API_KEY=
AI_API_URL=
AI_MODEL=
AI_ENABLED=false
# Example configurations for different AI providers:
# DeepSeek: AI_PROVIDER=deepseek, AI_API_KEY=sk-xxx, AI_API_URL=https://api.deepseek.com/v1/chat/completions, AI_MODEL=deepseek-chat
# OpenAI: AI_PROVIDER=openai, AI_API_KEY=sk-xxx, AI_API_URL=https://api.openai.com/v1/chat/completions, AI_MODEL=gpt-3.5-turbo
# Zhipu: AI_PROVIDER=zhipu, AI_API_KEY=xxx, AI_API_URL=https://open.bigmodel.cn/api/paas/v4/chat/completions, AI_MODEL=glm-4
# Ollama: AI_PROVIDER=ollama, AI_API_URL=http://localhost:11434/api/generate, AI_MODEL=llama2
# ========================================
# OAuth Configuration (optional)
# ========================================
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id_here
GOOGLE_CLIENT_SECRET=your_google_client_secret_here
# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
"@
$envContent | Out-File -FilePath ".env" -Encoding UTF8
Write-Host ".env file created successfully!" -ForegroundColor Green
Write-Host ""
# ========================================
# Display summary
# ========================================
Write-Host ""
Write-Host "Password generation completed!" -ForegroundColor Green
Write-Host ""
Write-Host "Generated files:" -ForegroundColor Cyan
Write-Host " • .env - Environment variables for all services" -ForegroundColor White
Write-Host ""
Write-Host "Generated passwords:" -ForegroundColor Cyan
Write-Host " • PostgreSQL: $($passwords['POSTGRES_PASSWORD'].Substring(0,8))..." -ForegroundColor White
Write-Host " • MySQL: $($passwords['MYSQL_PASSWORD'].Substring(0,8))..." -ForegroundColor White
Write-Host " • MongoDB: $($passwords['MONGO_INITDB_ROOT_PASSWORD'].Substring(0,8))..." -ForegroundColor White
Write-Host " • Redis: $($passwords['REDIS_PASSWORD'].Substring(0,8))..." -ForegroundColor White
Write-Host " • JWT Secret: $($passwords['JWT_SECRET'].Substring(0,16))..." -ForegroundColor White
Write-Host ""
Write-Host "IMPORTANT SECURITY NOTES:" -ForegroundColor Red
Write-Host " • All passwords use alphanumeric characters (a-z, A-Z, 0-9)" -ForegroundColor Yellow
Write-Host " • Change OAuth client IDs and secrets in .env if needed" -ForegroundColor Yellow
Write-Host " • Keep .env file secure and never commit to version control" -ForegroundColor Yellow
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host " 1. Review and update OAuth settings in .env if needed" -ForegroundColor White
Write-Host " 2. Run: docker compose -f docker-compose.prod.yml up -d" -ForegroundColor White
Write-Host " 3. Access: http://localhost:8383" -ForegroundColor White
Write-Host ""