aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-29 09:45:49 +0000
committerRoy Marples <roy@marples.name>2007-10-29 09:45:49 +0000
commite372729b8cc489af7b1b2305d6fd9c1895b9c8d4 (patch)
tree5ffa0e392d92a03bd23fe8f00aa2d6a26d41ffbb
parent42c231d7609447cb96d98cbebdc12a197324fb99 (diff)
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.
-rw-r--r--ChangeLog6
-rw-r--r--conf.d.BSD/net.example45
-rw-r--r--conf.d.Linux/net.example125
-rw-r--r--net.BSD/iwconfig.sh37
-rw-r--r--net.Linux/arping.sh28
-rw-r--r--net.Linux/bonding.sh13
-rw-r--r--net.Linux/bridge.sh20
-rw-r--r--net.Linux/ccwgroup.sh6
-rw-r--r--net.Linux/clip.sh13
-rw-r--r--net.Linux/ip6to4.sh5
-rw-r--r--net.Linux/iwconfig.sh48
-rw-r--r--net.Linux/pppd.sh35
-rw-r--r--net.Linux/vlan.sh18
-rwxr-xr-xsh/net.sh48
14 files changed, 260 insertions, 187 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e5e6a12..8d1eb578 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# 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>:
clock init script now works with busybox hwclock.
diff --git a/conf.d.BSD/net.example b/conf.d.BSD/net.example
index 134bee86..235b6058 100644
--- a/conf.d.BSD/net.example
+++ b/conf.d.BSD/net.example
@@ -42,27 +42,29 @@
# 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 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'"
+#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
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
# (eth0:1, eth0:2, etc)
# 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
-#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
# fallbacks, you have to ensure that both end up with the same number of
# values otherwise your fallback won't work correctly.
# You can also use IPv6 addresses
# (you should always specify a prefix length with IPv6 here)
-#config_eth0="192.168.0.2/24 \
-#4321:0:1:2:3:4:567:89ab/64 \
+#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"
# 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)
# This is useful when configuring your interface with a kernel command line
# 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)
#config_eth0="null"
# Here's how to do routing if you need it
# We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route
-#routes_eth0=" \
-# 'default via 192.168.0.1' \
-# '10.0.0.0/8 via 192.168.0.1' \
-# '::/0' \
-#"
+#routes_eth0="default via 192.168.0.1
+#10.0.0.0/8 via 192.168.0.1
+#::/0"
# If a specified module fails (like dhcp - see below), you can specify a
# fallback like so
-#fallback_eth0="'192.168.0.2 netmask 255.255.255.0'"
-#fallback_route_eth0="'default via 192.168.0.1'"
+#fallback_eth0="192.168.0.2 netmask 255.255.255.0"
+#fallback_route_eth0="default via 192.168.0.1"
# NOTE: fallback entry must match the entry location in config_eth0
# 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
# 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
-#preferred_aps="'ESSID 1' 'ESSID 2'"
+#preferred_aps="ESSID 1
+#ESSID 2"
# 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
# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly"
@@ -234,8 +237,10 @@
#associate_order_eth0="any"
# You can define blacklisted Access Points in the same way
-#blacklist_aps="'ESSID 1' 'ESSID 2'"
-#blacklist_aps_eth0="'ESSID 3' 'ESSID 4'"
+#blacklist_aps="ESSID 1
+#ESSID 2"
+#blacklist_aps_eth0="ESSID 3
+#ESSID 4"
# 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
@@ -354,7 +359,7 @@
#dns_domain_eth0="your.domain"
#dns_servers_eth0="192.168.0.2 192.168.0.3"
#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"
# See the man page for resolv.conf for details about the options and sortlist
# directives
diff --git a/conf.d.Linux/net.example b/conf.d.Linux/net.example
index 584000e2..ed69d13d 100644
--- a/conf.d.Linux/net.example
+++ b/conf.d.Linux/net.example
@@ -27,14 +27,15 @@
# 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"
+# 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'
+# 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
-# value has no spaces, therefore no additional quoting is required.
-# The last statement is invalid because when it is evaluated, it only has one
-# set of quotes.
+# Basically if array elements may need spaces in their values then we separate
+# on a hard coded new line.
##############################################################################
# MODULES
@@ -80,27 +81,29 @@
# 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 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'"
+#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
# NOTE: ifconfig creates an aliased device for each extra IPv4 address
# (eth0:1, eth0:2, etc)
# 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
-#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
# fallbacks, you have to ensure that both end up with the same number of
# values otherwise your fallback won't work correctly.
# You can also use IPv6 addresses
# (you should always specify a prefix length with IPv6 here)
-#config_eth0="192.168.0.2/24 \
-#4321:0:1:2:3:4:567:89ab/64 \
+#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"
#)
@@ -109,23 +112,22 @@
# 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
# 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)
#config_eth0="null"
# Here's how to do routing if you need it
# We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route
-#routes_eth0=" \
-# 'default via 192.168.0.1' \
-# '10.0.0.0/8 via 192.168.0.1' \
-# '::/0' \
-#"
+#routes_eth0="default via 192.168.0.1
+#10.0.0.0/8 via 192.168.0.1
+#::/0"
# If a specified module fails (like dhcp - see below), you can specify a
# fallback like so
-#fallback_eth0="'192.168.0.2 netmask 255.255.255.0'"
-#fallback_route_eth0="'default via 192.168.0.1'"
+#fallback_eth0="192.168.0.2 netmask 255.255.255.0"
+#fallback_route_eth0="default via 192.168.0.1"
# NOTE: fallback entry must match the entry location in config_eth0
# 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
# you can set WPA here, below is an example.
#iwpriv_eth0=""
-#iwpriv_SSID=" \
-# 'set AuthMode=WPAPSK' \
-# 'set EncrypType=TKIP' \
-# 'set WPAPSK=yourpasskey' \
-#"
+#iwpriv_SSID="set AuthMode=WPAPSK
+#set EncrypType=TKIP
+#set WPAPSK=yourpasskey"
#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
#used though.
@@ -326,10 +326,12 @@
# 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 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
-#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
# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" and "forceany"
@@ -346,8 +348,10 @@
#associate_order_eth0="any"
# You can define blacklisted Access Points in the same way
-#blacklist_aps="'SSID 1' 'SSID 2'"
-#blacklist_aps_eth0="'SSID 3' 'SSID 4'"
+#blacklist_aps="SSID 1
+#SSID 2"
+#blacklist_aps_eth0="SSID 3
+#SSID 4"
# 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
@@ -508,7 +512,7 @@
#
#gateways_eth0="192.168.0.1 10.0.0.1"
#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"
#config_010000000001="10.0.0.254/8"
#routes_010000000001="default via 10.0.0.1"
@@ -560,10 +564,11 @@
#config_eth0="null"
# 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_vlan1="'set_flag 1' 'set_egress_map 2 6'"
-#config_vlan1="'172.16.3.1 netmask 255.255.254.0'"
-#config_vlan2="'172.16.2.1 netmask 255.255.254.0'"
+#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
+#vconfig_vlan1="set_flag 1
+#set_egress_map 2 6"
+#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
# 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
# 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
# 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"
@@ -610,7 +615,7 @@
# 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,
# 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
# 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
# before enabling any of them
#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
-# '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
# # for the first time.
# # Do not use it for dial-on-demand links!
-# 'debug' # Enables syslog debugging
-# 'noauth' # Do not require the peer to authenticate itself
-# 'defaultroute' # Make this PPP interface the default route
-# 'usepeerdns' # Use the DNS settings provided by PPP
+# debug # Enables syslog debugging
+# noauth # Do not require the peer to authenticate itself
+# defaultroute # Make this PPP interface the default route
+# usepeerdns # Use the DNS settings provided by PPP
#
# On demand options
-# 'demand' # Enable dial on demand
-# 'idle 30' # Link goes down after 30 seconds of inactivity
-# '10.112.112.112:10.112.112.113' # Phony IP addresses
-# 'ipcp-accept-remote' # Accept the peers idea of remote address
-# 'ipcp-accept-local' # Accept the peers idea of local address
-# 'holdoff 3' # Wait 3 seconds after link dies before re-starting
+# demand # Enable dial on demand
+# idle 30 # Link goes down after 30 seconds of inactivity
+# 10.112.112.112:10.112.112.113 # Phony IP addresses
+# ipcp-accept-remote # Accept the peers idea of remote address
+# ipcp-accept-local # Accept the peers idea of local address
+# holdoff 3 # Wait 3 seconds after link dies before re-starting
#
# Dead peer detection
-# 'lcp-echo-interval 15' # Send a LCP echo every 15 seconds
-# 'lcp-echo-failure 3' # Make peer dead after 3 consective
+# lcp-echo-interval 15 # Send a LCP echo every 15 seconds
+# lcp-echo-failure 3 # Make peer dead after 3 consective
# # echo-requests
#
# Compression options - use these to completely disable compression
# noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp
#
# Dial-up settings
-# 'lock' # Lock serial port
-# '115200' # Set the serial port baud rate
-# 'modem crtscts' # Enable hardware flow control
-# '192.168.0.1:192.168.0.2' # Local and remote IP addresses
+# lock # Lock serial port
+# 115200 # Set the serial port baud rate
+# modem crtscts # Enable hardware flow control
+# 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
@@ -814,7 +819,9 @@
# Below is an example of configuring the bridge
# 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
@@ -844,8 +851,8 @@
#iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"
# To configure the interface
-#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 pointopoint 192.168.1.2" # ifconfig 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
# have a non-private address configured on an interface.
@@ -876,7 +883,7 @@
#dns_domain_eth0="your.domain"
#dns_servers_eth0="192.168.0.2 192.168.0.3"
#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"
# See the man page for resolv.conf for details about the options and sortlist
# directives
diff --git a/net.BSD/iwconfig.sh b/net.BSD/iwconfig.sh
index 63e9623a..87fcc954 100644
--- a/net.BSD/iwconfig.sh
+++ b/net.BSD/iwconfig.sh
@@ -319,9 +319,7 @@ iwconfig_scan() {
i=$((${i} + 1))
done
- local i=0 e= m= black= s=
- eval "$(_get_array "blacklist_aps")"
- black="$@"
+ local i=0 e= m= s= black="$(_get_array "blacklist_aps")"
while [ ${i} -le ${APS} ] ; do
eval x=\$MAC_${i}
@@ -355,13 +353,15 @@ iwconfig_scan() {
eoutdent
fi
- eval "$(_get_array "blacklist_aps")"
- for x in "$@" ; do
+ local IFS="
+"
+ for x in ${black}; do
if [ "${x}" = "${s}" ] ; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} CAPS_${i}
fi
done
+ unset IFS
i=$((${i} + 1))
done
eoutdent
@@ -372,11 +372,13 @@ iwconfig_force_preferred() {
[ -z "${preferred_aps}" ] && return 1
ewarn "Trying to force preferred in case they are hidden"
- eval "$(_get_array "preferred_aps_${IFVAR}")"
- [ $# = 0 ] && eval "$(_get_array "preferred_aps")"
+ local pref="$(_get_array "preferred_aps_${IFVAR}")"
+ [ -z "${pref}" ] && pref="$(_get_array "preferred_aps")"
- local ssid=
- for ssid in "$@"; do
+ local ssid= IFS="
+"
+ for ssid in ${pref}; do
+ unset IFS
local found_AP=false i=0 e=
while [ ${i} -le ${APS:--1} ] ; do
eval e=\$SSID_${i}
@@ -398,11 +400,13 @@ iwconfig_force_preferred() {
iwconfig_connect_preferred() {
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}")"
- [ $# = 0 ] && eval "$(_get_array "preferred_aps")"
-
- for ssid in "$@"; do
+ local IFS="
+"
+ for ssid in ${pref}; do
+ unset IFS
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
if [ "${e}" = "${ssid}" ] ; then
@@ -431,14 +435,17 @@ iwconfig_connect_not_preferred() {
continue
fi
- eval "$(_get_array preferred_aps)"
+ local prefa="$(_get_array preferred_aps)"
pref=false
- for ssid in "$@" ; do
+ local IFS="
+ "
+ for ssid in ${prefa}; do
if [ "${e}" = "${ssid}" ] ; then
pref=true
break
fi
done
+ unset IFS
if ! ${pref} ; then
SSID=${e}
diff --git a/net.Linux/arping.sh b/net.Linux/arping.sh
index 817f8b2d..68d04216 100644
--- a/net.Linux/arping.sh
+++ b/net.Linux/arping.sh
@@ -39,21 +39,30 @@ arping_address() {
return 0
}
+_arping_in_config() {
+ _get_array "config_${IFVAR}" | while read i; do
+ [ "${i}" = "arping" ] && return 0
+ done
+ return 1
+}
+
arping_start() {
local gateways= x= conf= i=
einfo "Pinging gateways on ${IFACE} for configuration"
- eval $(_get_array "gateways_${IFVAR}")
- if [ $# = 0 ] ; then
+ eval gateways=\$gateways_${IFVAR}
+ if [ -n "${gateways}" ] ; then
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
return 1
fi
eindent
- for x in "$@"; do
- eval set -- "${x}"
+ for x in ${gateways}; do
+ local IFS=,
+ set -- ${x}
local ip=$1 mac=$2 extra=
+ unset IFS
if [ -n "${mac}" ] ; then
mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')"
@@ -90,13 +99,10 @@ arping_start() {
system_pre_start
# Ensure that we have a valid config - ie arping is no longer there
- eval $(_get_array "config_${IFVAR}")
- for i in "$@" ; do
- if [ "${i}" = "arping" ] ; then
- veend 1 "No config found for ${ip} (config_${conf}=\"...\")"
- continue 2
- fi
- done
+ if _arping_in_config; then
+ veend 1 "No config found for ${ip} (config_${conf}=\"...\")"
+ continue 2
+ fi
_load_config
return 0
diff --git a/net.Linux/bonding.sh b/net.Linux/bonding.sh
index 1f8b6377..ed3d9827 100644
--- a/net.Linux/bonding.sh
+++ b/net.Linux/bonding.sh
@@ -13,10 +13,9 @@ _is_bond() {
}
bonding_pre_start() {
- local s= slaves=
+ local s= slaves="$(_get_array "slaves_${IFVAR}")"
- eval $(_get_array "slaves_${IFVAR}")
- [ $# = "0" ] && return 0
+ [ -z "${slaves}" ] && return 0
# Load the kernel module if required
if [ ! -d /proc/net/bonding ] ; then
@@ -40,16 +39,16 @@ bonding_pre_start() {
ebegin "Adding slaves to ${IFACE}"
eindent
- einfo "$@"
+ einfo "${slaves}"
# Check that our slaves exist
(
- for IFACE in "$@" ; do
+ for IFACE in ${slaves}; do
_exists true || return 1
done
# Must force the slaves to a particular state before adding them
- for IFACE in "$@" ; do
+ for IFACE in ${slaves}; do
_delete_addresses
_up
done
@@ -60,7 +59,7 @@ bonding_pre_start() {
# finally add in slaves
eoutdent
- /sbin/ifenslave "${IFACE}" $@ >/dev/null
+ /sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
eend $?
return 0 #important
diff --git a/net.Linux/bridge.sh b/net.Linux/bridge.sh
index a6913fd9..e5b1df65 100644
--- a/net.Linux/bridge.sh
+++ b/net.Linux/bridge.sh
@@ -13,12 +13,11 @@ _is_bridge() {
}
bridge_pre_start() {
- local ports= brif= opts= iface="${IFACE}" e= x=
- eval $(_get_array "bridge_${IFVAR}")
- ports="$@"
+ local ports= brif= iface="${IFACE}" e= x=
+ local ports="$(_get_array "bridge_${IFVAR}")"
+ local opts="$(_get_array "brctl_${IFVAR}")"
+
eval brif=\$bridge_add_${IFVAR}
- eval $(_get_array "brctl_${IFVAR}")
- opts="$@"
[ -z "${ports}" -a -z "${brif}" -a -z "${opts}" ] && return 0
[ -n "${ports}" ] && bridge_post_stop
@@ -32,7 +31,7 @@ bridge_pre_start() {
metric=1000
fi
- if ! _is_bridge ; then
+ if ! _is_bridge; then
ebegin "Creating bridge ${IFACE}"
if ! brctl addbr "${IFACE}" ; then
eend 1
@@ -40,8 +39,10 @@ bridge_pre_start() {
fi
fi
- eval $(_get_array "brctl_${IFVAR}")
- for x in "$@" ; do
+ local IFS="
+"
+ for x in ${opts}; do
+ unset IFS
set -- ${x}
x=$1
shift
@@ -53,8 +54,7 @@ bridge_pre_start() {
einfo "Adding ports to ${IFACE}"
eindent
- eval set -- ${ports}
- for x in "$@" ; do
+ for x in ${ports}; do
ebegin "${x}"
ifconfig "${x}" promisc up
if ! brctl addif "${IFACE}" "${x}" ; then
diff --git a/net.Linux/ccwgroup.sh b/net.Linux/ccwgroup.sh
index 1cba04cb..c32b1ffb 100644
--- a/net.Linux/ccwgroup.sh
+++ b/net.Linux/ccwgroup.sh
@@ -9,8 +9,8 @@ ccwgroup_depend() {
}
ccwgroup_pre_start() {
- eval $(_get_array "ccwgroup_${IFVAR}")
- [ $# = "0" ] && return 0
+ local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
+ [ -z "${ccwgroup}" ] && return 0
if [ ! -d /sys/bus/ccwgroup ] ; then
modprobe qeth
@@ -22,7 +22,7 @@ ccwgroup_pre_start() {
einfo "Enabling ccwgroup on ${IFACE}"
local x= ccw= first= layer2=
- for x in "$@" ; do
+ for x in ${ccwgroup}; do
[ -z "${first}" ] && first=${x}
ccw="${ccw}${ccw:+,}${x}"
done
diff --git a/net.Linux/clip.sh b/net.Linux/clip.sh
index 7d3fef9b..771ec204 100644
--- a/net.Linux/clip.sh
+++ b/net.Linux/clip.sh
@@ -79,8 +79,9 @@ are_atmclip_svcs_running() {
}
clip_pre_start() {
- eval $(_get_array "clip_${IFVAR}")
- [ $# = 0 ] && return 0
+ local clip=
+ eval clip=\$clip_${IFVAR}
+ [ -z "${clip}" ] && return 0
if [ ! -r /proc/net/atm/arp ] ; then
modprobe clip && sleep 2
@@ -109,8 +110,8 @@ clip_pre_start() {
}
clip_post_start() {
- eval $(_get_array "clip_${IFVAR}")
- [ $# = 0 ] && return 0
+ local clip="$(_get_array "clip_${IFVAR}")"
+ [ -z "${clip}" ] && return 0
are_atmclip_svcs_running || return 1
@@ -129,8 +130,10 @@ clip_post_start() {
# reporting problems. Also, when no defined VC can be established,
# we stop the ATM daemons.
local has_failures= i=
- for i in "$@" ; do
+ for i in ${clip} ; do
+ local IFS=","
set -- ${i}
+ unset IFS
local peerip="$1"; shift
local ifvpivci="$1"; shift
ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"
diff --git a/net.Linux/ip6to4.sh b/net.Linux/ip6to4.sh
index 54cbe8ae..a4a477a3 100644
--- a/net.Linux/ip6to4.sh
+++ b/net.Linux/ip6to4.sh
@@ -96,8 +96,9 @@ ip6to4_start() {
config_index=$((${config_index} - 1))
# Add a route for us, ensuring we don't delete anything else
- eval $(_get_array "routes_${IFVAR}")
- eval routes_${IFVAR}="\"$@ '2003::/3 via ::${relay} metric 2147483647'\""
+ local routes="$(_get_array "routes_${IFVAR}")
+2003::/3 via ::${relay} metric 2147483647"
+ eval routes_${IFVAR}=\$routes
}
# vim: set ts=4 :
diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh
index 1caae611..5f1c1738 100644
--- a/net.Linux/iwconfig.sh
+++ b/net.Linux/iwconfig.sh
@@ -114,19 +114,26 @@ iwconfig_get_wep_key() {
}
iwconfig_user_config() {
- local conf= var=${SSIDVAR}
+ local conf= var=${SSIDVAR} config=
[ -z "${var}" ] && var=${IFVAR}
- eval "$(_get_array "iwconfig_${var}")"
- for conf in "$@" ; do
+ config="$(_get_array "iwconfig_${var}")"
+ local IFS="
+"
+ for conf in ${config}; do
+ unset IFS
if ! eval iwconfig "${IFACE}" "${conf}" ; then
ewarn "${IFACE} does not support the following configuration commands"
ewarn " ${conf}"
fi
done
+ unset IFS
- eval "$(_get_array "iwpriv_${var}")"
- for conf in "$@" ; do
+ config="$(_get_array "iwpriv_${var}")"
+ local IFS="
+"
+ for conf in ${config}; do
+ unset IFS
if ! eval iwpriv "${IFACE}" "${conf}" ; then
ewarn "${IFACE} does not support the following private ioctls"
ewarn " ${conf}"
@@ -472,13 +479,17 @@ iwconfig_scan() {
eoutdent
fi
- eval "$(_get_array "blacklist_aps")"
- for x in "$@" ; do
+ local blacklist="$(_get_array "blacklist_aps")"
+ local IFS="
+"
+ for x in ${blacklist}; do
+ unset IFS
if [ "${x}" = "${s}" ] ; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
done
+ unset IFS
i=$((${i} + 1))
done
eoutdent
@@ -488,9 +499,11 @@ iwconfig_force_preferred() {
[ -z "${preferred_aps}" ] && return 1
ewarn "Trying to force preferred in case they are hidden"
- eval "(_get_array "preferred_aps")"
- local ssid=
- for ssid in "$@"; do
+ local pref="$(_get_array "preferred_aps")" ssid=
+ local IFS="
+"
+ for ssid in ${pref}; do
+ unset IFS
local found_AP=false i=0 e=
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
@@ -512,9 +525,11 @@ iwconfig_force_preferred() {
iwconfig_connect_preferred() {
local ssid= i= mode= mac= enc= freq= chan=
-
- eval "$(_get_array preferred_aps)"
- for ssid in "$@"; do
+ local pref="$(_get_array preferred_aps)"
+ local IFS="
+"
+ for ssid in ${pref}; do
+ unset IFS
i=0
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
@@ -541,13 +556,16 @@ iwconfig_connect_not_preferred() {
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
if [ -n "${e}" ] ; then
- eval "$(_get_array preferred_aps)"
- for ssid in "$@" ; do
+ local prefa="$(_get_array preferred_aps)"
+ local IFS="
+"
+ for ssid in ${prefa}; do
if [ "${e}" = "${ssid}" ] ; then
pref=true
break
fi
done
+ unset IFS
if ! ${pref} ; then
SSID=${e}
diff --git a/net.Linux/pppd.sh b/net.Linux/pppd.sh
index 47d7dae3..07ac6b1f 100644
--- a/net.Linux/pppd.sh
+++ b/net.Linux/pppd.sh
@@ -33,7 +33,7 @@ pppd_pre_start() {
return 0
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
# PPPoE communicates over Ethernet
@@ -57,16 +57,14 @@ pppd_pre_start() {
return 1
fi
- eval $(_get_array "pppd_${IFVAR}")
- opts="$@"
+ eval opts=\$pppd_${IFVAR}
local mtu= hasmtu=false hasmru=false hasmaxfail=false haspersist=false
local hasupdetach=false hasdefaultmetric=false
- for i in "$@" ; do
- set -- ${i}
- case "$1" in
+ for i in ${opts}; do
+ case "${i}" in
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
;;
defaultmetric) hasdefaultmetric=true ;;
@@ -113,25 +111,31 @@ pppd_pre_start() {
# Load a custom interface configuration file if it exists
[ -f "/etc/ppp/options.${IFACE}" ] \
- && opts="${opts} file /etc/ppp/options.${IFACE}"
+ && opts="${opts} file '/etc/ppp/options.${IFACE}'"
# Set unit
opts="unit ${unit} ${opts}"
# Setup connect script
- local chatopts="/usr/sbin/chat -e -E -v"
- eval $(_get_array "phone_number_${IFVAR}")
+ local chatopts="/usr/sbin/chat -e -E -v" phone=
+ eval phone=\$phone_number_${IFVAR}
+ set -- ${phone}
[ -n "$1" ] && chatopts="${chatopts} -T '$1'"
[ -n "$2" ] && chatopts="${chatopts} -U '$2'"
- eval $(_get_array "chat_${IFVAR}")
- if [ $# != 0 ] ; then
+ local chat="$(_get_array "chat_${IFVAR}")"
+ if [ "${chat}" ] ; then
+ local IFS="
+"
opts="${opts} connect $(printf "\\'%s\\'" "${chatopts} $(printf "\\'\\\\'\\'%s\\'\\\'' " "$@")")"
+ unset IFS
fi
# Add plugins
- local haspppoa=false haspppoe=false
- eval $(_get_array "plugins_${IFVAR}")
- for i in "$@" ; do
+ local haspppoa=false haspppoe=false plugins="$(_get_array "plugins_${IFVAR}")"
+ local IFS="
+"
+ for i in ${plugins}; do
+ unset IFS
set -- ${i}
case "$1" in
passwordfd) continue;;
@@ -151,6 +155,7 @@ pppd_pre_start() {
shift
opts="${opts} $@"
done
+ unset IFS
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
local insert_link_in_opts=1
diff --git a/net.Linux/vlan.sh b/net.Linux/vlan.sh
index 1542d4c0..23cdf777 100644
--- a/net.Linux/vlan.sh
+++ b/net.Linux/vlan.sh
@@ -31,14 +31,17 @@ _check_vlan() {
}
vlan_pre_start() {
- eval $(_get_array "vconfig_${IFVAR}")
- [ $# = "0" ] && return 0
+ local vc="$(_get_array "vconfig_${IFVAR}")"
+ [ -z "${vc}" ] && return 0
_check_vlan || return 1
_exists || return 1
local v= x= e=
- for v in "$@" ; do
+ local IFS="
+"
+ for v in ${vc}; do
+ unset IFS
case "${v}" in
set_name_type" "*) x=${v} ;;
*) x="$(echo "${v}" | sed -e "s/ / ${IFACE} /g")"
@@ -56,14 +59,15 @@ vlan_pre_start() {
}
vlan_post_start() {
- eval $(_get_array "vlans_${IFVAR}")
- [ $# = "0" ] && return 0
+ local vlans=
+ eval vlans=\$vlans_${IFACE}
+ [ -z "${vlans}" ] && return 0
_check_vlan || return 1
_exists || return 1
local vlan= e= s=
- for vlan in "$@" ; do
+ for vlan in ${vlans}; do
einfo "Adding VLAN ${vlan} to ${IFACE}"
e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)"
if [ -n "${e}" ] ; then
@@ -92,7 +96,7 @@ vlan_post_start() {
vlan_post_stop() {
local vlan=
- for vlan in $(_get_vlans) ; do
+ for vlan in $(_get_vlans); do
einfo "Removing VLAN ${vlan##*.} from ${IFACE}"
(
export SVCNAME="net.${vlan}"
diff --git a/sh/net.sh b/sh/net.sh
index de3164c3..427c1fa7 100755
--- a/sh/net.sh
+++ b/sh/net.sh
@@ -40,20 +40,24 @@ _shell_var() {
echo -n "$1" | sed -e 's/[^[:alnum:]]/_/g'
}
-# Credit to David Leverton for this function which handily maps a bash array
-# structure to positional parameters so existing configs work :)
-# We'll deprecate arrays at some point though.
+# Support bash arrays - sigh
_get_array() {
+ local _a=
if [ -n "${BASH}" ] ; then
case "$(declare -p "$1" 2>/dev/null)" in
"declare -a "*)
- echo "set -- \"\${$1[@]}\""
- return
+ eval "set -- \"\${$1[@]}\""
+ for _a in "$@"; do
+ printf "%s\n" "${_a}"
+ done
+ return 0
;;
esac
fi
- echo "eval set -- \"\$$1\""
+ eval _a=\$$1
+ printf "%s" "${_a}"
+ [ -n "${_a}" ]
}
_wait_for_carrier() {
@@ -339,20 +343,25 @@ _load_modules() {
}
_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
- set -- "127.0.0.1/8" "$@"
+ config="127.0.0.1/8
+${config}"
else
- if [ $# -eq 0 ] ; then
+ if [ -z "${config}" ] ; then
ewarn "No configuration specified; defaulting to DHCP"
- set -- "dhcp"
+ config="dhcp"
fi
fi
# We store our config in an array like vars
# so modules can influence it
config_index=0
- for cmd in "$@" ; do
+ local IFS="
+"
+ for cmd in ${config}; do
eval config_${config_index}="'${cmd}'"
config_index=$((${config_index} + 1))
done
@@ -360,8 +369,7 @@ _load_config() {
eval config_${config_index}=
config_index=0
- eval "$(_get_array fallback_${IFVAR})"
- for cmd in "$@" ; do
+ for cmd in ${fallback}; do
eval fallback_${config_index}="'${cmd}'"
config_index=$((${config_index} + 1))
done
@@ -483,14 +491,18 @@ start() {
return 1
fi
- local hidefirstroute=false first=true routes=
- eval "$(_get_array "routes_${IFVAR}")"
+ local hidefirstroute=false first=true
+ local routes="$(_get_array "routes_${IFVAR}")"
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
fi
- for cmd in "$@" ; do
- if ${first} ; then
+ local IFS="
+"
+ for cmd in ${routes}; do
+ unset IFS
+ if ${first}; then
first=false
einfo "Adding routes"
fi