Skip to content

Commit

Permalink
Iprove wrapper function
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Sep 8, 2024
1 parent 73599b6 commit 32b49e1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
22 changes: 15 additions & 7 deletions lib/armbian-configng/config.ng.jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,7 @@
"id": "N05",
"description": "Enable DHCP on all interfaces",
"command": [
"rm -f /etc/netplan/30-*-static-interfaces.yaml",
"netplan set --origin-hint 10-dhcp-all-interfaces renderer=networkd",
"netplan set --origin-hint 10-dhcp-all-interfaces ethernets.all-eth-interfaces.dhcp4=true",
"netplan set --origin-hint 10-dhcp-all-interfaces ethernets.all-eth-interfaces.dhcp6=true",
"netplan set --origin-hint 10-dhcp-all-interfaces ethernets.all-eth-interfaces.match.name=e*",
"show_message <<< \"$(sudo netplan get ethernets)\""
"netplan_wrapper \"dhcp_all_wired_interfaces\" \"10-dhcp-all-interfaces\" \"\" \"networkd\""
],
"status": "Active",
"author": "Igor Pecovnik",
Expand All @@ -318,14 +313,27 @@
"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": "",
"src_reference": "",
"author": "Igor Pecovnik",
"condition": "[ -f /etc/netplan/10-dhcp-all-interfaces.yaml ] || true"
},
{
"id": "N061",
"description": "Disable IPV6 in wireless configuration",
"command": [
"choose_adapter \"e\" \"false\"",
"[[ -n \"$SELECTED_ADAPTER\" ]] && netplan_wrapper \"disable_ipv6\" \"10-dhcp-all-interfaces\" \"ethernets\" \"networkd\" \"${SELECTED_ADAPTER}\" \"$IP_ADDRESS\""
],
"status": "Active",
"doc_link": "",
"src_reference": "",
"author": "Igor Pecovnik",
"condition": "[ -f /etc/netplan/10-dhcp-all-interfaces.yaml ]"
},
{
"id": "N07",
"description": "Disable wired networking",
Expand Down
41 changes: 31 additions & 10 deletions lib/armbian-configng/config.ng.network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,36 @@ 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
dhcp_all_wired_interfaces)
rm -f /etc/netplan/30-*-static-interfaces.yaml
netplan set --origin-hint ${config} renderer=${renderer}
netplan set --origin-hint ${config} ethernets.all-eth-interfaces.dhcp4=true
netplan set --origin-hint ${config} ethernets.all-eth-interfaces.dhcp6=true
netplan set --origin-hint ${config} ethernets.all-eth-interfaces.match.name=e*
show_message <<< "$(sudo netplan get ${type})"
;;
set_ip)
netplan set --origin-hint ${config} renderer=${renderer}
netplan set --origin-hint ${config} ethernets.${adapter}.addresses=[$address]
show_message <<< "$(sudo netplan get ${type})"
;;
disable_ipv6)
netplan set --origin-hint ${config} renderer=${renderer}
netplan set --origin-hint ${config} ethernets.${adapter}.dhcp6=false
show_message <<< "$(sudo netplan get ${type})"
;;
*)
esac




}

0 comments on commit 32b49e1

Please sign in to comment.