Network config arrays are now split by embedded new lines instead of being evaled into space separated values. This makes it easier to read, maintain and document as discussed on gentoo-dev.

This commit is contained in:
Roy Marples 2007-10-29 09:45:49 +00:00
parent 42c231d760
commit e372729b8c
14 changed files with 260 additions and 187 deletions

View File

@ -1,6 +1,12 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts # ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2 # Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
29 Oct 2007; Roy Marples <uberlord@gentoo.org>:
Network config arrays are now split by embedded new lines instead of
being evaled into space separated values. This makes it easier to read,
maintain and document as discussed on gentoo-dev.
23 Oct 2007; Roy Marples <uberlord@gentoo.org>: 23 Oct 2007; Roy Marples <uberlord@gentoo.org>:
clock init script now works with busybox hwclock. clock init script now works with busybox hwclock.

View File

@ -42,27 +42,29 @@
# For a static configuration, use something like this # For a static configuration, use something like this
# (They all do exactly the same thing btw) # (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'" #config_eth0="192.168.0.2 netmask 255.255.255.0"
# We can also specify a broadcast # We can also specify a broadcast
#config_eth0="'192.168.0.2/24 brd 192.168.0.255'" #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'" #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' '192.168.0.3/24' '192.168.0.4/24'" #config_eth0="192.168.0.2/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
# fallbacks, you have to ensure that both end up with the same number of # fallbacks, you have to ensure that both end up with the same number of
# values otherwise your fallback won't work correctly. # values otherwise your fallback won't work correctly.
# 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:89ab/64
#4321:0:1:2:3:4:567:89ac/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,
@ -70,23 +72,22 @@
# 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 192.168.0.2/24" #config_eth0="noop
#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"
# Here's how to do routing if you need it # Here's how to do routing if you need it
# We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route # We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route
#routes_eth0=" \ #routes_eth0="default via 192.168.0.1
# 'default via 192.168.0.1' \ #10.0.0.0/8 via 192.168.0.1
# '10.0.0.0/8 via 192.168.0.1' \ #::/0"
# '::/0' \
#"
# 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 netmask 255.255.255.0"
#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
# As such you can only have one fallback route. # As such you can only have one fallback route.
@ -211,10 +212,12 @@
# Surround each ESSID with the " character and seperate them with a space # Surround each ESSID with the " character and seperate them with a space
# If the first ESSID isn't found then it moves onto the next # If the first ESSID isn't found then it moves onto the next
# If this isn't defined then it connects to the first one found # If this isn't defined then it connects to the first one found
#preferred_aps="'ESSID 1' 'ESSID 2'" #preferred_aps="ESSID 1
#ESSID 2"
# You can also define a preferred_aps list per interface # You can also define a preferred_aps list per interface
#preferred_aps_eth0="'ESSID 3' 'ESSID 4'" #preferred_aps_eth0="ESSID 3
#ESSID 4"
# You can also say whether we only connect to preferred APs or not # You can also say whether we only connect to preferred APs or not
# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" # Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly"
@ -234,8 +237,10 @@
#associate_order_eth0="any" #associate_order_eth0="any"
# You can define blacklisted Access Points in the same way # You can define blacklisted Access Points in the same way
#blacklist_aps="'ESSID 1' 'ESSID 2'" #blacklist_aps="ESSID 1
#blacklist_aps_eth0="'ESSID 3' 'ESSID 4'" #ESSID 2"
#blacklist_aps_eth0="ESSID 3
#ESSID 4"
# If you have more than one wireless card, you can say if you want # If you have more than one wireless card, you can say if you want
# to allow each card to associate with the same Access Point or not # to allow each card to associate with the same Access Point or not
@ -354,7 +359,7 @@
#dns_domain_eth0="your.domain" #dns_domain_eth0="your.domain"
#dns_servers_eth0="192.168.0.2 192.168.0.3" #dns_servers_eth0="192.168.0.2 192.168.0.3"
#dns_search_eth0="this.domain that.domain" #dns_search_eth0="this.domain that.domain"
#dns_options_eth0="'timeout:1' 'rotate'" #dns_options_eth0="timeout:1 rotate"
#dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0" #dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0"
# See the man page for resolv.conf for details about the options and sortlist # See the man page for resolv.conf for details about the options and sortlist
# directives # directives

View File

