Skip to content

Commit b17d5c4

Browse files
committed
feat: add NetAlertX ProxmoxVE helper scripts
1 parent 1b6dc94 commit b17d5c4

9 files changed

Lines changed: 696 additions & 40 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ docker-compose.yml.ffsb42
4848
test_mounts/
4949
.gemini/settings.json
5050
.vscode/mcp.json
51+
install/proxmox/PULL_REQUEST.md

front/php/templates/language/fr_fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,4 +789,4 @@
789789
"settings_system_label": "Système",
790790
"settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. <b>Il n'y a pas de pas de contrôle.</b>",
791791
"test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage."
792-
}
792+
}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# NetAlertX Installation Guide for Proxmox VE
2+
3+
## Quick Start (ProxmoxVE LXC Container)
4+
5+
To create a NetAlertX LXC container on Proxmox VE, run this command on your Proxmox host:
6+
7+
```bash
8+
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/netalertx.sh)"
9+
```
10+
11+
This will:
12+
- Create a Debian 13 LXC container
13+
- Install all dependencies automatically
14+
- Configure NetAlertX with NGINX on port 20211
15+
- Start the service automatically
16+
17+
### Update Existing Installation
18+
19+
To update an existing NetAlertX container:
20+
21+
```bash
22+
bash -c "$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/netalertx.sh)" -s update
23+
```
24+
25+
---
26+
27+
## Installation Process Overview
28+
29+
### 1. **System Preparation**
30+
- Updates system packages
31+
32+
### 2. **Dependency Installation**
33+
- Installs NGINX web server
34+
- Installs Python 3 and development tools
35+
- Installs network scanning tools (nmap, arp-scan, fping, etc.)
36+
- Installs system utilities (sqlite3, dnsutils, avahi-daemon, etc.)
37+
38+
### 3. **Application Setup**
39+
- Clones NetAlertX repository to `/app`
40+
- Creates Python virtual environment at `/opt/netalertx-env`
41+
- Installs Python dependencies from requirements.txt
42+
- Configures NGINX with default port 20211
43+
44+
### 4. **File Structure Creation**
45+
- Creates persistent directories for `/app/log` and `/app/api`
46+
- Creates log files and plugin directories
47+
- Copies initial database and configuration files
48+
- Sets secure file permissions (www-data user/group)
49+
- Configures systemd RuntimeDirectory (`/run/netalertx`) for volatile service files
50+
51+
### 5. **Service Configuration**
52+
- Creates startup script at `/app/start.netalertx.sh`
53+
- Installs systemd service (`netalertx.service`)
54+
- Enables auto-start on boot
55+
- Starts NetAlertX and NGINX services
56+
57+
### 6. **Hardware Vendor Database**
58+
- Updates IEEE OUI database for MAC address vendor identification (if not present)
59+
60+
---
61+
62+
## Post-Installation
63+
64+
### Accessing NetAlertX
65+
66+
After successful installation, access the web interface at:
67+
68+
```
69+
http://YOUR_SERVER_IP:YOUR_PORT
70+
```
71+
72+
**Default port**: 20211
73+
74+
To find your server IP:
75+
```bash
76+
ip -4 route get 1.1.1.1 | awk '{for(i=1;i<=NF;i++) if ($i=="src") {print $(i+1); exit}}'
77+
```
78+
79+
### Service Management
80+
81+
```bash
82+
# Check service status
83+
systemctl status netalertx.service
84+
85+
# View real-time logs
86+
journalctl -u netalertx.service -f
87+
88+
# Restart service
89+
systemctl restart netalertx.service
90+
91+
# Stop service
92+
systemctl stop netalertx.service
93+
```
94+
95+
---
96+
97+
## Important File Locations
98+
99+
| Component | Location |
100+
|-----------|----------|
101+
| Installation Directory | `/app` |
102+
| Configuration File | `/app/config/app.conf` |
103+
| Database File | `/app/db/app.db` |
104+
| NGINX Configuration | `/etc/nginx/conf.d/netalertx.conf` |
105+
| Web UI (symlink) | `/var/www/html/netalertx``/app/front` |
106+
| Python Virtual Env | `/opt/netalertx-env` |
107+
| Systemd Service | `/etc/systemd/system/netalertx.service` |
108+
| Startup Script | `/app/start.netalertx.sh` |
109+
| Application Logs | `/app/log/` (persistent) |
110+
| API Files | `/app/api/` (persistent) |
111+
| Service Runtime | `/run/netalertx/` (tmpfs, systemd-managed) |
112+
113+
### Storage Strategy (Hybrid Approach)
114+
115+
**Persistent Storage** (survives reboots):
116+
- `/app/log/app.log` - Main application log
117+
- `/app/log/execution_queue.log` - Task execution log
118+
- `/app/log/app_front.log` - Frontend log
119+
- `/app/log/app.php_errors.log` - PHP error log
120+
- `/app/log/stderr.log` - Standard error output
121+
- `/app/log/stdout.log` - Standard output
122+
- `/app/log/db_is_locked.log` - Database lock log
123+
- `/app/api/user_notifications.json` - User notification data
124+
125+
**Volatile Storage** (tmpfs, cleared on reboot):
126+
- `/run/netalertx/` - Systemd-managed runtime directory for service temporary files
127+
128+
Systemd service logs are always available via: `journalctl -u netalertx.service`
129+
130+
---
131+
132+
## Environment Variables
133+
134+
The installation script supports the following environment variables:
135+
136+
| Variable | Description | Default |
137+
|----------|-------------|---------|
138+
| `NETALERTX_ASSUME_YES` | Skip all interactive prompts | (not set) |
139+
| `ASSUME_YES` | Alternative to NETALERTX_ASSUME_YES | (not set) |
140+
| `PORT` | HTTP port for web interface | 20211 |
141+
| `NETALERTX_FORCE` | Force installation without prompts | (not set) |
142+
143+
---
144+
145+
## Security Considerations
146+
147+
- **Runtime directory**: Systemd manages `/run/netalertx/` as tmpfs with `noexec,nosuid,nodev` flags
148+
- **File permissions**: Application files restricted to `www-data` user/group only (mode 0750)
149+
- **Service isolation**: Runs as unprivileged `www-data` user
150+
- **Automatic restart**: Service configured to restart on failure
151+
- **Persistent logs**: Application logs survive reboots for debugging and audit trails
152+
153+
---
154+
155+
## Additional Resources
156+
157+
- **GitHub Repository**: https://github.com/jokob-sk/NetAlertX
158+
- **Issue Tracker**: https://github.com/jokob-sk/NetAlertX/issues
159+
- **Documentation**: `/app/docs/` directory

