chore: update version and enhance bootstrap configuration in setup

- Incremented version in Makefile to 0.52.7.
- Refactored the `generateConfigsInteractive` function to streamline the setup for single-node VPS configurations.
- Removed user prompts for bootstrap peers and join address, simplifying the configuration process.
- Added explicit commands for generating bootstrap and gateway configurations with improved error handling and output messages.
This commit is contained in:
anonpenguin23 2025-10-26 11:20:10 +02:00
parent a9ac3fcb83
commit ddebb03aa6
No known key found for this signature in database
GPG Key ID: 1CBB1FE35AFBEE30
2 changed files with 48 additions and 54 deletions

View File

@ -21,7 +21,7 @@ test-e2e:
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports
VERSION := 0.52.6 VERSION := 0.52.7
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'

View File

@ -402,71 +402,65 @@ func cloneAndBuild() {
func generateConfigsInteractive(force bool) { func generateConfigsInteractive(force bool) {
fmt.Printf("⚙️ Generating configurations...\n") fmt.Printf("⚙️ Generating configurations...\n")
// Prompt for bootstrap peers // For single-node VPS setup, use sensible defaults
// This creates a bootstrap node that acts as the cluster leader
fmt.Printf("\n") fmt.Printf("\n")
fmt.Printf("Enter bootstrap peer multiaddresses (one per line, empty line to finish):\n") fmt.Printf("Setting up single-node configuration...\n")
fmt.Printf("Format: /ip4/<IP>/tcp/<PORT>/p2p/<PEER_ID>\n") fmt.Printf(" • Bootstrap node (cluster leader)\n")
fmt.Printf("Example: /ip4/127.0.0.1/tcp/4001/p2p/12D3Koo...\n\n") fmt.Printf(" • No external peers required\n")
fmt.Printf(" • Gateway connected to local node\n\n")
reader := bufio.NewReader(os.Stdin) // Generate bootstrap node config with explicit parameters
var bootstrapPeers []string // Pass empty bootstrap-peers and no join address for bootstrap node
for { bootstrapArgs := []string{
fmt.Printf("Bootstrap peer: ") "-u", "debros",
line, _ := reader.ReadString('\n')
line = strings.TrimSpace(line)
if line == "" {
break
}
if !isValidMultiaddr(line) {
fmt.Printf("❌ Invalid multiaddr format. Must start with /ip4 or /ip6 and contain /p2p/\n")
continue
}
bootstrapPeers = append(bootstrapPeers, line)
fmt.Printf("✓ Added peer\n")
}
// Prompt for RQLite join address with validation
var joinAddr string
for {
fmt.Printf("\nEnter RQLite join address (host:port, e.g., 10.0.1.5:7001): ")
input, _ := reader.ReadString('\n')
joinAddr = strings.TrimSpace(input)
if joinAddr == "" {
fmt.Printf("⚠️ Join address is required\n")
continue
}
if !isValidHostPort(joinAddr) {
fmt.Printf("❌ Invalid host:port format\n")
continue
}
break
}
// Generate configs using network-cli
bootstrapPeersStr := strings.Join(bootstrapPeers, ",")
args := []string{
"/home/debros/bin/network-cli", "config", "init", "/home/debros/bin/network-cli", "config", "init",
"--type", "node", "--type", "bootstrap",
"--bootstrap-peers", bootstrapPeersStr, "--bootstrap-peers", "",
"--join", joinAddr,
} }
if force { if force {
args = append(args, "--force") bootstrapArgs = append(bootstrapArgs, "--force")
} }
cmd := exec.Command("sudo", append([]string{"-u", "debros"}, args...)...) cmd := exec.Command("sudo", bootstrapArgs...)
if err := cmd.Run(); err != nil { cmd.Stdin = nil // Explicitly close stdin to prevent interactive prompts
fmt.Fprintf(os.Stderr, "⚠️ Failed to generate node config: %v\n", err) output, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "⚠️ Failed to generate bootstrap config: %v\n", err)
if len(output) > 0 {
fmt.Fprintf(os.Stderr, " Output: %s\n", string(output))
}
} else {
fmt.Printf(" ✓ Bootstrap node config created\n")
} }
// Generate gateway config // Rename bootstrap.yaml to node.yaml so the service can find it
cmd = exec.Command("sudo", "-u", "debros", "/home/debros/bin/network-cli", "config", "init", "--type", "gateway", "--bootstrap-peers", bootstrapPeersStr) renameCmd := exec.Command("sudo", "-u", "debros", "mv", "/home/debros/.debros/bootstrap.yaml", "/home/debros/.debros/node.yaml")
if err := renameCmd.Run(); err != nil {
fmt.Fprintf(os.Stderr, "⚠️ Failed to rename config: %v\n", err)
}
// Generate gateway config with explicit empty bootstrap peers
gatewayArgs := []string{
"-u", "debros",
"/home/debros/bin/network-cli", "config", "init",
"--type", "gateway",
"--bootstrap-peers", "",
}
if force { if force {
cmd.Args = append(cmd.Args, "--force") gatewayArgs = append(gatewayArgs, "--force")
} }
if err := cmd.Run(); err != nil {
cmd = exec.Command("sudo", gatewayArgs...)
cmd.Stdin = nil // Explicitly close stdin to prevent interactive prompts
output, err = cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "⚠️ Failed to generate gateway config: %v\n", err) fmt.Fprintf(os.Stderr, "⚠️ Failed to generate gateway config: %v\n", err)
if len(output) > 0 {
fmt.Fprintf(os.Stderr, " Output: %s\n", string(output))
}
} else {
fmt.Printf(" ✓ Gateway config created\n")
} }
fmt.Printf(" ✓ Configurations generated\n") fmt.Printf(" ✓ Configurations generated\n")