configure_network: use classical function parsing

This commit is contained in:
Frédéric Pierret (fepitre) 2019-06-19 21:03:54 +02:00
parent 1c54101663
commit aa7ab25a78
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -5,19 +5,16 @@
. /usr/lib/qubes/init/functions . /usr/lib/qubes/init/functions
configure_network() { configure_network() {
local IFS=',' local MAC="$1"
read -r -a args <<< "$@" local INTERFACE="$2"
local ip="$3"
local MAC="${args[0]}" local ip6="$4"
local INTERFACE="${args[1]}" local netmask="$5"
local ip="${args[2]}" local netmask6="$6"
local ip6="${args[3]}" local gateway="$7"
local netmask="${args[4]}" local gateway6="$8"
local netmask6="${args[5]}" local primary_dns="$9"
local gateway="${args[6]}" local secondary_dns="${10}"
local gateway6="${args[7]}"
local primary_dns="${args[8]}"
local secondary_dns="${args[9]}"
/sbin/ifconfig "$INTERFACE" "$ip" netmask "$netmask" /sbin/ifconfig "$INTERFACE" "$ip" netmask "$netmask"
if [ -n "$ip6" ]; then if [ -n "$ip6" ]; then
@ -52,19 +49,16 @@ configure_network() {
} }
configure_network_nm() { configure_network_nm() {
local IFS=',' local MAC="$1"
read -r -a args <<< "$@" local INTERFACE="$2"
local ip="$3"
local MAC="${args[0]}" local ip6="$4"
local INTERFACE="${args[1]}" local netmask="$5"
local ip="${args[2]}" local netmask6="$6"
local ip6="${args[3]}" local gateway="$7"
local netmask="${args[4]}" local gateway6="$8"
local netmask6="${args[5]}" local primary_dns="$9"
local gateway="${args[6]}" local secondary_dns="${10}"
local gateway6="${args[7]}"
local primary_dns="${args[8]}"
local secondary_dns="${args[9]}"
local prefix local prefix
local prefix6 local prefix6
@ -209,9 +203,9 @@ if [ -n "$INTERFACE" ]; then
# If NetworkManager is enabled, let it configure the network # If NetworkManager is enabled, let it configure the network
if qsvc network-manager ; then if qsvc network-manager ; then
configure_network_nm "$MAC","$INTERFACE","$ip","$ip6","$netmask","$netmask6","$gateway","$gateway6","$primary_dns","$secondary_dns" configure_network_nm "$MAC" "$INTERFACE" "$ip" "$ip6" "$netmask" "$netmask6" "$gateway" "$gateway6" "$primary_dns" "$secondary_dns"
else else
configure_network "$MAC","$INTERFACE","$ip","$ip6","$netmask","$netmask6","$gateway","$gateway6","$primary_dns","$secondary_dns" configure_network "$MAC" "$INTERFACE" "$ip" "$ip6" "$netmask" "$netmask6" "$gateway" "$gateway6" "$primary_dns" "$secondary_dns"
fi fi
network=$(qubesdb-read /qubes-netvm-network 2>/dev/null) network=$(qubesdb-read /qubes-netvm-network 2>/dev/null)