diff options
author | Roy Marples <roy@marples.name> | 2007-10-29 09:45:49 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-10-29 09:45:49 +0000 |
commit | e372729b8cc489af7b1b2305d6fd9c1895b9c8d4 (patch) | |
tree | 5ffa0e392d92a03bd23fe8f00aa2d6a26d41ffbb /net.Linux | |
parent | 42c231d7609447cb96d98cbebdc12a197324fb99 (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.
Diffstat (limited to 'net.Linux')
-rw-r--r-- | net.Linux/arping.sh | 28 | ||||
-rw-r--r-- | net.Linux/bonding.sh | 13 | ||||
-rw-r--r-- | net.Linux/bridge.sh | 20 | ||||
-rw-r--r-- | net.Linux/ccwgroup.sh | 6 | ||||
-rw-r--r-- | net.Linux/clip.sh | 13 | ||||
-rw-r--r-- | net.Linux/ip6to4.sh | 5 | ||||
-rw-r--r-- | net.Linux/iwconfig.sh | 48 | ||||
-rw-r--r-- | net.Linux/pppd.sh | 35 | ||||
-rw-r--r-- | net.Linux/vlan.sh | 18 |
9 files changed, 111 insertions, 75 deletions
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}" |