Compare commits

...

3 Commits

Author SHA1 Message Date
CanbiZ
aaa9c343cd Refactor PostgreSQL setup and configuration 2025-11-13 15:06:54 +01:00
CanbiZ
53b25872a6 Update date_created in netvisor.json 2025-11-13 15:04:18 +01:00
push-app-to-main[bot]
f233196958 'Add new script' 2025-11-13 13:58:18 +00:00
4 changed files with 253 additions and 0 deletions

6
ct/headers/netvisor Normal file
View File

@@ -0,0 +1,6 @@
_ __ __ _ ___
/ | / /__ / /| | / (_)________ _____
/ |/ / _ \/ __/ | / / / ___/ __ \/ ___/
/ /| / __/ /_ | |/ / (__ ) /_/ / /
/_/ |_/\___/\__/ |___/_/____/\____/_/

80
ct/netvisor.sh Normal file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# 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
APP="NetVisor"
var_tags="${var_tags:-analytics}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-6}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/netvisor ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "netvisor" "mayanayza/netvisor"; then
msg_info "Stopping services"
systemctl stop netvisor-daemon netvisor-server
msg_ok "Stopped services"
msg_info "Backing up configurations"
cp /opt/netvisor/.env /opt/netvisor.env
msg_ok "Backed up configurations"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "netvisor" "mayanayza/netvisor" "tarball" "latest" "/opt/netvisor"
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
msg_info "Creating frontend UI"
export PUBLIC_SERVER_HOSTNAME=default
export PUBLIC_SERVER_PORT=60072
cd /opt/netvisor/ui
$STD npm ci --no-fund --no-audit
$STD npm run build
msg_ok "Created frontend UI"
msg_info "Building Netvisor-server (patience)"
cd /opt/netvisor/backend
$STD cargo build --release --bin server
mv ./target/release/server /usr/bin/netvisor-server
msg_ok "Built Netvisor-server"
msg_info "Building Netvisor-daemon (amd64 version)"
$STD cargo build --release --bin daemon
cp ./target/release/daemon /usr/bin/netvisor-daemon
msg_ok "Built Netvisor-daemon (amd64 version)"
msg_info "Starting services"
systemctl start netvisor-server netvisor-daemon
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
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}"

View File

@@ -0,0 +1,40 @@
{
"name": "NetVisor",
"slug": "netvisor",
"categories": [
9
],
"date_created": "2025-11-13",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 60072,
"documentation": "https://github.com/mayanayza/netvisor",
"config_path": "/opt/netvisor/.env",
"website": "https://github.com/mayanayza/netvisor",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/png/netvisor.png",
"description": "Automatically discover and visually document network infrastructure",
"install_methods": [
{
"type": "default",
"script": "ct/netvisor.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 6,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "The integrated daemon config is located at `/root/.config/daemon/config.json`",
"type": "info"
}
]
}

127
install/netvisor-install.sh Normal file
View File

@@ -0,0 +1,127 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: vhsdream
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/mayanayza/netvisor
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential
msg_ok "Installed Dependencies"
PG_VERSION=17 setup_postgresql
NODE_VERSION="24" setup_nodejs
PG_DB_NAME="netvisor_db" PG_DB_USER="netvisor" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
fetch_and_deploy_gh_release "netvisor" "mayanayza/netvisor" "tarball" "latest" "/opt/netvisor"
TOOLCHAIN="$(grep "channel" /opt/netvisor/backend/rust-toolchain.toml | awk -F\" '{print $2}')"
RUST_TOOLCHAIN=$TOOLCHAIN setup_rust
msg_info "Creating frontend UI"
export PUBLIC_SERVER_HOSTNAME=default
export PUBLIC_SERVER_PORT=60072
cd /opt/netvisor/ui
$STD npm ci --no-fund --no-audit
$STD npm run build
msg_ok "Created frontend UI"
msg_info "Building Netvisor-server (patience)"
cd /opt/netvisor/backend
$STD cargo build --release --bin server
mv ./target/release/server /usr/bin/netvisor-server
msg_ok "Built Netvisor-server"
msg_info "Building Netvisor-daemon"
$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"
cat <<EOF >/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_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
# NETVISOR_USE_SECURE_SESSION_COOKIES=true
### - OIDC (optional)
# NETVISOR_OIDC_ISSUER_URL=
# NETVISOR_OIDC_CLIENT_ID=
# NETVISOR_OIDC_CLIENT_SECRET=
# NETVISOR_OIDC_PROVIDER_NAME=
# NETVISOR_OIDC_REDIRECT_URL=
## - Callback URL for reference
# http://your-netvisor-domain:60072/api/auth/oidc/callback
### - INTEGRATED DAEMON
NETVISOR_SERVER_TARGET=127.0.0.1
NETVISOR_BIND_ADDRESS=0.0.0.0
NETVISOR_NAME="netvisor-daemon"
NETVISOR_HEARTBEAT_INTERVAL=30
EOF
cat <<EOF >/etc/systemd/system/netvisor-server.service
[Unit]
Description=NetVisor Network Discovery Server
After=network.target postgresql.service
[Service]
Type=simple
EnvironmentFile=/opt/netvisor/.env
ExecStart=/usr/bin/netvisor-server
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
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
[Unit]
Description=NetVisor Network Discovery Daemon
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}
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now netvisor-daemon
msg_ok "Netvisor server & daemon configured and running"
motd_ssh
customize
cleanup_lxc