Allow space separated configs to work for CIDR address styles
This commit is contained in:
parent
f0aa06b586
commit
50161bef0e
@ -40,21 +40,13 @@
|
|||||||
# INTERFACE HANDLERS
|
# INTERFACE HANDLERS
|
||||||
|
|
||||||
# For a static configuration, use something like this
|
# For a static configuration, use something like this
|
||||||
# (They all do exactly the same thing btw)
|
|
||||||
#config_eth0="192.168.0.2/24"
|
#config_eth0="192.168.0.2/24"
|
||||||
#config_eth0="192.168.0.2 netmask 255.255.255.0"
|
|
||||||
|
|
||||||
# We can also specify a broadcast
|
|
||||||
#config_eth0="192.168.0.2/24 brd 192.168.0.255"
|
|
||||||
#config_eth0="192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
|
|
||||||
|
|
||||||
# If you need more than one address, you can use something like this
|
# If you need more than one address, you can use something like this
|
||||||
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
|
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
|
||||||
# (eth0:1, eth0:2, etc)
|
# (eth0:1, eth0:2, etc)
|
||||||
# iproute2 does not do this as there is no need to
|
# iproute2 does not do this as there is no need to
|
||||||
#config_eth0="192.168.0.2/24
|
#config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24"
|
||||||
#192.168.0.3/24
|
|
||||||
#192.168.0.4/24'"
|
|
||||||
# Or you can use sequence expressions
|
# Or you can use sequence expressions
|
||||||
#config_eth0="192.168.0.{2..4}/24" FIXME - may not work with baselayout2
|
#config_eth0="192.168.0.{2..4}/24" FIXME - may not work with baselayout2
|
||||||
# which does the same as above. Be careful though as if you use this and
|
# which does the same as above. Be careful though as if you use this and
|
||||||
@ -63,17 +55,14 @@
|
|||||||
|
|
||||||
# You can also use IPv6 addresses
|
# You can also use IPv6 addresses
|
||||||
# (you should always specify a prefix length with IPv6 here)
|
# (you should always specify a prefix length with IPv6 here)
|
||||||
#config_eth0="192.168.0.2/24
|
#config_eth0="192.168.0.2/24 4321:0:1:2:3:4:567:89ab/64 4321:0:1:2:3:4:567:89ac/64"
|
||||||
#4321:0:1:2:3:4:567:89ab/64
|
|
||||||
#4321:0:1:2:3:4:567:89ac/64"
|
|
||||||
|
|
||||||
# If you wish to keep existing addresses + routing and the interface is up,
|
# If you wish to keep existing addresses + routing and the interface is up,
|
||||||
# you can specify a noop (no operation). If the interface is down or there
|
# you can specify a noop (no operation). If the interface is down or there
|
||||||
# are no addresses assigned, then we move onto the next step (default dhcp)
|
# are no addresses assigned, then we move onto the next step (default dhcp)
|
||||||
# This is useful when configuring your interface with a kernel command line
|
# This is useful when configuring your interface with a kernel command line
|
||||||
# or similar
|
# or similar
|
||||||
#config_eth0="noop
|
#config_eth0="noop 192.168.0.2/24"
|
||||||
#192.168.0.2/24"
|
|
||||||
|
|
||||||
# If you don't want ANY address (only useful when calling for advanced stuff)
|
# If you don't want ANY address (only useful when calling for advanced stuff)
|
||||||
#config_eth0="null"
|
#config_eth0="null"
|
||||||
@ -120,8 +109,7 @@
|
|||||||
# Most users will just need to set the following options
|
# Most users will just need to set the following options
|
||||||
# key_SSID1="s:yourkeyhere enc open" # s: means a text key
|
# key_SSID1="s:yourkeyhere enc open" # s: means a text key
|
||||||
# key_SSID2="aaaa-bbbb-cccc-dd" # no s: means a hex key
|
# key_SSID2="aaaa-bbbb-cccc-dd" # no s: means a hex key
|
||||||
# preferred_aps="SSID 1
|
# preferred_aps="SSID1 SSID2"
|
||||||
#SSID 2"
|
|
||||||
#
|
#
|
||||||
# Clear? Good. Now configure your wireless network below
|
# Clear? Good. Now configure your wireless network below
|
||||||
|
|
||||||
|
@ -18,25 +18,6 @@
|
|||||||
# read through the rest of this file.
|
# read through the rest of this file.
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
# VARIABLES
|
|
||||||
#
|
|
||||||
# We've changed from using arrays to evaluated strings.
|
|
||||||
# This has the benefit of being slightly more readable but more importantly it
|
|
||||||
# works across all shells.
|
|
||||||
# OLD
|
|
||||||
# config_eth0=( "192.168.0.24 netmask 255.255.255.0" "192.168.0.25/24" )
|
|
||||||
# NEW
|
|
||||||
# config_eth0="192.168.0.24 netmask 255.255.255.0
|
|
||||||
# 192.168.0.25/24"
|
|
||||||
# INVALID
|
|
||||||
# config_eth0="192.168.0.24 netmask 255.255.255.0 192.168.0.25/24"
|
|
||||||
# INVALID
|
|
||||||
# config_eth0="192.168.0.24 netmask 255.255.255.0 \n 192.168.0.25/24"
|
|
||||||
#
|
|
||||||
# Basically if array elements may need spaces in their values then we separate
|
|
||||||
# on a hard coded new line.
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# MODULES
|
# MODULES
|
||||||
#
|
#
|
||||||
@ -83,17 +64,12 @@
|
|||||||
#config_eth0="192.168.0.2/24"
|
#config_eth0="192.168.0.2/24"
|
||||||
#config_eth0="192.168.0.2 netmask 255.255.255.0"
|
#config_eth0="192.168.0.2 netmask 255.255.255.0"
|
||||||
|
|
||||||
# We can also specify a broadcast
|
|
||||||
#config_eth0="192.168.0.2/24 brd 192.168.0.255"
|
|
||||||
#config_eth0="192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
|
|
||||||
|
|
||||||
# If you need more than one address, you can use something like this
|
# If you need more than one address, you can use something like this
|
||||||
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
|
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
|
||||||
# (eth0:1, eth0:2, etc)
|
# (eth0:1, eth0:2, etc)
|
||||||
# iproute2 does not do this as there is no need to
|
# iproute2 does not do this as there is no need to
|
||||||
#config_eth0="192.168.0.2/24
|
#config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24"
|
||||||
#192.168.0.3/24
|
# However, that only works with CIDR addresses, so you can't use netmask.
|
||||||
#192.168.0.4/24"
|
|
||||||
# Or you can use sequence expressions
|
# Or you can use sequence expressions
|
||||||
#config_eth0="192.168.0.{2..4}/24"
|
#config_eth0="192.168.0.{2..4}/24"
|
||||||
# which does the same as above. Be careful though as if you use this and
|
# which does the same as above. Be careful though as if you use this and
|
||||||
@ -102,18 +78,14 @@
|
|||||||
|
|
||||||
# You can also use IPv6 addresses
|
# You can also use IPv6 addresses
|
||||||
# (you should always specify a prefix length with IPv6 here)
|
# (you should always specify a prefix length with IPv6 here)
|
||||||
#config_eth0="192.168.0.2/24
|
#config_eth0="192.168.0.2/24 4321:0:1:2:3:4:567:89ab/64 4321:0:1:2:3:4:567:89ac/64"
|
||||||
#4321:0:1:2:3:4:567:89ab/64
|
|
||||||
#4321:0:1:2:3:4:567:89ac/64"
|
|
||||||
#)
|
|
||||||
|
|
||||||
# If you wish to keep existing addresses + routing and the interface is up,
|
# If you wish to keep existing addresses + routing and the interface is up,
|
||||||
# you can specify a noop (no operation). If the interface is down or there
|
# you can specify a noop (no operation). If the interface is down or there
|
||||||
# are no addresses assigned, then we move onto the next step (default dhcp)
|
# are no addresses assigned, then we move onto the next step (default dhcp)
|
||||||
# This is useful when configuring your interface with a kernel command line
|
# This is useful when configuring your interface with a kernel command line
|
||||||
# or similar
|
# or similar
|
||||||
#config_eth0="noop
|
#config_eth0="noop 192.168.0.2/24"
|
||||||
#192.168.0.2/24"
|
|
||||||
|
|
||||||
# If you don't want ANY address (only useful when calling for advanced stuff)
|
# If you don't want ANY address (only useful when calling for advanced stuff)
|
||||||
#config_eth0="null"
|
#config_eth0="null"
|
||||||
@ -126,7 +98,7 @@
|
|||||||
|
|
||||||
# If a specified module fails (like dhcp - see below), you can specify a
|
# If a specified module fails (like dhcp - see below), you can specify a
|
||||||
# fallback like so
|
# fallback like so
|
||||||
#fallback_eth0="192.168.0.2 netmask 255.255.255.0"
|
#fallback_eth0="192.168.0.2/24"
|
||||||
#fallback_route_eth0="default via 192.168.0.1"
|
#fallback_route_eth0="default via 192.168.0.1"
|
||||||
|
|
||||||
# NOTE: fallback entry must match the entry location in config_eth0
|
# NOTE: fallback entry must match the entry location in config_eth0
|
||||||
@ -570,8 +542,8 @@
|
|||||||
#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
|
#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
|
||||||
#vconfig_vlan1="set_flag 1
|
#vconfig_vlan1="set_flag 1
|
||||||
#set_egress_map 2 6"
|
#set_egress_map 2 6"
|
||||||
#config_vlan1="172.16.3.1 netmask 255.255.254.0"
|
#config_vlan1="172.16.3.1/23"
|
||||||
#config_vlan2="172.16.2.1 netmask 255.255.254.0"
|
#config_vlan2="172.16.2.1/23"
|
||||||
|
|
||||||
# NOTE: Vlans can be configured with a . in their interface names
|
# NOTE: Vlans can be configured with a . in their interface names
|
||||||
# When configuring vlans with this name type, you need to replace . with a _
|
# When configuring vlans with this name type, you need to replace . with a _
|
||||||
|
20
sh/net.sh
20
sh/net.sh
@ -410,11 +410,27 @@ ${config}"
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
config_index=0
|
||||||
|
local IFS="$__IFS"
|
||||||
|
set -- ${config}
|
||||||
|
|
||||||
|
# We should support a space separated array for cidr configs
|
||||||
|
if [ $# = 1 ]; then
|
||||||
|
unset IFS
|
||||||
|
set -- ${config}
|
||||||
|
# Of course, we may have a single address added old style.
|
||||||
|
case "$2" in
|
||||||
|
netmask|broadcast|brd|brd+)
|
||||||
|
local IFS="$__IFS"
|
||||||
|
set -- ${config}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# We store our config in an array like vars
|
# We store our config in an array like vars
|
||||||
# so modules can influence it
|
# so modules can influence it
|
||||||
config_index=0
|
config_index=0
|
||||||
local IFS="$__IFS"
|
for cmd; do
|
||||||
for cmd in ${config}; do
|
|
||||||
eval config_${config_index}="'${cmd}'"
|
eval config_${config_index}="'${cmd}'"
|
||||||
config_index=$((${config_index} + 1))
|
config_index=$((${config_index} + 1))
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user