From d6106bcbb8a32f519ca3a028a49d58ca39c0e249 Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Thu, 29 Jan 2026 10:23:40 +0200 Subject: [PATCH] Added nyx auto install with anyone relay --- .../production/installers/anyone_relay.go | 24 ++++++++++++++ pkg/environments/production/orchestrator.go | 33 +++---------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/pkg/environments/production/installers/anyone_relay.go b/pkg/environments/production/installers/anyone_relay.go index c0b8178..b38ecda 100644 --- a/pkg/environments/production/installers/anyone_relay.go +++ b/pkg/environments/production/installers/anyone_relay.go @@ -181,6 +181,30 @@ func (ari *AnyoneRelayInstaller) Install() error { os.Remove(installScript) fmt.Fprintf(ari.logWriter, " ✓ Anyone relay binary installed\n") + + // Install nyx for relay monitoring (connects to ControlPort 9051) + if err := ari.installNyx(); err != nil { + fmt.Fprintf(ari.logWriter, " ⚠️ nyx install warning: %v\n", err) + } + + return nil +} + +// installNyx installs the nyx relay monitor tool +func (ari *AnyoneRelayInstaller) installNyx() error { + // Check if already installed + if _, err := exec.LookPath("nyx"); err == nil { + fmt.Fprintf(ari.logWriter, " ✓ nyx already installed\n") + return nil + } + + fmt.Fprintf(ari.logWriter, " Installing nyx (relay monitor)...\n") + cmd := exec.Command("apt-get", "install", "-y", "nyx") + if output, err := cmd.CombinedOutput(); err != nil { + return fmt.Errorf("failed to install nyx: %w\n%s", err, string(output)) + } + + fmt.Fprintf(ari.logWriter, " ✓ nyx installed (use 'nyx' to monitor relay on ControlPort 9051)\n") return nil } diff --git a/pkg/environments/production/orchestrator.go b/pkg/environments/production/orchestrator.go index 5e4a787..0740bff 100644 --- a/pkg/environments/production/orchestrator.go +++ b/pkg/environments/production/orchestrator.go @@ -336,11 +336,6 @@ func (ps *ProductionSetup) Phase2bInstallBinaries() error { if err := relayInstaller.Configure(); err != nil { ps.logf(" ⚠️ Anyone relay config warning: %v", err) } - } else { - // Install anyone-client for SOCKS5 proxy (default client mode) - if err := ps.binaryInstaller.InstallAnyoneClient(); err != nil { - ps.logf(" ⚠️ anyone-client install warning: %v", err) - } } // Install DeBros binaries (must be done before CoreDNS since we need the RQLite plugin source) @@ -614,19 +609,13 @@ func (ps *ProductionSetup) Phase5CreateSystemdServices(enableHTTPS bool) error { } ps.logf(" ✓ Node service created: debros-node.service (with embedded gateway)") - // Anyone service (Client or Relay based on configuration) + // Anyone Relay service (only created when --anyone-relay flag is used) if ps.IsAnyoneRelay() { anyoneUnit := ps.serviceGenerator.GenerateAnyoneRelayService() if err := ps.serviceController.WriteServiceUnit("debros-anyone-relay.service", anyoneUnit); err != nil { return fmt.Errorf("failed to write Anyone Relay service: %w", err) } ps.logf(" ✓ Anyone Relay service created (operator mode, ORPort: %d)", ps.anyoneRelayConfig.ORPort) - } else { - anyoneUnit := ps.serviceGenerator.GenerateAnyoneClientService() - if err := ps.serviceController.WriteServiceUnit("debros-anyone-client.service", anyoneUnit); err != nil { - return fmt.Errorf("failed to write Anyone Client service: %w", err) - } - ps.logf(" ✓ Anyone Client service created") } // CoreDNS and Caddy services (only for nameserver nodes) @@ -668,11 +657,9 @@ func (ps *ProductionSetup) Phase5CreateSystemdServices(enableHTTPS bool) error { // Note: debros-rqlite.service is NOT created - RQLite is managed by each node internally services := []string{"debros-ipfs.service", "debros-ipfs-cluster.service", "debros-olric.service", "debros-node.service"} - // Add appropriate Anyone service based on mode + // Add Anyone Relay service if configured if ps.IsAnyoneRelay() { services = append(services, "debros-anyone-relay.service") - } else { - services = append(services, "debros-anyone-client.service") } // Add CoreDNS and Caddy only for nameserver nodes @@ -698,9 +685,8 @@ func (ps *ProductionSetup) Phase5CreateSystemdServices(enableHTTPS bool) error { // Start infrastructure first (IPFS, Olric, Anyone) - RQLite is managed internally by each node infraServices := []string{"debros-ipfs.service", "debros-olric.service"} - // Add appropriate Anyone service based on mode + // Add Anyone Relay service if configured if ps.IsAnyoneRelay() { - // For relay mode, check if ORPort is already in use orPort := 9001 if ps.anyoneRelayConfig != nil && ps.anyoneRelayConfig.ORPort > 0 { orPort = ps.anyoneRelayConfig.ORPort @@ -711,14 +697,6 @@ func (ps *ProductionSetup) Phase5CreateSystemdServices(enableHTTPS bool) error { } else { infraServices = append(infraServices, "debros-anyone-relay.service") } - } else { - // For client mode, check if SOCKS port 9050 is already in use - if ps.portChecker.IsPortInUse(9050) { - ps.logf(" ℹ️ Port 9050 is already in use (anyone-client or similar service running)") - ps.logf(" ℹ️ Skipping debros-anyone-client startup - using existing service") - } else { - infraServices = append(infraServices, "debros-anyone-client.service") - } } for _, svc := range infraServices { @@ -826,11 +804,8 @@ func (ps *ProductionSetup) LogSetupComplete(peerID string) { ps.logf(" Register at: https://dashboard.anyone.io") ps.logf(" IMPORTANT: You need 100 $ANYONE tokens in your wallet to receive rewards") } else { - ps.logf(" %s/logs/anyone-client.log", ps.oramaDir) ps.logf("\nStart All Services:") - ps.logf(" systemctl start debros-ipfs debros-ipfs-cluster debros-olric debros-anyone-client debros-node") - ps.logf("\nAnyone Client:") - ps.logf(" # SOCKS5 proxy on localhost:9050") + ps.logf(" systemctl start debros-ipfs debros-ipfs-cluster debros-olric debros-node") } ps.logf("\nVerify Installation:")