mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-28 07:46:36 +00:00
pull hostname from dashboard url in crowdsec install
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -21,9 +22,9 @@ import (
|
|||||||
|
|
||||||
// DO NOT EDIT THIS FUNCTION; IT MATCHED BY REGEX IN CICD
|
// DO NOT EDIT THIS FUNCTION; IT MATCHED BY REGEX IN CICD
|
||||||
func loadVersions(config *Config) {
|
func loadVersions(config *Config) {
|
||||||
config.PangolinVersion = "1.9.4"
|
config.PangolinVersion = "replaceme"
|
||||||
config.GerbilVersion = "1.2.1"
|
config.GerbilVersion = "replaceme"
|
||||||
config.BadgerVersion = "1.2.0"
|
config.BadgerVersion = "replaceme"
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed config/*
|
//go:embed config/*
|
||||||
@@ -48,9 +49,9 @@ type Config struct {
|
|||||||
TraefikBouncerKey string
|
TraefikBouncerKey string
|
||||||
DoCrowdsecInstall bool
|
DoCrowdsecInstall bool
|
||||||
Secret string
|
Secret string
|
||||||
HybridMode bool
|
HybridMode bool
|
||||||
HybridId string
|
HybridId string
|
||||||
HybridSecret string
|
HybridSecret string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SupportedContainer string
|
type SupportedContainer string
|
||||||
@@ -190,7 +191,13 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
config.DashboardDomain = appConfig.DashboardURL
|
parsedURL, err := url.Parse(appConfig.DashboardURL)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error parsing URL: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
config.DashboardDomain = parsedURL.Hostname()
|
||||||
config.LetsEncryptEmail = traefikConfig.LetsEncryptEmail
|
config.LetsEncryptEmail = traefikConfig.LetsEncryptEmail
|
||||||
config.BadgerVersion = traefikConfig.BadgerVersion
|
config.BadgerVersion = traefikConfig.BadgerVersion
|
||||||
|
|
||||||
@@ -205,17 +212,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.InstallationContainerType = podmanOrDocker(reader)
|
config.InstallationContainerType = podmanOrDocker(reader)
|
||||||
|
|
||||||
config.DoCrowdsecInstall = true
|
config.DoCrowdsecInstall = true
|
||||||
err := installCrowdsec(config)
|
err := installCrowdsec(config)
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
fmt.Printf("Error installing CrowdSec: %v\n", err)
|
fmt.Printf("Error installing CrowdSec: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("CrowdSec installed successfully!")
|
fmt.Println("CrowdSec installed successfully!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,12 +544,12 @@ func printSetupToken(containerType SupportedContainer, dashboardDomain string) {
|
|||||||
tokenStart := strings.Index(trimmedLine, "Token:")
|
tokenStart := strings.Index(trimmedLine, "Token:")
|
||||||
if tokenStart != -1 {
|
if tokenStart != -1 {
|
||||||
token := strings.TrimSpace(trimmedLine[tokenStart+6:])
|
token := strings.TrimSpace(trimmedLine[tokenStart+6:])
|
||||||
fmt.Printf("Setup token: %s\n", token)
|
fmt.Printf("Setup token: %s\n", token)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println("This token is required to register the first admin account in the web UI at:")
|
fmt.Println("This token is required to register the first admin account in the web UI at:")
|
||||||
fmt.Printf("https://%s/auth/initial-setup\n", dashboardDomain)
|
fmt.Printf("https://%s/auth/initial-setup\n", dashboardDomain)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println("Save this token securely. It will be invalid after the first admin is created.")
|
fmt.Println("Save this token securely. It will be invalid after the first admin is created.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -634,21 +641,21 @@ func run(name string, args ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkPortsAvailable(port int) error {
|
func checkPortsAvailable(port int) error {
|
||||||
addr := fmt.Sprintf(":%d", port)
|
addr := fmt.Sprintf(":%d", port)
|
||||||
ln, err := net.Listen("tcp", addr)
|
ln, err := net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"ERROR: port %d is occupied or cannot be bound: %w\n\n",
|
"ERROR: port %d is occupied or cannot be bound: %w\n\n",
|
||||||
port, err,
|
port, err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if closeErr := ln.Close(); closeErr != nil {
|
if closeErr := ln.Close(); closeErr != nil {
|
||||||
fmt.Fprintf(os.Stderr,
|
fmt.Fprintf(os.Stderr,
|
||||||
"WARNING: failed to close test listener on port %d: %v\n",
|
"WARNING: failed to close test listener on port %d: %v\n",
|
||||||
port, closeErr,
|
port, closeErr,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkIsPangolinInstalledWithHybrid() bool {
|
func checkIsPangolinInstalledWithHybrid() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user