Skip to content

Commit 09fdccd

Browse files
vhsdreamprobers1
authored andcommitted
[FIX]: NetVisor daemon auto-config (community-scripts#9682)
1 parent 11bd92a commit 09fdccd

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

ct/netvisor.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
33
# Copyright (c) 2021-2025 community-scripts ORG
44
# Author: vhsdream
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://github.com/maynayza/netvisor
6+
# Source: https://github.com/mayanayza/netvisor
77

88
APP="NetVisor"
99
var_tags="${var_tags:-analytics}"
@@ -99,3 +99,4 @@ msg_ok "Completed Successfully!\n"
9999
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
100100
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
101101
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:60072${CL}"
102+
echo -e "${INFO}${YW} Then create your account, and run the 'configure_daemon.sh' script to setup the daemon.${CL}"

frontend/public/json/netvisor.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
},
3434
"notes": [
3535
{
36-
"text": "The integrated daemon config is located at `/root/.config/daemon/config.json`",
36+
"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",
3737
"type": "info"
3838
},
3939
{
40-
"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`.",
40+
"text": "The integrated daemon config is located at `/root/.config/daemon/config.json`",
4141
"type": "info"
4242
}
4343
]

install/netvisor-install.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $STD cargo build --release --bin daemon
4848
cp ./target/release/daemon /usr/bin/netvisor-daemon
4949
msg_ok "Built Netvisor-daemon"
5050

51-
msg_info "Configuring server & daemon for first-run"
51+
msg_info "Configuring server for first-run"
5252
LOCAL_IP="$(hostname -I | awk '{print $1}')"
5353
cat <<EOF >/opt/netvisor/.env
5454
### - SERVER
@@ -101,29 +101,41 @@ WantedBy=multi-user.target
101101
EOF
102102

103103
systemctl enable -q --now netvisor-server
104-
sleep 5
105-
NETWORK_ID="$(sudo -u postgres psql -1 -t -d $PG_DB_NAME -c 'SELECT id FROM networks;')"
106-
API_KEY="$(sudo -u postgres psql -1 -t -d $PG_DB_NAME -c 'SELECT key from api_keys;')"
107104

108-
cat <<EOF >/etc/systemd/system/netvisor-daemon.service
105+
# Creating short script to configure netvisor-daemon
106+
cat <<EOF >~/configure_daemon.sh
107+
#!/usr/bin/env bash
108+
109+
echo "Auto-configuring integrated daemon..."
110+
111+
NETWORK_ID="\$(sudo -u postgres psql -1 -t -d "${PG_DB_NAME}" -c 'SELECT id FROM networks;')"
112+
API_KEY="\$(sudo -u postgres psql -1 -t -d "${PG_DB_NAME}" -c 'SELECT key FROM api_keys;')"
113+
114+
cat <<END >/etc/systemd/system/netvisor-daemon.service
109115
[Unit]
110116
Description=NetVisor Network Discovery Daemon
111-
After=network.target netvisor-server.service
117+
After=network-online.target
118+
Wants=network-online.target
112119
113120
[Service]
114121
Type=simple
115-
EnvironmentFile=/opt/netvisor/.env
116-
ExecStart=/usr/bin/netvisor-daemon --server-url http://127.0.0.1:60072 --network-id ${NETWORK_ID} --daemon-api-key ${API_KEY}
122+
User=root
123+
ExecStart=/usr/bin/netvisor-daemon --server-url http://127.0.0.1:60072 --network-id \${NETWORK_ID} --daemon-api-key \${API_KEY} --mode push
117124
Restart=always
118125
RestartSec=10
119126
StandardOutput=journal
120127
StandardError=journal
121128
122129
[Install]
123130
WantedBy=multi-user.target
124-
EOF
131+
END
132+
125133
systemctl enable -q --now netvisor-daemon
126-
msg_ok "Netvisor server & daemon configured and running"
134+
echo "NetVisor daemon configured and running"
135+
136+
EOF
137+
chmod +x ~/configure_daemon.sh
138+
msg_ok "Netvisor server running - please create an account in the UI to continue."
127139

128140
motd_ssh
129141
customize

0 commit comments

Comments
 (0)