#!/usr/bin/env bash set -e echo "=== Installing Proxmox RouterOS Controller ===" # Check root if [ "$EUID" -ne 0 ]; then echo "[-] Please run as root" exit 1 fi APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$APP_DIR" # Build binary echo "[+] Compiling Go binary..." CGO_ENABLED=0 go build -ldflags="-s -w" -o /usr/local/bin/proxmox-router cmd/server/main.go chmod +x /usr/local/bin/proxmox-router # Create directories mkdir -p /etc/proxmox-router mkdir -p /etc/network/interfaces.d # Ensure interfaces.d is included in /etc/network/interfaces if [ -f /etc/network/interfaces ]; then if ! grep -q "source /etc/network/interfaces.d/\*" /etc/network/interfaces; then echo -e "\n# Proxmox Router interfaces inclusion\nsource /etc/network/interfaces.d/*" >> /etc/network/interfaces echo "[+] Added source /etc/network/interfaces.d/* to /etc/network/interfaces" fi fi # Install systemd service if [ -d /etc/systemd/system ]; then cp systemd/proxmox-router.service /etc/systemd/system/proxmox-router.service systemctl daemon-reload systemctl enable proxmox-router systemctl restart proxmox-router || true echo "[+] Systemd service installed and active on port 80!" else echo "[!] Systemd not detected, binary installed to /usr/local/bin/proxmox-router" fi echo "=== Installation complete! ===" echo "Access the Web UI at: http:///"