[FIX]: NetVisor daemon auto-config (#9682)
This commit is contained in:
parent
6dc73981d9
commit
2ef2ce0a4b
@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
|||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: vhsdream
|
# Author: vhsdream
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# 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"
|
APP="NetVisor"
|
||||||
var_tags="${var_tags:-analytics}"
|
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 "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:60072${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}"
|
||||||
|
|||||||
@ -33,11 +33,11 @@
|
|||||||
},
|
},
|
||||||
"notes": [
|
"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"
|
"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"
|
"type": "info"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -48,7 +48,7 @@ $STD cargo build --release --bin daemon
|
|||||||
cp ./target/release/daemon /usr/bin/netvisor-daemon
|
cp ./target/release/daemon /usr/bin/netvisor-daemon
|
||||||
msg_ok "Built 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}')"
|
LOCAL_IP="$(hostname -I | awk '{print $1}')"
|
||||||
cat <<EOF >/opt/netvisor/.env
|
cat <<EOF >/opt/netvisor/.env
|
||||||
### - SERVER
|
### - SERVER
|
||||||
@ -101,19 +101,26 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl enable -q --now netvisor-server
|
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]
|
[Unit]
|
||||||
Description=NetVisor Network Discovery Daemon
|
Description=NetVisor Network Discovery Daemon
|
||||||
After=network.target netvisor-server.service
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
EnvironmentFile=/opt/netvisor/.env
|
User=root
|
||||||
ExecStart=/usr/bin/netvisor-daemon --server-url http://127.0.0.1:60072 --network-id ${NETWORK_ID} --daemon-api-key ${API_KEY}
|
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
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
@ -121,9 +128,14 @@ StandardError=journal
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
END
|
||||||
|
|
||||||
systemctl enable -q --now netvisor-daemon
|
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
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user