mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-28 21:58:15 +02:00
prompt for convert node in installer
This commit is contained in:
parent
117062f1d1
commit
cd34820138
1 changed files with 37 additions and 7 deletions
|
@ -215,7 +215,7 @@ func main() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Looks like you already installed, so I am going to do the setup...")
|
fmt.Println("Looks like you already installed, so I am going to do the setup...")
|
||||||
|
|
||||||
// Read existing config to get DashboardDomain
|
// Read existing config to get DashboardDomain
|
||||||
traefikConfig, err := ReadTraefikConfig("config/traefik/traefik_config.yml", "config/traefik/dynamic_config.yml")
|
traefikConfig, err := ReadTraefikConfig("config/traefik/traefik_config.yml", "config/traefik/dynamic_config.yml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -226,19 +226,28 @@ func main() {
|
||||||
config.DashboardDomain = traefikConfig.DashboardDomain
|
config.DashboardDomain = traefikConfig.DashboardDomain
|
||||||
config.LetsEncryptEmail = traefikConfig.LetsEncryptEmail
|
config.LetsEncryptEmail = traefikConfig.LetsEncryptEmail
|
||||||
config.BadgerVersion = traefikConfig.BadgerVersion
|
config.BadgerVersion = traefikConfig.BadgerVersion
|
||||||
|
|
||||||
// Show detected values and allow user to confirm or re-enter
|
// Show detected values and allow user to confirm or re-enter
|
||||||
fmt.Println("Detected existing configuration:")
|
fmt.Println("Detected existing configuration:")
|
||||||
fmt.Printf("Dashboard Domain: %s\n", config.DashboardDomain)
|
fmt.Printf("Dashboard Domain: %s\n", config.DashboardDomain)
|
||||||
fmt.Printf("Let's Encrypt Email: %s\n", config.LetsEncryptEmail)
|
fmt.Printf("Let's Encrypt Email: %s\n", config.LetsEncryptEmail)
|
||||||
fmt.Printf("Badger Version: %s\n", config.BadgerVersion)
|
fmt.Printf("Badger Version: %s\n", config.BadgerVersion)
|
||||||
|
|
||||||
if !readBool(reader, "Are these values correct?", true) {
|
if !readBool(reader, "Are these values correct?", true) {
|
||||||
config = collectUserInput(reader)
|
config = collectUserInput(reader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if Pangolin is already installed with hybrid section
|
||||||
|
if checkIsPangolinInstalledWithHybrid() {
|
||||||
|
fmt.Println("\n=== Convert to Self-Host Node ===")
|
||||||
|
if readBool(reader, "Do you want to convert this Pangolin instance into a manage self-host node?", true) {
|
||||||
|
fmt.Println("hello world")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !checkIsCrowdsecInstalledInCompose() {
|
if !checkIsCrowdsecInstalledInCompose() {
|
||||||
fmt.Println("\n=== CrowdSec Install ===")
|
fmt.Println("\n=== CrowdSec Install ===")
|
||||||
// check if crowdsec is installed
|
// check if crowdsec is installed
|
||||||
|
@ -276,7 +285,7 @@ func main() {
|
||||||
|
|
||||||
// Setup Token Section
|
// Setup Token Section
|
||||||
fmt.Println("\n=== Setup Token ===")
|
fmt.Println("\n=== Setup Token ===")
|
||||||
|
|
||||||
// Check if containers were started during this installation
|
// Check if containers were started during this installation
|
||||||
containersStarted := false
|
containersStarted := false
|
||||||
if (isDockerInstalled() && chosenContainer == Docker) ||
|
if (isDockerInstalled() && chosenContainer == Docker) ||
|
||||||
|
@ -285,7 +294,7 @@ func main() {
|
||||||
containersStarted = true
|
containersStarted = true
|
||||||
printSetupToken(chosenContainer, config.DashboardDomain)
|
printSetupToken(chosenContainer, config.DashboardDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If containers weren't started or token wasn't found, show instructions
|
// If containers weren't started or token wasn't found, show instructions
|
||||||
if !containersStarted {
|
if !containersStarted {
|
||||||
showSetupTokenInstructions(chosenContainer, config.DashboardDomain)
|
showSetupTokenInstructions(chosenContainer, config.DashboardDomain)
|
||||||
|
@ -354,7 +363,7 @@ func collectUserInput(reader *bufio.Reader) Config {
|
||||||
// Basic configuration
|
// Basic configuration
|
||||||
fmt.Println("\n=== Basic Configuration ===")
|
fmt.Println("\n=== Basic Configuration ===")
|
||||||
config.BaseDomain = readString(reader, "Enter your base domain (no subdomain e.g. example.com)", "")
|
config.BaseDomain = readString(reader, "Enter your base domain (no subdomain e.g. example.com)", "")
|
||||||
|
|
||||||
// Set default dashboard domain after base domain is collected
|
// Set default dashboard domain after base domain is collected
|
||||||
defaultDashboardDomain := ""
|
defaultDashboardDomain := ""
|
||||||
if config.BaseDomain != "" {
|
if config.BaseDomain != "" {
|
||||||
|
@ -816,7 +825,7 @@ func waitForContainer(containerName string, containerType SupportedContainer) er
|
||||||
|
|
||||||
func printSetupToken(containerType SupportedContainer, dashboardDomain string) {
|
func printSetupToken(containerType SupportedContainer, dashboardDomain string) {
|
||||||
fmt.Println("Waiting for Pangolin to generate setup token...")
|
fmt.Println("Waiting for Pangolin to generate setup token...")
|
||||||
|
|
||||||
// Wait for Pangolin to be healthy
|
// Wait for Pangolin to be healthy
|
||||||
if err := waitForContainer("pangolin", containerType); err != nil {
|
if err := waitForContainer("pangolin", containerType); err != nil {
|
||||||
fmt.Println("Warning: Pangolin container did not become healthy in time.")
|
fmt.Println("Warning: Pangolin container did not become healthy in time.")
|
||||||
|
@ -938,3 +947,24 @@ func checkPortsAvailable(port int) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkIsPangolinInstalledWithHybrid() bool {
|
||||||
|
// Check if docker-compose.yml exists (indicating Pangolin is installed)
|
||||||
|
if _, err := os.Stat("docker-compose.yml"); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if config/config.yml exists and contains hybrid section
|
||||||
|
if _, err := os.Stat("config/config.yml"); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read config file to check for hybrid section
|
||||||
|
content, err := os.ReadFile("config/config.yml")
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for hybrid section
|
||||||
|
return bytes.Contains(content, []byte("hybrid:"))
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue