#!/bin/bash # PVE Trunks Plugin - Installer # Adds a "Trunks" field to the VM Network Device editor in the Proxmox VE UI. # # Usage: bash install.sh # # Both the plugin JS and the index template belong to the `pve-manager` # package, so an `apt upgrade` wipes them. This installer therefore also sets # up a reapply hook so the plugin survives Proxmox updates. set -euo pipefail 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)" # Persistent copy + reapply machinery (so upgrades can restore the plugin). STORE_DIR="/usr/local/share/pve-trunks-plugin" REAPPLY="/usr/local/sbin/pve-trunks-reapply.sh" APT_HOOK="/etc/apt/apt.conf.d/99-pve-trunks-plugin" SCRIPT_TAG='' if [ "$(id -u)" -ne 0 ]; then echo "Error: run as root" >&2 exit 1 fi if [ ! -d "$PVE_JS_DIR" ] || [ ! -f "$INDEX_TPL" ]; then echo "Error: Proxmox VE not found ($PVE_JS_DIR / $INDEX_TPL missing)" >&2 exit 1 fi if [ ! -f "$SCRIPT_DIR/$PLUGIN_JS" ]; then echo "Error: $PLUGIN_JS not found next to installer" >&2 exit 1 fi # 1) Persist the plugin source for the reapply hook. install -d "$STORE_DIR" install -m 0644 "$SCRIPT_DIR/$PLUGIN_JS" "$STORE_DIR/$PLUGIN_JS" # 2) Install the reapply script (idempotent; restarts pveproxy only on change). cat > "$REAPPLY" </dev/null; then install -m 0644 "\$STORE_DIR/\$PLUGIN_JS" "\$PVE_JS_DIR/\$PLUGIN_JS" changed=1 fi # Re-add the