Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions dream-server/installers/phases/01-preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Dream Server Installer — Phase 01: Pre-flight Checks
# ============================================================================
# Part of: installers/phases/
# Purpose: Root/OS/tools checks, existing installation check
# Purpose: Root/OS/tools checks, existing installation detection
#
# Expects: SCRIPT_DIR, INSTALL_DIR, LOG_FILE, INTERACTIVE, DRY_RUN, FORCE,
# Expects: SCRIPT_DIR, INSTALL_DIR, LOG_FILE, INTERACTIVE, DRY_RUN,
# PKG_MANAGER,
# show_phase(), ai(), ai_ok(), signal(), log(), warn(), error()
# Provides: OS sourced from /etc/os-release, OPTIONAL_TOOLS_MISSING
Expand Down Expand Up @@ -65,21 +65,10 @@ if [[ ! -f "$SCRIPT_DIR/docker-compose.yml" ]] && [[ ! -f "$SCRIPT_DIR/docker-co
error "No compose files found in $SCRIPT_DIR. Please run from the dream-server directory."
fi

# Check for existing installation
if [[ -d "$INSTALL_DIR" && "$FORCE" != "true" ]]; then
if $INTERACTIVE && ! $DRY_RUN; then
warn "Existing installation found at $INSTALL_DIR"
read -p " Overwrite and start fresh? [y/N] " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
log "User chose to overwrite existing installation"
FORCE=true
else
log "User chose not to overwrite. Exiting."
exit 0
fi
else
error "Installation already exists at $INSTALL_DIR. Use --force to overwrite."
fi
# Existing installation — update in place (secrets and data are preserved)
if [[ -d "$INSTALL_DIR" ]]; then
log "Existing installation found at $INSTALL_DIR — updating in place"
signal "Existing install detected. Secrets and data will be preserved."
fi

ai_ok "Pre-flight checks passed."
Expand Down
43 changes: 31 additions & 12 deletions dream-server/installers/windows/lib/env-generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,34 @@ function New-DreamEnv {
[string]$LlamaServerImage = ""
)

# Generate secrets
$webuiSecret = New-SecureHex -Bytes 32
$n8nPass = New-SecureBase64 -Bytes 16
$litellmKey = "sk-dream-$(New-SecureHex -Bytes 16)"
$livekitSecret = New-SecureBase64 -Bytes 32
$livekitApiKey = New-SecureHex -Bytes 16
$dashboardApiKey = New-SecureHex -Bytes 32
$openclawToken = New-SecureHex -Bytes 24
$searxngSecret = New-SecureHex -Bytes 32
# Preserve existing secrets on re-install (mirrors Linux _env_get logic)
$existingEnv = @{}
$envPath = Join-Path $InstallDir ".env"
if (Test-Path $envPath) {
Get-Content $envPath | ForEach-Object {
if ($_ -match "^([A-Za-z_][A-Za-z0-9_]*)=(.*)$") {
$existingEnv[$Matches[1]] = $Matches[2]
}
}
}

# Helper: reuse existing value or generate new
function Get-EnvOrNew { param([string]$Key, [string]$Default)
if ($existingEnv.ContainsKey($Key) -and $existingEnv[$Key]) {
return $existingEnv[$Key]
}
return $Default
}

# Generate secrets (reuse existing on re-install)
$webuiSecret = Get-EnvOrNew "WEBUI_SECRET" (New-SecureHex -Bytes 32)
$n8nPass = Get-EnvOrNew "N8N_PASS" (New-SecureBase64 -Bytes 16)
$litellmKey = Get-EnvOrNew "LITELLM_KEY" "sk-dream-$(New-SecureHex -Bytes 16)"
$livekitSecret = Get-EnvOrNew "LIVEKIT_API_SECRET" (New-SecureBase64 -Bytes 32)
$livekitApiKey = Get-EnvOrNew "LIVEKIT_API_KEY" (New-SecureHex -Bytes 16)
$dashboardApiKey = Get-EnvOrNew "DASHBOARD_API_KEY" (New-SecureHex -Bytes 32)
$openclawToken = Get-EnvOrNew "OPENCLAW_TOKEN" (New-SecureHex -Bytes 24)
$searxngSecret = Get-EnvOrNew "SEARXNG_SECRET" (New-SecureHex -Bytes 32)

# Determine LLM API URL based on backend
# AMD on Windows: llama-server runs natively, containers reach it via host.docker.internal
Expand Down Expand Up @@ -154,9 +173,9 @@ DREAM_MODE=$DreamMode
LLM_API_URL=$llmApiUrl

#=== Cloud API Keys ===
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
TOGETHER_API_KEY=
ANTHROPIC_API_KEY=$(Get-EnvOrNew "ANTHROPIC_API_KEY" "")
OPENAI_API_KEY=$(Get-EnvOrNew "OPENAI_API_KEY" "")
TOGETHER_API_KEY=$(Get-EnvOrNew "TOGETHER_API_KEY" "")

#=== LLM Settings (llama-server) ===
LLM_MODEL=$($TierConfig.LlmModel)
Expand Down
Loading