Added nyx auto install with anyone relay

This commit is contained in:
anonpenguin23 2026-01-29 10:23:40 +02:00
parent 15ecf366d5
commit d6106bcbb8
2 changed files with 28 additions and 29 deletions

View File

@ -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
}

View File

@ -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:")