[FIX]: NetVisor daemon auto-config (#9682)

This commit is contained in:
Chris 2025-12-05 12:19:28 -05:00 committed by GitHub
parent 6dc73981d9
commit 2ef2ce0a4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 13 deletions

View File

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

View File

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

View File

@ -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 <<EOF >/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 <<EOF >/etc/systemd/system/netvisor-daemon.service
# Creating short script to configure netvisor-daemon
cat <<EOF >~/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 <<END >/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