mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-25 05:57:26 +00:00
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.
This commit is contained in:
@@ -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" ;;
|
||||
|
||||
Reference in New Issue
Block a user