From e7072ddd8623a01edde96b0d8c6e35e7cd9bfa44 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sun, 8 Sep 2024 09:00:50 +0200 Subject: [PATCH] Iprove wrapper function --- lib/armbian-configng/config.ng.jobs.json | 2 +- lib/armbian-configng/config.ng.network.sh | 28 +++++++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 956e962a7..df1ac9e66 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -318,7 +318,7 @@ "description": "Set fixed IP address", "command": [ "choose_adapter \"e\"", - "[[ -n \"$IP_ADDRESS\" ]] && netplan_wrapper \"10-dhcp-all-interfaces\" \"ethernets\" \"networkd\" \"${SELECTED_ADAPTER}\" \"$IP_ADDRESS\"" + "[[ -n \"$IP_ADDRESS\" ]] && netplan_wrapper \"set_ip\" \"10-dhcp-all-interfaces\" \"ethernets\" \"networkd\" \"${SELECTED_ADAPTER}\" \"$IP_ADDRESS\"" ], "status": "Active", "doc_link": "", diff --git a/lib/armbian-configng/config.ng.network.sh b/lib/armbian-configng/config.ng.network.sh index 0d6062ffc..0b29d55e0 100644 --- a/lib/armbian-configng/config.ng.network.sh +++ b/lib/armbian-configng/config.ng.network.sh @@ -287,15 +287,23 @@ module_options+=( # function netplan_wrapper() { - local config=$1 - local type=$2 - local renderer=$3 - local adapter=$4 - local address=$5 - - #rm -f /etc/netplan/${config}.yaml - netplan set --origin-hint ${config} renderer=${renderer} - netplan set --origin-hint ${config} ethernets.${adapter}.addresses=[$address] - show_message <<< "$(sudo netplan get ${type})" + local what=$1 + local config=$2 + local type=$3 + local renderer=$4 + local adapter=$5 + local address=$6 + + case "$1" in + set_ip) + netplan set --origin-hint ${config} renderer=${renderer} + netplan set --origin-hint ${config} ethernets.${adapter}.addresses=[$address] + show_message <<< "$(sudo netplan get ${type})" + ;; + *) + esac + + + } \ No newline at end of file