@ -27,14 +27,15 @@
# OLD # OLD
# config_eth0=( "192.168.0.24 netmask 255.255.255.0" "192.168.0.25/24" ) # config_eth0=( "192.168.0.24 netmask 255.255.255.0" "192.168.0.25/24" )
# NEW # NEW
# config_eth0="'192.168.0.24 netmask 255.255.255.0' 192.168.0.25/24" # config_eth0="192.168.0.24 netmask 255.255.255.0
# 192.168.0.25/24"
# INVALID # INVALID
# config_eth0='192.168.0.24 netmask 255.255.255.0' # 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"
# #
# As the 1st value has spaces in it, it needs additional quoting. The 2nd # Basically if array elements may need spaces in their values then we separate
# value has no spaces, therefore no additional quoting is required. # on a hard coded new line.
# The last statement is invalid because when it is evaluated, it only has one
# set of quotes.
############################################################################## ##############################################################################
# MODULES # MODULES
@ -80,27 +81,29 @@
# For a static configuration, use something like this # For a static configuration, use something like this
# (They all do exactly the same thing btw) # (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'" #config_eth0="192.168.0.2 netmask 255.255.255.0"
# We can also specify a broadcast # We can also specify a broadcast
#config_eth0="'192.168.0.2/24 brd 192.168.0.255'" #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'" #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' '192.168.0.3/24' '192.168.0.4/24'" #config_eth0="192.168.0.2/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 - does it work? #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
# fallbacks, you have to ensure that both end up with the same number of # fallbacks, you have to ensure that both end up with the same number of
# values otherwise your fallback won't work correctly. # values otherwise your fallback won't work correctly.
# 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:89ab/64
#4321:0:1:2:3:4:567:89ac/64" #4321:0:1:2:3:4:567:89ac/64"
#) #)
@ -109,23 +112,22 @@
# 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 192.168.0.2/24" #config_eth0="noop
#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"
# Here's how to do routing if you need it # Here's how to do routing if you need it
# We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route # We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route
#routes_eth0=" \ #routes_eth0="default via 192.168.0.1
# 'default via 192.168.0.1' \ #10.0.0.0/8 via 192.168.0.1
# '10.0.0.0/8 via 192.168.0.1' \ #::/0"
# '::/0' \
#"
# 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 netmask 255.255.255.0"
#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
# As such you can only have one fallback route. # As such you can only have one fallback route.
@ -217,11 +219,9 @@
# the iwpriv $iface. If you use the rt2500 driver (not the rt2x00 one) then # the iwpriv $iface. If you use the rt2500 driver (not the rt2x00 one) then
# you can set WPA here, below is an example. # you can set WPA here, below is an example.
#iwpriv_eth0="" #iwpriv_eth0=""
#iwpriv_SSID=" \ #iwpriv_SSID="set AuthMode=WPAPSK
# 'set AuthMode=WPAPSK' \ #set EncrypType=TKIP
# 'set EncrypType=TKIP' \ #set WPAPSK=yourpasskey"
# 'set WPAPSK=yourpasskey' \
#"
#NOTE: Even though you can use WPA like so, you may have to set a WEP key #NOTE: Even though you can use WPA like so, you may have to set a WEP key
#if your driver claims the AP is encrypted. The WEP key itself will not be #if your driver claims the AP is encrypted. The WEP key itself will not be
#used though. #used though.
@ -326,10 +326,12 @@
# Surround each SSID with the " character and seperate them with a space # Surround each SSID with the " character and seperate them with a space
# If the first SSID isn't found then it moves onto the next # If the first SSID isn't found then it moves onto the next
# If this isn't defined then it connects to the first one found # If this isn't defined then it connects to the first one found
#preferred_aps="'SSID 1' 'SSID 2'" #preferred_aps="SSID 1
#SSID 2"
# You can also define a preferred_aps list per interface # You can also define a preferred_aps list per interface
#preferred_aps_eth0="'SSID 3' 'SSID 4'" #preferred_aps_eth0="SSID 3
#SSID 4'"
# You can also say whether we only connect to preferred APs or not # You can also say whether we only connect to preferred APs or not
# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" and "forceany" # Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" and "forceany"
@ -346,8 +348,10 @@
#associate_order_eth0="any" #associate_order_eth0="any"
# You can define blacklisted Access Points in the same way # You can define blacklisted Access Points in the same way
#blacklist_aps="'SSID 1' 'SSID 2'" #blacklist_aps="SSID 1
#blacklist_aps_eth0="'SSID 3' 'SSID 4'" #SSID 2"
#blacklist_aps_eth0="SSID 3
#SSID 4"
# If you have more than one wireless card, you can say if you want # If you have more than one wireless card, you can say if you want
# to allow each card to associate with the same Access Point or not # to allow each card to associate with the same Access Point or not
@ -508,7 +512,7 @@
# #
#gateways_eth0="192.168.0.1 10.0.0.1" #gateways_eth0="192.168.0.1 10.0.0.1"
#config_192168000001="192.168.0.2/24" #config_192168000001="192.168.0.2/24"
#routes_192168000001="'default via 192.168.0.1'" #routes_192168000001="default via 192.168.0.1"
#dns_servers_192168000001="192.168.0.1" #dns_servers_192168000001="192.168.0.1"
#config_010000000001="10.0.0.254/8" #config_010000000001="10.0.0.254/8"
#routes_010000000001="default via 10.0.0.1" #routes_010000000001="default via 10.0.0.1"
@ -560,10 +564,11 @@
#config_eth0="null" #config_eth0="null"
# You can also configure the VLAN - see for vconfig man page for more details # You can also configure the VLAN - see for vconfig man page for more details
#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' 'set_egress_map 2 6'" #vconfig_vlan1="set_flag 1
#config_vlan1="'172.16.3.1 netmask 255.255.254.0'" #set_egress_map 2 6"
#config_vlan2="'172.16.2.1 netmask 255.255.254.0'" #config_vlan1="172.16.3.1 netmask 255.255.254.0"
#config_vlan2="172.16.2.1 netmask 255.255.254.0"
# 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 _
@ -602,7 +607,7 @@
# Ensure that you have /etc/atmsigd.conf setup correctly # Ensure that you have /etc/atmsigd.conf setup correctly
# Now setup each clip interface like so # Now setup each clip interface like so
#clip_atm0="'peer_ip [if.]vpi.vci [opts]'" #clip_atm0="peer_ip [if.]vpi.vci [opts],"
# where "peer_ip" is the IP address of a PVC peer (in case of an ATM connection # where "peer_ip" is the IP address of a PVC peer (in case of an ATM connection
# with your ISP, your only peer is usually the ISP gateway closest to you), # with your ISP, your only peer is usually the ISP gateway closest to you),
# "if" is the number of the ATM interface which will carry the PVC, "vpi.vci" # "if" is the number of the ATM interface which will carry the PVC, "vpi.vci"
@ -610,7 +615,7 @@
# qos, pcr, and the like (see "atmarp -s" for further reference). Please also # qos, pcr, and the like (see "atmarp -s" for further reference). Please also
# note quoting: it is meant to distinguish the VCs you want to create. You may, # note quoting: it is meant to distinguish the VCs you want to create. You may,
# in example, create an atm0 interface to more peers, like this: # in example, create an atm0 interface to more peers, like this:
#clip_atm0="'1.1.1.254 0.8.35' 1.1.1.253 1.8.35'" #clip_atm0="1.1.1.254,0.8.35 1.1.1.253,1.8.35"
# By default, the PVC will use the LLC/SNAP encapsulation. If you rather need a # By default, the PVC will use the LLC/SNAP encapsulation. If you rather need a
# null encapsulation (aka "VC mode"), please add the keyword "null" to opts. # null encapsulation (aka "VC mode"), please add the keyword "null" to opts.
@ -652,38 +657,38 @@
# and may seem daunting, it is recommended that you read the pppd man page # and may seem daunting, it is recommended that you read the pppd man page
# before enabling any of them # before enabling any of them
#pppd_ppp0=" #pppd_ppp0="
# 'maxfail 0' # WARNING: It's not recommended you use this # maxfail 0 # WARNING: It's not recommended you use this
# # if you don't specify maxfail then we assume 0 # # if you don't specify maxfail then we assume 0
# 'updetach' # If not set, "/etc/init.d/net.ppp0 start" will return # updetach # If not set, "/etc/init.d/net.ppp0 start" will return
# # immediately, without waiting the link to come up # # immediately, without waiting the link to come up
# # for the first time. # # for the first time.
# # Do not use it for dial-on-demand links! # # Do not use it for dial-on-demand links!
# 'debug' # Enables syslog debugging # debug # Enables syslog debugging
# 'noauth' # Do not require the peer to authenticate itself # noauth # Do not require the peer to authenticate itself
# 'defaultroute' # Make this PPP interface the default route # defaultroute # Make this PPP interface the default route
# 'usepeerdns' # Use the DNS settings provided by PPP # usepeerdns # Use the DNS settings provided by PPP
# #
# On demand options # On demand options
# 'demand' # Enable dial on demand # demand # Enable dial on demand
# 'idle 30' # Link goes down after 30 seconds of inactivity # idle 30 # Link goes down after 30 seconds of inactivity
# '10.112.112.112:10.112.112.113' # Phony IP addresses # 10.112.112.112:10.112.112.113 # Phony IP addresses
# 'ipcp-accept-remote' # Accept the peers idea of remote address # ipcp-accept-remote # Accept the peers idea of remote address
# 'ipcp-accept-local' # Accept the peers idea of local address # ipcp-accept-local # Accept the peers idea of local address
# 'holdoff 3' # Wait 3 seconds after link dies before re-starting # holdoff 3 # Wait 3 seconds after link dies before re-starting
# #
# Dead peer detection # Dead peer detection
# 'lcp-echo-interval 15' # Send a LCP echo every 15 seconds # lcp-echo-interval 15 # Send a LCP echo every 15 seconds
# 'lcp-echo-failure 3' # Make peer dead after 3 consective # lcp-echo-failure 3 # Make peer dead after 3 consective
# # echo-requests # # echo-requests
# #
# Compression options - use these to completely disable compression # Compression options - use these to completely disable compression
# noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp # noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp
# #
# Dial-up settings # Dial-up settings
# 'lock' # Lock serial port # lock # Lock serial port
# '115200' # Set the serial port baud rate # 115200 # Set the serial port baud rate
# 'modem crtscts' # Enable hardware flow control # modem crtscts # Enable hardware flow control
# '192.168.0.1:192.168.0.2' # Local and remote IP addresses # 192.168.0.1:192.168.0.2 # Local and remote IP addresses
#" #"
# #
# Dial-up PPP users need to specify at least one telephone number # Dial-up PPP users need to specify at least one telephone number
@ -814,7 +819,9 @@
# Below is an example of configuring the bridge # Below is an example of configuring the bridge
# Consult "man brctl" for more details # Consult "man brctl" for more details
#brctl_br0="'setfd 0' 'sethello 0' 'stp off'" #brctl_br0="setfd 0
#sethello 0
#stp off"
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# RFC 2684 Bridge Support # RFC 2684 Bridge Support
@ -844,8 +851,8 @@
#iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255" #iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"
# To configure the interface # To configure the interface
#config_vpn0="'192.168.0.2 pointopoint 192.168.1.2'" # ifconfig style #config_vpn0="192.168.0.2 pointopoint 192.168.1.2" # ifconfig style
#config_vpn0="'192.168.0.2 peer 192.168.1.1'" # iproute2 style #config_vpn0="192.168.0.2 peer 192.168.1.1" # iproute2 style
# 6to4 Tunnels allow IPv6 to work over IPv4 addresses, provided you # 6to4 Tunnels allow IPv6 to work over IPv4 addresses, provided you
# have a non-private address configured on an interface. # have a non-private address configured on an interface.
@ -876,7 +883,7 @@
#dns_domain_eth0="your.domain" #dns_domain_eth0="your.domain"
#dns_servers_eth0="192.168.0.2 192.168.0.3" #dns_servers_eth0="192.168.0.2 192.168.0.3"
#dns_search_eth0="this.domain that.domain" #dns_search_eth0="this.domain that.domain"
#dns_options_eth0="'timeout:1' rotate" #dns_options_eth0="timeout:1 rotate"
#dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0" #dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0"
# See the man page for resolv.conf for details about the options and sortlist # See the man page for resolv.conf for details about the options and sortlist
# directives # directives

