mirror of
https://github.com/DeBrosOfficial/orama.git
synced 2026-03-17 11:26:58 +00:00
67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
package install
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// Handle executes the install command
|
|
func Handle(args []string) {
|
|
// Parse flags
|
|
flags, err := ParseFlags(args)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Resolve base domain interactively if not provided (before local/VPS branch)
|
|
if flags.BaseDomain == "" {
|
|
flags.BaseDomain = promptForBaseDomain()
|
|
}
|
|
|
|
// Local mode: not running as root → orchestrate install via SSH
|
|
if os.Geteuid() != 0 {
|
|
remote, err := NewRemoteOrchestrator(flags)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
if err := remote.Execute(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
return
|
|
}
|
|
|
|
// VPS mode: running as root on the VPS — existing behavior
|
|
orchestrator, err := NewOrchestrator(flags)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Validate flags
|
|
if err := orchestrator.validator.ValidateFlags(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ Error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Check port availability before proceeding
|
|
if err := orchestrator.validator.ValidatePorts(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Validate Anyone relay configuration if enabled
|
|
if err := orchestrator.validator.ValidateAnyoneRelayFlags(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Execute installation
|
|
if err := orchestrator.Execute(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|