install.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. set -e
  3. echo "=== Installing Proxmox RouterOS Controller ==="
  4. # Check root
  5. if [ "$EUID" -ne 0 ]; then
  6. echo "[-] Please run as root"
  7. exit 1
  8. fi
  9. APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  10. cd "$APP_DIR"
  11. # Build binary
  12. echo "[+] Compiling Go binary..."
  13. CGO_ENABLED=0 go build -ldflags="-s -w" -o /usr/local/bin/proxmox-router cmd/server/main.go
  14. chmod +x /usr/local/bin/proxmox-router
  15. # Create directories
  16. mkdir -p /etc/proxmox-router
  17. mkdir -p /etc/network/interfaces.d
  18. # Ensure interfaces.d is included in /etc/network/interfaces
  19. if [ -f /etc/network/interfaces ]; then
  20. if ! grep -q "source /etc/network/interfaces.d/\*" /etc/network/interfaces; then
  21. echo -e "\n# Proxmox Router interfaces inclusion\nsource /etc/network/interfaces.d/*" >> /etc/network/interfaces
  22. echo "[+] Added source /etc/network/interfaces.d/* to /etc/network/interfaces"
  23. fi
  24. fi
  25. # Install systemd service
  26. if [ -d /etc/systemd/system ]; then
  27. cp systemd/proxmox-router.service /etc/systemd/system/proxmox-router.service
  28. systemctl daemon-reload
  29. systemctl enable proxmox-router
  30. systemctl restart proxmox-router || true
  31. echo "[+] Systemd service installed and active on port 80!"
  32. else
  33. echo "[!] Systemd not detected, binary installed to /usr/local/bin/proxmox-router"
  34. fi
  35. echo "=== Installation complete! ==="
  36. echo "Access the Web UI at: http://<container-ip>/"