From 8d00d2c9db3900b8c4569ae3438c7621cd8a4e42 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 26 Sep 2025 12:47:46 +0200 Subject: [PATCH] Add Description field for Bridges --- misc/build.func | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/misc/build.func b/misc/build.func index 59684d8c..f2578240 100644 --- a/misc/build.func +++ b/misc/build.func @@ -220,6 +220,22 @@ get_current_ip() { echo "$CURRENT_IP" } +# ------------------------------------------------------------------------------ +# get_bridge_description() +# +# - Reads bridge descriptions from /usr/local/community-scripts/bridge_description +# - Returns description for given bridge name, or empty string if not found +# - File format: bridge_name:description (e.g., vmbr0:LAN, vmbr1:WAN) +# ------------------------------------------------------------------------------ +get_bridge_description() { + local bridge_name="$1" + local desc_file="/usr/local/community-scripts/bridge_description" + + if [[ -f "$desc_file" ]]; then + grep "^${bridge_name}:" "$desc_file" 2>/dev/null | cut -d':' -f2- | head -n1 + fi +} + # ------------------------------------------------------------------------------ # update_motd_ip() # @@ -613,7 +629,20 @@ advanced_settings() { BRG="vmbr0" echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}" else - BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --menu "Select network bridge:" 15 40 6 $(echo "$BRIDGES" | awk '{print $0, "Bridge"}') 3>&1 1>&2 2>&3) + # Build bridge menu with descriptions + BRIDGE_MENU_OPTIONS="" + while IFS= read -r bridge; do + if [[ -n "$bridge" ]]; then + description=$(get_bridge_description "$bridge") + if [[ -n "$description" ]]; then + BRIDGE_MENU_OPTIONS="${BRIDGE_MENU_OPTIONS}${bridge} \"${bridge} - ${description}\" " + else + BRIDGE_MENU_OPTIONS="${BRIDGE_MENU_OPTIONS}${bridge} \"${bridge}\" " + fi + fi + done <<< "$BRIDGES" + + BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --menu "Select network bridge:" 15 60 6 $BRIDGE_MENU_OPTIONS 3>&1 1>&2 2>&3) if [[ -z "$BRG" ]]; then exit_script else