pve-trunks-plugin/install.sh

43 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# PVE Trunks Plugin - Installer
# Adds "Trunks" field to VM Network Device editor in Proxmox VE UI
#
# Usage: bash install.sh
set -e
PLUGIN_JS="pve-trunks-plugin.js"
PVE_JS_DIR="/usr/share/pve-manager/js"
INDEX_TPL="/usr/share/pve-manager/index.html.tpl"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT_TAG='<script type="text/javascript" src="/pve2/js/pve-trunks-plugin.js"></script>'
# Check running as root
if [ "$(id -u)" -ne 0 ]; then
echo "Error: run as root"
exit 1
fi
# Check Proxmox
if [ ! -d "$PVE_JS_DIR" ]; then
echo "Error: Proxmox VE not found ($PVE_JS_DIR missing)"
exit 1
fi
# Copy plugin JS
cp "$SCRIPT_DIR/$PLUGIN_JS" "$PVE_JS_DIR/$PLUGIN_JS"
echo "Installed $PVE_JS_DIR/$PLUGIN_JS"
# Patch index template if not already patched
if ! grep -q "pve-trunks-plugin" "$INDEX_TPL"; then
# Insert before closing </body>
sed -i "s|</body>|${SCRIPT_TAG}\n</body>|" "$INDEX_TPL"
echo "Patched $INDEX_TPL"
else
echo "Index template already patched, skipping"
fi
# Restart web UI
systemctl restart pveproxy
echo "Done. Reload the Proxmox web UI (Ctrl+Shift+R)."