From 2ef2ce0a4b5a596834219dd9cfa4e9c5c95eac34 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 5 Dec 2025 12:19:28 -0500 Subject: [PATCH] [FIX]: NetVisor daemon auto-config (#9682) --- ct/netvisor.sh | 3 ++- frontend/public/json/netvisor.json | 4 ++-- install/netvisor-install.sh | 32 ++++++++++++++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ct/netvisor.sh b/ct/netvisor.sh index c51985fd25..696bca21c4 100644 --- a/ct/netvisor.sh +++ b/ct/netvisor.sh @@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV # Copyright (c) 2021-2025 community-scripts ORG # Author: vhsdream # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://github.com/maynayza/netvisor +# Source: https://github.com/mayanayza/netvisor APP="NetVisor" var_tags="${var_tags:-analytics}" @@ -99,3 +99,4 @@ msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:60072${CL}" +echo -e "${INFO}${YW} Then create your account, and run the 'configure_daemon.sh' script to setup the daemon.${CL}" diff --git a/frontend/public/json/netvisor.json b/frontend/public/json/netvisor.json index 4da83eb8a8..b9dc43baed 100644 --- a/frontend/public/json/netvisor.json +++ b/frontend/public/json/netvisor.json @@ -33,11 +33,11 @@ }, "notes": [ { - "text": "The integrated daemon config is located at `/root/.config/daemon/config.json`", + "text": "To configure the integrated daemon after install is complete, either use the `Create Daemon` menu in the UI, or run `/root/configure_daemon.sh` for automatic configuration", "type": "info" }, { - "text": "When using a reverse proxy, edit `/opt/netvisor/ui/build/_app/env.js`: add 443 to `PUBLIC_SERVER_PORT` and remove 'default' from `PUBLIC_SERVER_HOSTNAME`.", + "text": "The integrated daemon config is located at `/root/.config/daemon/config.json`", "type": "info" } ] diff --git a/install/netvisor-install.sh b/install/netvisor-install.sh index fee67a940a..af8d8fe439 100644 --- a/install/netvisor-install.sh +++ b/install/netvisor-install.sh @@ -48,7 +48,7 @@ $STD cargo build --release --bin daemon cp ./target/release/daemon /usr/bin/netvisor-daemon msg_ok "Built Netvisor-daemon" -msg_info "Configuring server & daemon for first-run" +msg_info "Configuring server for first-run" LOCAL_IP="$(hostname -I | awk '{print $1}')" cat </opt/netvisor/.env ### - SERVER @@ -101,19 +101,26 @@ WantedBy=multi-user.target EOF systemctl enable -q --now netvisor-server -sleep 5 -NETWORK_ID="$(sudo -u postgres psql -1 -t -d $PG_DB_NAME -c 'SELECT id FROM networks;')" -API_KEY="$(sudo -u postgres psql -1 -t -d $PG_DB_NAME -c 'SELECT key from api_keys;')" -cat </etc/systemd/system/netvisor-daemon.service +# Creating short script to configure netvisor-daemon +cat <~/configure_daemon.sh +#!/usr/bin/env bash + +echo "Auto-configuring integrated daemon..." + +NETWORK_ID="\$(sudo -u postgres psql -1 -t -d "${PG_DB_NAME}" -c 'SELECT id FROM networks;')" +API_KEY="\$(sudo -u postgres psql -1 -t -d "${PG_DB_NAME}" -c 'SELECT key FROM api_keys;')" + +cat </etc/systemd/system/netvisor-daemon.service [Unit] Description=NetVisor Network Discovery Daemon -After=network.target netvisor-server.service +After=network-online.target +Wants=network-online.target [Service] Type=simple -EnvironmentFile=/opt/netvisor/.env -ExecStart=/usr/bin/netvisor-daemon --server-url http://127.0.0.1:60072 --network-id ${NETWORK_ID} --daemon-api-key ${API_KEY} +User=root +ExecStart=/usr/bin/netvisor-daemon --server-url http://127.0.0.1:60072 --network-id \${NETWORK_ID} --daemon-api-key \${API_KEY} --mode push Restart=always RestartSec=10 StandardOutput=journal @@ -121,9 +128,14 @@ StandardError=journal [Install] WantedBy=multi-user.target -EOF +END + systemctl enable -q --now netvisor-daemon -msg_ok "Netvisor server & daemon configured and running" +echo "NetVisor daemon configured and running" + +EOF +chmod +x ~/configure_daemon.sh +msg_ok "Netvisor server running - please create an account in the UI to continue." motd_ssh customize