install/proxmox/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ An installer script for deploying NetAlertX on Proxmox VE (Debian-based) system
1111

1212
### Installation
1313

14-
## Download and run the installer
14+
#### Proxmox VE Helper Script (Recommended)
15+
This is the easiest way to deploy NetAlertX on Proxmox. Run this command on your Proxmox host:
16+
```bash
17+
bash -c "$(wget -qLO - https://github.com/JVKeller/NetAlertX/raw/proxmox-baremetal-installer/install/proxmox/ct/netalertx.sh)"
18+
```
19+
20+
#### Standalone Script (Inside existing LXC/VM)
21+
Download and run the installer inside a fresh Debian/Ubuntu system:
1522
```bash
1623
wget https://raw.githubusercontent.com/jokob-sk/NetAlertX/refs/heads/main/install/proxmox/proxmox-install-netalertx.sh -O proxmox-install-netalertx.sh && chmod +x proxmox-install-netalertx.sh && ./proxmox-install-netalertx.sh
1724
```

install/proxmox/ct/netalertx.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2021-2026 community-scripts ORG
3+
# Author: jokob-sk
4+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
5+
# Source: https://github.com/netalertx/NetAlertX
6+
7+
# Import main orchestrator
8+
source <(curl -fsSL https://github.com/community-scripts/ProxmoxVE/raw/main/misc/build.func)
9+
10+
# Application Configuration
11+
APP="NetAlertX"
12+
var_tags="network;monitoring;security"
13+
var_cpu="2"
14+
var_ram="2048"
15+
var_disk="10"
16+
# Container Type & OS
17+
var_os="debian"
18+
var_version="13"
19+
var_unprivileged="1"
20+
# var_password="root" # Uncomment if you want to hardcode a password for testing
21+
22+
# Standard initialization
23+
header_info "$APP"
24+
variables
25+
color
26+
catch_errors
27+
28+
# Support running from a mirror
29+
if [[ -n "${REPOS_URL}" ]]; then
30+
# Only show info message in verbose mode to avoid UI overlap
31+
if [[ "${VERBOSE:-no}" == "yes" ]]; then
32+
msg_info "Using custom repository: ${REPOS_URL}"
33+
fi
34+
# Override build_container to use the custom repo URL
35+
original_func=$(declare -f build_container)
36+
# Map official ProxmoxVE path to NetAlertX fork path - EXTREMELY SURGICAL to avoid core breakages
37+
eval "$(echo "$original_func" | sed "s|https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/\${var_install}.sh|${REPOS_URL}/install/proxmox/install/\${var_install}.sh|g")"
38+
fi
39+
40+
# Define local installer path for testing
41+
LOCAL_INSTALLER="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../install/${NSAPP:-netalertx}-install.sh"
42+
43+
# Override build_container to use local install script if available
44+
if [[ -f "$LOCAL_INSTALLER" ]]; then
45+
msg_info "Using local installer from $LOCAL_INSTALLER"
46+
original_func=$(declare -f build_container)
47+
replacement="pct push \"\$CTID\" \"$LOCAL_INSTALLER\" /root/install.sh && lxc-attach -n \"\$CTID\" -- bash /root/install.sh"
48+
eval "$(echo "$original_func" | sed "s|lxc-attach.*install/\${var_install}.sh.*|$replacement|")"
49+
fi
50+
51+
# Export variables to ensure they're passed to the installation script
52+
export NSAPP APP var_os var_version var_cpu var_ram var_disk var_unprivileged PORT VERBOSE REPO_URL
53+
54+
# Support verbose logging
55+
if [[ "${VERBOSE:-no}" == "yes" ]]; then
56+
set -x
57+
STD=""
58+
fi
59+
60+
# Automatically detect bridge if vmbr0 is missing
61+
if ! ip link show vmbr0 >/dev/null 2>&1 || [[ "$(cat /sys/class/net/vmbr0/bridge/bridge_id 2>/dev/null)" == "" ]]; then
62+
# Get List of Bridges using multiple methods
63+
# shellcheck disable=SC2207,SC2010 # Working pattern for bridge detection
64+
BRIDGES=($(ip -o link show type bridge | awk -F': ' '{print $2}') $(ls /sys/class/net | grep vmbr | grep -v "vmbr0"))
65+
# Remove duplicates
66+
# shellcheck disable=SC2207 # Working pattern for deduplication
67+
BRIDGES=($(echo "${BRIDGES[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
68+
69+
if [ ${#BRIDGES[@]} -eq 0 ]; then
70+
# Fallback to pvesh if available
71+
if command -v pvesh >/dev/null 2>&1; then
72+
# shellcheck disable=SC2207,SC2046 # Working pattern for pvesh output
73+
BRIDGES=($(pvesh get /nodes/$(hostname)/network --type bridge --output-format json | grep -oP '"iface":"\K[^"]+'))
74+
fi
75+
fi
76+
77+
if [ ${#BRIDGES[@]} -eq 0 ]; then
78+
msg_error "No network bridges (vmbr) detected. Please create a Linux Bridge in Proxmox first."
79+
exit 1
80+
elif [ ${#BRIDGES[@]} -eq 1 ]; then
81+
export var_bridge="${BRIDGES[0]}"
82+
msg_info "Using detected bridge: ${var_bridge}"
83+
else
84+
# Multiple bridges found, let the user pick
85+
BRIDGE_MENU=()
86+
for b in "${BRIDGES[@]}"; do
87+
BRIDGE_MENU+=("$b" "Network Bridge")
88+
done
89+
# shellcheck disable=SC2155 # Standard whiptail pattern
90+
export var_bridge=$(whiptail --title "Select Network Bridge" --menu "vmbr0 not found. Please select a valid bridge:" 15 60 5 "${BRIDGE_MENU[@]}" 3>&1 1>&2 2>&3)
91+
if [ -z "$var_bridge" ]; then
92+
msg_error "No bridge selected. Aborting."
93+
exit 1
94+
fi
95+
fi
96+
fi
97+
98+
function update_script() {
99+
header_info
100+
check_container_storage
101+
check_container_resources
102+
103+
if [[ ! -d /app ]]; then
104+
msg_error "No ${APP} Installation Found!"
105+
exit
106+
fi
107+
108+
msg_info "Stopping ${APP} Service"
109+
systemctl stop netalertx.service
110+
msg_ok "Stopped ${APP} Service"
111+
112+
msg_info "Updating ${APP}"
113+
cd /app || exit
114+
git pull
115+
msg_ok "Updated ${APP}"
116+
117+
msg_info "Updating Python Dependencies"
118+
# shellcheck disable=SC1091 # venv activation script
119+
source /opt/netalertx-env/bin/activate
120+
pip install -r install/proxmox/requirements.txt
121+
deactivate
122+
msg_ok "Updated Python Dependencies"
123+
124+
msg_info "Starting ${APP} Service"
125+
systemctl start netalertx.service
126+
msg_ok "Started ${APP} Service"
127+
128+
msg_ok "Update Complete"
129+
exit
130+
}
131+
132+
# Start the container creation workflow
133+
start
134+
135+
# Build the container with selected configuration
136+
build_container
137+
138+
# Set container description/notes in Proxmox UI
139+
description
140+
141+
# Display success message
142+
msg_ok "Completed successfully!\n"
143+
144+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
145+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
146+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:${PORT:-20211}${CL}"
147+
echo -e "${INFO}${YW} Service Management:${CL}"
148+
echo -e "${TAB}systemctl status netalertx.service${CL}"

0 commit comments

Comments
 (0)