From 6373e16d449deb2329f803e6e6f6dba6b2f631be Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 22 Sep 2025 11:34:44 +0200 Subject: [PATCH] Refactor network string construction in build_container Improves readability and flexibility by building the NET_STRING variable incrementally, using parameter expansion to include only set values for MAC, GATE, VLAN, and MTU. This change makes the network configuration more robust and easier to maintain. --- misc/build.func | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/build.func b/misc/build.func index b00eac9c..0bfe7430 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2108,7 +2108,12 @@ start() { build_container() { # if [ "$VERBOSE" == "yes" ]; then set -x; fi - NET_STRING="-net0 name=eth0,bridge=${BRG:-vmbr0}${MAC:-},ip=${NET:-dhcp}${GATE:-}${VLAN:-}${MTU:-}" + NET_STRING="-net0 name=eth0,bridge=${BRG:-vmbr0}" + NET_STRING+="${MAC:+,hwaddr=$MAC}" + NET_STRING+=",ip=${NET:-dhcp}" + NET_STRING+="${GATE:+,gw=$GATE}" + NET_STRING+="${VLAN:+,tag=$VLAN}" + NET_STRING+="${MTU:+,mtu=$MTU}" case "$IPV6_METHOD" in auto) NET_STRING="$NET_STRING,ip6=auto" ;; dhcp) NET_STRING="$NET_STRING,ip6=dhcp" ;;