diff --git a/ct/netvisor.sh b/ct/netvisor.sh index 7ceb9ef71..77d5a96da 100644 --- a/ct/netvisor.sh +++ b/ct/netvisor.sh @@ -35,7 +35,7 @@ function update_script() { msg_ok "Stopped services" msg_info "Backing up configurations" - cp /opt/netvisor/.env /opt/netvisor.env + cp /opt/netvisor/.env /opt/netvisor.env.bak msg_ok "Backed up configurations" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "netvisor" "mayanayza/netvisor" "tarball" "latest" "/opt/netvisor" @@ -49,10 +49,16 @@ function update_script() { TOOLCHAIN="$(grep "channel" /opt/netvisor/backend/rust-toolchain.toml | awk -F\" '{print $2}')" RUST_TOOLCHAIN=$TOOLCHAIN setup_rust - mv /opt/netvisor.env /opt/netvisor/.env + cp /opt/netvisor.env.bak /opt/netvisor/.env + LOCAL_IP="$(hostname -I | awk '{print $1}')" + if ! grep -q "PUBLIC_URL"; then + sed -i "\|_PATH=|a\NETVISOR_SERVER_PUBLIC_URL=http://${LOCAL_IP}:60072" /opt/netvisor/.env + fi + sed -i 's|_TARGET=.*$|_URL=http://127.0.0.1:60072|' /opt/netvisor/.env + msg_info "Creating frontend UI" export PUBLIC_SERVER_HOSTNAME=default - export PUBLIC_SERVER_PORT=60072 + export PUBLIC_SERVER_PORT="" cd /opt/netvisor/ui $STD npm ci --no-fund --no-audit $STD npm run build @@ -64,10 +70,16 @@ function update_script() { mv ./target/release/server /usr/bin/netvisor-server msg_ok "Built Netvisor-server" - msg_info "Building Netvisor-daemon (amd64 version)" + msg_info "Building Netvisor-daemon" $STD cargo build --release --bin daemon cp ./target/release/daemon /usr/bin/netvisor-daemon - msg_ok "Built Netvisor-daemon (amd64 version)" + msg_ok "Built Netvisor-daemon" + + sed -i -e 's|-target|-url|' \ + -e 's| --server-port |:|' \ + /etc/systemd/system/netvisor-daemon.service + sed -i '/^ \"server_target.*$/d' /root/.config/daemon/config.json + systemctl daemon-reload msg_info "Starting services" systemctl start netvisor-server netvisor-daemon diff --git a/frontend/public/json/netvisor.json b/frontend/public/json/netvisor.json index c875de570..b4d4fb85f 100644 --- a/frontend/public/json/netvisor.json +++ b/frontend/public/json/netvisor.json @@ -35,6 +35,10 @@ { "text": "The integrated daemon config is located at `/root/.config/daemon/config.json`", "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`.", + "type": "info" } ] } diff --git a/install/netvisor-install.sh b/install/netvisor-install.sh index 2271d8d61..5d432035d 100644 --- a/install/netvisor-install.sh +++ b/install/netvisor-install.sh @@ -31,7 +31,7 @@ RUST_TOOLCHAIN=$TOOLCHAIN setup_rust msg_info "Creating frontend UI" export PUBLIC_SERVER_HOSTNAME=default -export PUBLIC_SERVER_PORT=60072 +export PUBLIC_SERVER_PORT="" cd /opt/netvisor/ui $STD npm ci --no-fund --no-audit $STD npm run build @@ -49,20 +49,18 @@ cp ./target/release/daemon /usr/bin/netvisor-daemon msg_ok "Built Netvisor-daemon" msg_info "Configuring server & daemon for first-run" +LOCAL_IP="$(hostname -I | awk '{print $1}')" cat </opt/netvisor/.env -### - UI -PUBLIC_SERVER_HOSTNAME=default -PUBLIC_SERVER_PORT=60072 - ### - SERVER NETVISOR_DATABASE_URL=postgresql://$PG_DB_USER:$PG_DB_PASS@localhost:5432/$PG_DB_NAME NETVISOR_WEB_EXTERNAL_PATH="/opt/netvisor/ui/build" +NETVISOR_SERVER_PUBLIC_URL=http://${LOCAL_IP}:60072 NETVISOR_SERVER_PORT=60072 NETVISOR_LOG_LEVEL=info NETVISOR_INTEGRATED_DAEMON_URL=http://127.0.0.1:60073 ## - uncomment to disable signups # NETVISOR_DISABLE_REGISTRATION=true -## - uncomment when behind reverse proxy +## - uncomment when using TLS # NETVISOR_USE_SECURE_SESSION_COOKIES=true ### - OIDC (optional) @@ -74,8 +72,14 @@ NETVISOR_INTEGRATED_DAEMON_URL=http://127.0.0.1:60073 ## - Callback URL for reference # http://your-netvisor-domain:60072/api/auth/oidc/callback +### - SMTP (password reset and notifications - optional) +# NETVISOR_SMTP_RELAY=smtp.gmail.com:587 +# NETVISOR_SMTP_USERNAME=your-email@gmail.com +# NETVISOR_SMTP_PASSWORD=your-app-password +# NETVISOR_SMTP_EMAIL=netvisor@yourdomain.tld + ### - INTEGRATED DAEMON -NETVISOR_SERVER_TARGET=127.0.0.1 +NETVISOR_SERVER_URL=http://127.0.0.1:60072 NETVISOR_BIND_ADDRESS=0.0.0.0 NETVISOR_NAME="netvisor-daemon" NETVISOR_HEARTBEAT_INTERVAL=30 @@ -112,7 +116,7 @@ After=network.target netvisor-server.service [Service] Type=simple EnvironmentFile=/opt/netvisor/.env -ExecStart=/usr/bin/netvisor-daemon --server-target http://127.0.0.1 --server-port 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} Restart=always RestartSec=10 StandardOutput=journal