View File

@ -319,9 +319,7 @@ iwconfig_scan() {
i=$((${i} + 1)) i=$((${i} + 1))
done done
local i=0 e= m= black= s= local i=0 e= m= s= black="$(_get_array "blacklist_aps")"
eval "$(_get_array "blacklist_aps")"
black="$@"
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval x=\$MAC_${i} eval x=\$MAC_${i}
@ -355,13 +353,15 @@ iwconfig_scan() {
eoutdent eoutdent
fi fi
eval "$(_get_array "blacklist_aps")" local IFS="
for x in "$@" ; do "
for x in ${black}; do
if [ "${x}" = "${s}" ] ; then if [ "${x}" = "${s}" ] ; then
ewarn "${s} has been blacklisted - not connecting" ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i} unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
fi fi
done done
unset IFS
i=$((${i} + 1)) i=$((${i} + 1))
done done
eoutdent eoutdent
@ -372,11 +372,13 @@ iwconfig_force_preferred() {
[ -z "${preferred_aps}" ] && return 1 [ -z "${preferred_aps}" ] && return 1
ewarn "Trying to force preferred in case they are hidden" ewarn "Trying to force preferred in case they are hidden"
eval "$(_get_array "preferred_aps_${IFVAR}")" local pref="$(_get_array "preferred_aps_${IFVAR}")"
[ $# = 0 ] && eval "$(_get_array "preferred_aps")" [ -z "${pref}" ] && pref="$(_get_array "preferred_aps")"
local ssid= local ssid= IFS="
for ssid in "$@"; do "
for ssid in ${pref}; do
unset IFS
local found_AP=false i=0 e= local found_AP=false i=0 e=
while [ ${i} -le ${APS:--1} ] ; do while [ ${i} -le ${APS:--1} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
@ -398,11 +400,13 @@ iwconfig_force_preferred() {
iwconfig_connect_preferred() { iwconfig_connect_preferred() {
local ssid= i=0 mode= mac= caps= freq= chan= local ssid= i=0 mode= mac= caps= freq= chan=
local pref="$(_get_array "preferred_aps_${IFVAR}")"
[ -z "${pref}" ] && pref="$(_get_array "preferred_aps")"
eval "$(_get_array "preferred_aps_${IFVAR}")" local IFS="
[ $# = 0 ] && eval "$(_get_array "preferred_aps")" "
for ssid in ${pref}; do
for ssid in "$@"; do unset IFS
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
if [ "${e}" = "${ssid}" ] ; then if [ "${e}" = "${ssid}" ] ; then
@ -431,14 +435,17 @@ iwconfig_connect_not_preferred() {
continue continue
fi fi
eval "$(_get_array preferred_aps)" local prefa="$(_get_array preferred_aps)"
pref=false pref=false
for ssid in "$@" ; do local IFS="
"
for ssid in ${prefa}; do
if [ "${e}" = "${ssid}" ] ; then if [ "${e}" = "${ssid}" ] ; then
pref=true pref=true
break break
fi fi
done done
unset IFS
if ! ${pref} ; then if ! ${pref} ; then
SSID=${e} SSID=${e}

View File

@ -39,21 +39,30 @@ arping_address() {
return 0 return 0
} }
_arping_in_config() {
_get_array "config_${IFVAR}" | while read i; do
[ "${i}" = "arping" ] && return 0
done
return 1
}
arping_start() { arping_start() {
local gateways= x= conf= i= local gateways= x= conf= i=
einfo "Pinging gateways on ${IFACE} for configuration" einfo "Pinging gateways on ${IFACE} for configuration"
eval $(_get_array "gateways_${IFVAR}") eval gateways=\$gateways_${IFVAR}
if [ $# = 0 ] ; then if [ -n "${gateways}" ] ; then
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")" eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
return 1 return 1
fi fi
eindent eindent
for x in "$@"; do for x in ${gateways}; do
eval set -- "${x}" local IFS=,
set -- ${x}
local ip=$1 mac=$2 extra= local ip=$1 mac=$2 extra=
unset IFS
if [ -n "${mac}" ] ; then if [ -n "${mac}" ] ; then
mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')" mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')"
@ -90,13 +99,10 @@ arping_start() {
system_pre_start system_pre_start
# Ensure that we have a valid config - ie arping is no longer there # Ensure that we have a valid config - ie arping is no longer there
eval $(_get_array "config_${IFVAR}") if _arping_in_config; then
for i in "$@" ; do veend 1 "No config found for ${ip} (config_${conf}=\"...\")"
if [ "${i}" = "arping" ] ; then continue 2
veend 1 "No config found for ${ip} (config_${conf}=\"...\")" fi
continue 2
fi
done
_load_config _load_config
return 0 return 0

View File

@ -13,10 +13,9 @@ _is_bond() {
} }
bonding_pre_start() { bonding_pre_start() {
local s= slaves= local s= slaves="$(_get_array "slaves_${IFVAR}")"
eval $(_get_array "slaves_${IFVAR}") [ -z "${slaves}" ] && return 0
[ $# = "0" ] && return 0
# Load the kernel module if required # Load the kernel module if required
if [ ! -d /proc/net/bonding ] ; then if [ ! -d /proc/net/bonding ] ; then
@ -40,16 +39,16 @@ bonding_pre_start() {
ebegin "Adding slaves to ${IFACE}" ebegin "Adding slaves to ${IFACE}"
eindent eindent
einfo "$@" einfo "${slaves}"
# Check that our slaves exist # Check that our slaves exist
( (
for IFACE in "$@" ; do for IFACE in ${slaves}; do
_exists true || return 1 _exists true || return 1
done done
# Must force the slaves to a particular state before adding them # Must force the slaves to a particular state before adding them
for IFACE in "$@" ; do for IFACE in ${slaves}; do
_delete_addresses _delete_addresses
_up _up
done done
@ -60,7 +59,7 @@ bonding_pre_start() {
# finally add in slaves # finally add in slaves
eoutdent eoutdent
/sbin/ifenslave "${IFACE}" $@ >/dev/null /sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
eend $? eend $?
return 0 #important return 0 #important

View File

@ -13,12 +13,11 @@ _is_bridge() {
} }
bridge_pre_start() { bridge_pre_start() {
local ports= brif= opts= iface="${IFACE}" e= x= local ports= brif= iface="${IFACE}" e= x=
eval $(_get_array "bridge_${IFVAR}") local ports="$(_get_array "bridge_${IFVAR}")"
ports="$@" local opts="$(_get_array "brctl_${IFVAR}")"
eval brif=\$bridge_add_${IFVAR} eval brif=\$bridge_add_${IFVAR}
eval $(_get_array "brctl_${IFVAR}")
opts="$@"
[ -z "${ports}" -a -z "${brif}" -a -z "${opts}" ] && return 0 [ -z "${ports}" -a -z "${brif}" -a -z "${opts}" ] && return 0
[ -n "${ports}" ] && bridge_post_stop [ -n "${ports}" ] && bridge_post_stop
@ -32,7 +31,7 @@ bridge_pre_start() {
metric=1000 metric=1000
fi fi
if ! _is_bridge ; then if ! _is_bridge; then
ebegin "Creating bridge ${IFACE}" ebegin "Creating bridge ${IFACE}"
if ! brctl addbr "${IFACE}" ; then if ! brctl addbr "${IFACE}" ; then
eend 1 eend 1
@ -40,8 +39,10 @@ bridge_pre_start() {
fi fi
fi fi
eval $(_get_array "brctl_${IFVAR}") local IFS="
for x in "$@" ; do "
for x in ${opts}; do
unset IFS
set -- ${x} set -- ${x}
x=$1 x=$1
shift shift
@ -53,8 +54,7 @@ bridge_pre_start() {
einfo "Adding ports to ${IFACE}" einfo "Adding ports to ${IFACE}"
eindent eindent
eval set -- ${ports} for x in ${ports}; do
for x in "$@" ; do
ebegin "${x}" ebegin "${x}"
ifconfig "${x}" promisc up ifconfig "${x}" promisc up
if ! brctl addif "${IFACE}" "${x}" ; then if ! brctl addif "${IFACE}" "${x}" ; then

View File

@ -9,8 +9,8 @@ ccwgroup_depend() {
} }
ccwgroup_pre_start() { ccwgroup_pre_start() {
eval $(_get_array "ccwgroup_${IFVAR}") local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ $# = "0" ] && return 0 [ -z "${ccwgroup}" ] && return 0
if [ ! -d /sys/bus/ccwgroup ] ; then if [ ! -d /sys/bus/ccwgroup ] ; then
modprobe qeth modprobe qeth
@ -22,7 +22,7 @@ ccwgroup_pre_start() {
einfo "Enabling ccwgroup on ${IFACE}" einfo "Enabling ccwgroup on ${IFACE}"
local x= ccw= first= layer2= local x= ccw= first= layer2=
for x in "$@" ; do for x in ${ccwgroup}; do
[ -z "${first}" ] && first=${x} [ -z "${first}" ] && first=${x}
ccw="${ccw}${ccw:+,}${x}" ccw="${ccw}${ccw:+,}${x}"
done done

View File

@ -79,8 +79,9 @@ are_atmclip_svcs_running() {
} }
clip_pre_start() { clip_pre_start() {
eval $(_get_array "clip_${IFVAR}") local clip=
[ $# = 0 ] && return 0 eval clip=\$clip_${IFVAR}
[ -z "${clip}" ] && return 0
if [ ! -r /proc/net/atm/arp ] ; then if [ ! -r /proc/net/atm/arp ] ; then
modprobe clip && sleep 2 modprobe clip && sleep 2
@ -109,8 +110,8 @@ clip_pre_start() {
} }
clip_post_start() { clip_post_start() {
eval $(_get_array "clip_${IFVAR}") local clip="$(_get_array "clip_${IFVAR}")"
[ $# = 0 ] && return 0 [ -z "${clip}" ] && return 0
are_atmclip_svcs_running || return 1 are_atmclip_svcs_running || return 1
@ -129,8 +130,10 @@ clip_post_start() {
# reporting problems. Also, when no defined VC can be established, # reporting problems. Also, when no defined VC can be established,
# we stop the ATM daemons. # we stop the ATM daemons.
local has_failures= i= local has_failures= i=
for i in "$@" ; do for i in ${clip} ; do
local IFS=","
set -- ${i} set -- ${i}
unset IFS
local peerip="$1"; shift local peerip="$1"; shift
local ifvpivci="$1"; shift local ifvpivci="$1"; shift
ebegin "Creating PVC ${ifvpivci} for peer ${peerip}" ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"

View File

@ -96,8 +96,9 @@ ip6to4_start() {
config_index=$((${config_index} - 1)) config_index=$((${config_index} - 1))
# Add a route for us, ensuring we don't delete anything else # Add a route for us, ensuring we don't delete anything else
eval $(_get_array "routes_${IFVAR}") local routes="$(_get_array "routes_${IFVAR}")
eval routes_${IFVAR}="\"$@ '2003::/3 via ::${relay} metric 2147483647'\"" 2003::/3 via ::${relay} metric 2147483647"
eval routes_${IFVAR}=\$routes
} }
# vim: set ts=4 : # vim: set ts=4 :

View File

@ -114,19 +114,26 @@ iwconfig_get_wep_key() {
} }
iwconfig_user_config() { iwconfig_user_config() {
local conf= var=${SSIDVAR} local conf= var=${SSIDVAR} config=
[ -z "${var}" ] && var=${IFVAR} [ -z "${var}" ] && var=${IFVAR}
eval "$(_get_array "iwconfig_${var}")" config="$(_get_array "iwconfig_${var}")"
for conf in "$@" ; do local IFS="
"
for conf in ${config}; do
unset IFS
if ! eval iwconfig "${IFACE}" "${conf}" ; then if ! eval iwconfig "${IFACE}" "${conf}" ; then
ewarn "${IFACE} does not support the following configuration commands" ewarn "${IFACE} does not support the following configuration commands"
ewarn " ${conf}" ewarn " ${conf}"
fi fi
done done
unset IFS
eval "$(_get_array "iwpriv_${var}")" config="$(_get_array "iwpriv_${var}")"
for conf in "$@" ; do local IFS="
"
for conf in ${config}; do
unset IFS
if ! eval iwpriv "${IFACE}" "${conf}" ; then if ! eval iwpriv "${IFACE}" "${conf}" ; then
ewarn "${IFACE} does not support the following private ioctls" ewarn "${IFACE} does not support the following private ioctls"
ewarn " ${conf}" ewarn " ${conf}"
@ -472,13 +479,17 @@ iwconfig_scan() {
eoutdent eoutdent
fi fi
eval "$(_get_array "blacklist_aps")" local blacklist="$(_get_array "blacklist_aps")"
for x in "$@" ; do local IFS="
"
for x in ${blacklist}; do
unset IFS
if [ "${x}" = "${s}" ] ; then if [ "${x}" = "${s}" ] ; then
ewarn "${s} has been blacklisted - not connecting" ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i} unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi fi
done done
unset IFS
i=$((${i} + 1)) i=$((${i} + 1))
done done
eoutdent eoutdent
@ -488,9 +499,11 @@ iwconfig_force_preferred() {
[ -z "${preferred_aps}" ] && return 1 [ -z "${preferred_aps}" ] && return 1
ewarn "Trying to force preferred in case they are hidden" ewarn "Trying to force preferred in case they are hidden"
eval "(_get_array "preferred_aps")" local pref="$(_get_array "preferred_aps")" ssid=
local ssid= local IFS="
for ssid in "$@"; do "
for ssid in ${pref}; do
unset IFS
local found_AP=false i=0 e= local found_AP=false i=0 e=
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
@ -512,9 +525,11 @@ iwconfig_force_preferred() {
iwconfig_connect_preferred() { iwconfig_connect_preferred() {
local ssid= i= mode= mac= enc= freq= chan= local ssid= i= mode= mac= enc= freq= chan=
local pref="$(_get_array preferred_aps)"
eval "$(_get_array preferred_aps)" local IFS="
for ssid in "$@"; do "
for ssid in ${pref}; do
unset IFS
i=0 i=0
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
@ -541,13 +556,16 @@ iwconfig_connect_not_preferred() {
while [ ${i} -le ${APS} ] ; do while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i} eval e=\$SSID_${i}
if [ -n "${e}" ] ; then if [ -n "${e}" ] ; then
eval "$(_get_array preferred_aps)" local prefa="$(_get_array preferred_aps)"
for ssid in "$@" ; do local IFS="
"
for ssid in ${prefa}; do
if [ "${e}" = "${ssid}" ] ; then if [ "${e}" = "${ssid}" ] ; then
pref=true pref=true
break break
fi fi
done done
unset IFS
if ! ${pref} ; then if ! ${pref} ; then
SSID=${e} SSID=${e}

View File

@ -33,7 +33,7 @@ pppd_pre_start() {
return 0 return 0
fi fi
local link= i= opts= unit="${IFACE#ppp}" mtu= local link= i= unit="${IFACE#ppp}" opts=
# PPP requires a link to communicate over - normally a serial port # PPP requires a link to communicate over - normally a serial port
# PPPoE communicates over Ethernet # PPPoE communicates over Ethernet
@ -57,16 +57,14 @@ pppd_pre_start() {
return 1 return 1
fi fi
eval $(_get_array "pppd_${IFVAR}") eval opts=\$pppd_${IFVAR}
opts="$@"
local mtu= hasmtu=false hasmru=false hasmaxfail=false haspersist=false local mtu= hasmtu=false hasmru=false hasmaxfail=false haspersist=false
local hasupdetach=false hasdefaultmetric=false local hasupdetach=false hasdefaultmetric=false
for i in "$@" ; do for i in ${opts}; do
set -- ${i} case "${i}" in
case "$1" in
unit|nodetach|linkname) unit|nodetach|linkname)
eerror "The option \"$1\" is not allowed in pppd_${IFVAR}" eerror "The option \"${i}\" is not allowed in pppd_${IFVAR}"
return 1 return 1
;; ;;
defaultmetric) hasdefaultmetric=true ;; defaultmetric) hasdefaultmetric=true ;;
@ -113,25 +111,31 @@ pppd_pre_start() {
# Load a custom interface configuration file if it exists # Load a custom interface configuration file if it exists
[ -f "/etc/ppp/options.${IFACE}" ] \ [ -f "/etc/ppp/options.${IFACE}" ] \
&& opts="${opts} file /etc/ppp/options.${IFACE}" && opts="${opts} file '/etc/ppp/options.${IFACE}'"
# Set unit # Set unit
opts="unit ${unit} ${opts}" opts="unit ${unit} ${opts}"
# Setup connect script # Setup connect script
local chatopts="/usr/sbin/chat -e -E -v" local chatopts="/usr/sbin/chat -e -E -v" phone=
eval $(_get_array "phone_number_${IFVAR}") eval phone=\$phone_number_${IFVAR}
set -- ${phone}
[ -n "$1" ] && chatopts="${chatopts} -T '$1'" [ -n "$1" ] && chatopts="${chatopts} -T '$1'"
[ -n "$2" ] && chatopts="${chatopts} -U '$2'" [ -n "$2" ] && chatopts="${chatopts} -U '$2'"
eval $(_get_array "chat_${IFVAR}") local chat="$(_get_array "chat_${IFVAR}")"
if [ $# != 0 ] ; then if [ "${chat}" ] ; then
local IFS="
"
opts="${opts} connect $(printf "\\'%s\\'" "${chatopts} $(printf "\\'\\\\'\\'%s\\'\\\'' " "$@")")" opts="${opts} connect $(printf "\\'%s\\'" "${chatopts} $(printf "\\'\\\\'\\'%s\\'\\\'' " "$@")")"
unset IFS
fi fi
# Add plugins # Add plugins
local haspppoa=false haspppoe=false local haspppoa=false haspppoe=false plugins="$(_get_array "plugins_${IFVAR}")"
eval $(_get_array "plugins_${IFVAR}") local IFS="
for i in "$@" ; do "
for i in ${plugins}; do
unset IFS
set -- ${i} set -- ${i}
case "$1" in case "$1" in
passwordfd) continue;; passwordfd) continue;;
@ -151,6 +155,7 @@ pppd_pre_start() {
shift shift
opts="${opts} $@" opts="${opts} $@"
done done
unset IFS
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) #Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
local insert_link_in_opts=1 local insert_link_in_opts=1

View File

@ -31,14 +31,17 @@ _check_vlan() {
} }
vlan_pre_start() { vlan_pre_start() {
eval $(_get_array "vconfig_${IFVAR}") local vc="$(_get_array "vconfig_${IFVAR}")"
[ $# = "0" ] && return 0 [ -z "${vc}" ] && return 0
_check_vlan || return 1 _check_vlan || return 1
_exists || return 1 _exists || return 1
local v= x= e= local v= x= e=
for v in "$@" ; do local IFS="
"
for v in ${vc}; do
unset IFS
case "${v}" in case "${v}" in
set_name_type" "*) x=${v} ;; set_name_type" "*) x=${v} ;;
*) x="$(echo "${v}" | sed -e "s/ / ${IFACE} /g")" *) x="$(echo "${v}" | sed -e "s/ / ${IFACE} /g")"
@ -56,14 +59,15 @@ vlan_pre_start() {
} }
vlan_post_start() { vlan_post_start() {
eval $(_get_array "vlans_${IFVAR}") local vlans=
[ $# = "0" ] && return 0 eval vlans=\$vlans_${IFACE}
[ -z "${vlans}" ] && return 0
_check_vlan || return 1 _check_vlan || return 1
_exists || return 1 _exists || return 1
local vlan= e= s= local vlan= e= s=
for vlan in "$@" ; do for vlan in ${vlans}; do
einfo "Adding VLAN ${vlan} to ${IFACE}" einfo "Adding VLAN ${vlan} to ${IFACE}"
e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)" e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)"
if [ -n "${e}" ] ; then if [ -n "${e}" ] ; then
@ -92,7 +96,7 @@ vlan_post_start() {
vlan_post_stop() { vlan_post_stop() {
local vlan= local vlan=
for vlan in $(_get_vlans) ; do for vlan in $(_get_vlans); do
einfo "Removing VLAN ${vlan##*.} from ${IFACE}" einfo "Removing VLAN ${vlan##*.} from ${IFACE}"
( (
export SVCNAME="net.${vlan}" export SVCNAME="net.${vlan}"

View File

@ -40,20 +40,24 @@ _shell_var() {
echo -n "$1" | sed -e 's/[^[:alnum:]]/_/g' echo -n "$1" | sed -e 's/[^[:alnum:]]/_/g'
} }
# Credit to David Leverton for this function which handily maps a bash array # Support bash arrays - sigh
# structure to positional parameters so existing configs work :)
# We'll deprecate arrays at some point though.
_get_array() { _get_array() {
local _a=
if [ -n "${BASH}" ] ; then if [ -n "${BASH}" ] ; then
case "$(declare -p "$1" 2>/dev/null)" in case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*) "declare -a "*)
echo "set -- \"\${$1[@]}\"" eval "set -- \"\${$1[@]}\""
return for _a in "$@"; do
printf "%s\n" "${_a}"
done
return 0
;; ;;
esac esac
fi fi
echo "eval set -- \"\$$1\"" eval _a=\$$1
printf "%s" "${_a}"
[ -n "${_a}" ]
} }
_wait_for_carrier() { _wait_for_carrier() {
@ -339,20 +343,25 @@ _load_modules() {
} }
_load_config() { _load_config() {
eval "$(_get_array "config_${IFVAR}")" local config="$(_get_array "config_${IFVAR}")"
local fallback="$(_get_array fallback_${IFVAR})"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
set -- "127.0.0.1/8" "$@" config="127.0.0.1/8
${config}"
else else
if [ $# -eq 0 ] ; then if [ -z "${config}" ] ; then
ewarn "No configuration specified; defaulting to DHCP" ewarn "No configuration specified; defaulting to DHCP"
set -- "dhcp" config="dhcp"
fi fi
fi 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
for cmd in "$@" ; do local IFS="
"
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
@ -360,8 +369,7 @@ _load_config() {
eval config_${config_index}= eval config_${config_index}=
config_index=0 config_index=0
eval "$(_get_array fallback_${IFVAR})" for cmd in ${fallback}; do
for cmd in "$@" ; do
eval fallback_${config_index}="'${cmd}'" eval fallback_${config_index}="'${cmd}'"
config_index=$((${config_index} + 1)) config_index=$((${config_index} + 1))
done done
@ -483,14 +491,18 @@ start() {
return 1 return 1
fi fi
local hidefirstroute=false first=true routes= local hidefirstroute=false first=true
eval "$(_get_array "routes_${IFVAR}")" local routes="$(_get_array "routes_${IFVAR}")"
if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then if [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] ; then
set -- "127.0.0.0/8 via 127.0.0.1" "$@" routes="127.0.0.0/8 via 127.0.0.1
${routes}"
hidefirstroute=true hidefirstroute=true
fi fi
for cmd in "$@" ; do local IFS="
if ${first} ; then "
for cmd in ${routes}; do
unset IFS
if ${first}; then
first=false first=false
einfo "Adding routes" einfo "Adding routes"
fi fi