summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-scripts')
-rw-r--r--net-scripts/conf.d/net.example11
-rwxr-xr-xnet-scripts/init.d/net.lo70
-rw-r--r--net-scripts/net/adsl.sh6
-rw-r--r--net-scripts/net/apipa.sh2
-rw-r--r--net-scripts/net/arping.sh24
-rw-r--r--net-scripts/net/bonding.sh10
-rw-r--r--net-scripts/net/br2684ctl.sh2
-rw-r--r--net-scripts/net/bridge.sh18
-rw-r--r--net-scripts/net/ccwgroup.sh8
-rw-r--r--net-scripts/net/dhclient.sh8
-rw-r--r--net-scripts/net/dhcpcd.sh12
-rw-r--r--net-scripts/net/essidnet.sh6
-rw-r--r--net-scripts/net/ifconfig.sh32
-rw-r--r--net-scripts/net/ifplugd.sh6
-rw-r--r--net-scripts/net/ip6to4.sh6
-rw-r--r--net-scripts/net/ipppd.sh5
-rw-r--r--net-scripts/net/iproute2.sh22
-rw-r--r--net-scripts/net/iptunnel.sh4
-rw-r--r--net-scripts/net/iwconfig.sh156
-rw-r--r--net-scripts/net/macchanger.sh14
-rw-r--r--net-scripts/net/macnet.sh2
-rw-r--r--net-scripts/net/netplugd.sh4
-rw-r--r--net-scripts/net/pppd.sh120
-rw-r--r--net-scripts/net/pump.sh6
-rw-r--r--net-scripts/net/rename.sh3
-rw-r--r--net-scripts/net/system.sh6
-rw-r--r--net-scripts/net/tuntap.sh2
-rw-r--r--net-scripts/net/udhcpc.sh16
-rw-r--r--net-scripts/net/vlan.sh25
-rw-r--r--net-scripts/net/wpa_supplicant.sh49
30 files changed, 299 insertions, 356 deletions
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index 1366eea..3038451 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -340,7 +340,7 @@
# If you wish to control the configuration of each vlan through a seperate
# script, or wish to rename the vlan interface to something that vconfig
# cannot then you need to do this.
-#vlan_start_eth0="no
+#vlan_start_eth0="no"
# If you do the above then you may want to depend on eth0 like so
# depend_vlan1() {
@@ -398,7 +398,6 @@
# against the specified username
#username_ppp0='user'
#password_ppp0='password'
-#
# NOTE: You can set a blank password like so
#password_ppp0=
#
@@ -406,10 +405,12 @@
# and may seem daunting, it is recommended that you read the pppd man page
# before enabling any of them
#pppd_ppp0=(
-# "updetach" # WARNING: If you don't specify this then we will
-# # not wait for the actual PPP link to go up
# "maxfail 0" # WARNING: It's not recommended you use change this
# # if you don't specify maxfail then we assume 0
+# "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
@@ -667,7 +668,7 @@
#modules_eth0=( "!plug" )
# To use specific ifplugd options, fex specifying wiress mode
-#ifplugd_eth0="--api-mode wlan"
+#ifplugd_eth0="--api-mode=wlan"
# man ifplugd for more options
##############################################################################
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index 94b85bc..cab348d 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -84,8 +84,8 @@ calculate_metric() {
local iface="$1" metric="$2"
# Have we already got a metric?
- local m="$( awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \
- /proc/net/route )"
+ local m=$(awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \
+ /proc/net/route)
if [[ -n ${m} ]] ; then
echo "${m}"
return 0
@@ -101,7 +101,7 @@ calculate_metric() {
done < /proc/net/route
# Now, sort our metrics
- metrics="$(echo -e "${metrics}" | sort -n)"
+ metrics=$(echo -e "${metrics}" | sort -n)
# Now, find the lowest we can use
local gotbase=false
@@ -118,7 +118,7 @@ calculate_metric() {
#
# Returns the CIDR of a given netmask
netmask2cidr() {
- local binary="" i bin
+ local binary= i= bin=
for i in ${1//./ }; do
bin=""
@@ -146,11 +146,11 @@ is_function() {
# wraps function calls - for example function_wrap(this, that)
# maps function names this_* to that_*
function_wrap() {
- local i
+ local i=
is_function "${2}_depend" && return
- for i in $( typeset -f | grep -o '^'"${1}"'_[^ ]*' ); do
+ for i in $(typeset -f | grep -o '^'"${1}"'_[^ ]*'); do
eval "${2}${i#${1}}() { ${i} \"\$@\"; }"
done
}
@@ -170,7 +170,7 @@ function_wrap() {
# "192.168.3.2/24 brd +"
# "192.168.3.3/24 brd +"
expand_parameters() {
- local x="$( eval echo ${@// /_} )"
+ local x=$(eval echo ${@// /_})
local -a a=( ${x} )
a=( "${a[@]/#/\"}" )
@@ -185,14 +185,14 @@ expand_parameters() {
configure_variables() {
local iface="$1" option1="$2" option2="$3"
- local mod func x i
- local -a ivars ovars1 ovars2
- local ifvar="$(bash_variable "${iface}")"
+ local mod= func= x= i=
+ local -a ivars=() ovars1=() ovars2=()
+ local ifvar=$(bash_variable "${iface}")
for mod in ${MODULES[@]}; do
is_function ${mod}_variables || continue
for v in $(${mod}_variables) ; do
- x=""
+ x=
[[ -n ${option2} ]] && x="${v}_${option2}[@]"
[[ -z ${!x} ]] && x="${v}_${option1}[@]"
[[ -n ${!x} ]] && eval "${v}_${ifvar}=( \"\${!x}\" )"
@@ -311,9 +311,9 @@ modules_check_installed() {
# bool modules_check_user(void)
modules_check_user() {
- local iface="$1" ifvar="$(bash_variable "${IFACE}")"
- local i j k l nmods="${#MODULES[@]}"
- local -a umods
+ local iface="$1" ifvar=$(bash_variable "${IFACE}")
+ local i= j= k= l= nmods="${#MODULES[@]}"
+ local -a umods=()
# Has the interface got any specific modules?
umods="modules_${ifvar}[@]"
@@ -376,7 +376,7 @@ modules_check_user() {
fi
if is_function "${umods[i]}_provide" ; then
- mod="$(${umods[i]}_provide )"
+ mod=$(${umods[i]}_provide)
else
mod="${umods[i]}"
fi
@@ -419,7 +419,7 @@ modules_check_user() {
#
# Sort our modules
modules_sort() {
- local i j nmods=${#MODULES[@]} m
+ local i= j= nmods=${#MODULES[@]} m=
local -a provide=() provide_list=() after=() dead=() sorted=() sortedp=()
# Make our provide list
@@ -469,7 +469,7 @@ modules_sort() {
# We then use the below code to provide a topologial sort
module_after_visit() {
- local name=$1 i x
+ local name="$1" i= x=
for ((i=0; i<nmods; i++)); do
[[ ${MODULES[i]} == "$1" ]] && break
@@ -496,12 +496,12 @@ modules_sort() {
# bool modules_check_depends(bool showprovides)
modules_check_depends() {
- local showprovides="${1:-false}" nmods="${#MODULES[@]}" i j needmod
- local missingdeps p interface=false
+ local showprovides="${1:-false}" nmods="${#MODULES[@]}" i= j= needmod=
+ local missingdeps= p= interface=false
for (( i=0; i<nmods; i++ )); do
if is_function "${MODULES[i]}_need" ; then
- for needmod in $( ${MODULES[i]}_need ); do
+ for needmod in $(${MODULES[i]}_need); do
missingdeps=true
for (( j=0; j<nmods; j++ )); do
if [[ ${needmod} == "${MODULES[j]}" \
@@ -518,7 +518,7 @@ modules_check_depends() {
fi
if is_function "${MODULES[i]}_functions" ; then
- for f in $( ${MODULES[i]}_functions ); do
+ for f in $(${MODULES[i]}_functions); do
if ! is_function "${f}" ; then
eerror "${MODULES[i]}: missing required function \"${f}\""
return 1
@@ -547,10 +547,10 @@ modules_check_depends() {
# Loads the defined handler and modules for the interface
# Returns 0 on success, otherwise 1
modules_load() {
- local iface="$1" starting="${2:-true}" MODULE p=false i j k
- local -a x
+ local iface="$1" starting="${2:-true}" MODULE= p=false i= j= k=
+ local -a x=()
local RC_INDENTATION="${RC_INDENTATION}"
- local -a PROVIDES WRAP_MODULES
+ local -a PROVIDES=() WRAP_MODULES=()
if ! is_loopback "${iface}" ; then
x="modules_force_${iface}[@]"
@@ -592,7 +592,7 @@ modules_load() {
# If no provide is given, assume module name
if is_function "${MODULES[i]}_provide" ; then
- PROVIDES[i]="$(${MODULES[i]}_provide)"
+ PROVIDES[i]=$(${MODULES[i]}_provide)
else
PROVIDES[i]="${MODULES[i]}"
fi
@@ -655,8 +655,8 @@ modules_load() {
iface_start() {
local iface="$1" mod config_counter="-1" x config_worked=false
local RC_INDENTATION="${RC_INDENTATION}"
- local -a config fallback fallback_route conf a b
- local ifvar="$(bash_variable "$1")" i j metric=0
+ local -a config=() fallback=() fallback_route=() conf=() a=() b=()
+ local ifvar=$(bash_variable "$1") i= j= metric=0
# pre Start any modules with
for mod in ${MODULES[@]}; do
@@ -809,7 +809,7 @@ iface_start() {
# iface_start ran. Instead query for current configuration and bring
# down the interface.
iface_stop() {
- local iface="$1" i aliases need_begin=false mod
+ local iface="$1" i= aliases= need_begin=false mod=
local RC_INDENTATION="${RC_INDENTATION}"
# pre Stop any modules
@@ -825,7 +825,7 @@ iface_stop() {
# Collect list of aliases for this interface.
# List will be in reverse order.
if interface_exists "${iface}" ; then
- aliases="$(interface_get_aliases_rev "${iface}")"
+ aliases=$(interface_get_aliases_rev "${iface}")
fi
# Stop aliases before primary interface.
@@ -875,7 +875,7 @@ iface_stop() {
# We cannot check that the device exists ourselves as modules like
# tuntap make create it.
run_start() {
- local iface="$1" IFVAR="$(bash_variable "$1")"
+ local iface="$1" IFVAR=$(bash_variable "$1")
# We do this so users can specify additional addresses for lo if they
# need too - additional routes too
@@ -914,7 +914,7 @@ run_start() {
# If config is set to noop and the interface is up with an address
# then we don't start it
- local config
+ local config=
config="config_${IFVAR}[@]"
config=( "${!config}" )
if [[ ${config[0]} == "noop" ]] && interface_is_up "${iface}" true ; then
@@ -962,12 +962,12 @@ run_start() {
# stop returns non-zero to indicate failure bringing down device.
# In all other cases stop returns 0 to indicate success.
run_stop() {
- local iface="$1" IFVAR="$(bash_variable "$1")" x
+ local iface="$1" IFVAR=$(bash_variable "$1") x
# Load our ESSID variable so users can use it in predown() instead
# of having to write code.
- local ESSID="$(get_options ESSID)" ESSIDVAR
- [[ -n ${ESSID} ]] && ESSIDVAR="$(bash_variable "${ESSID}")"
+ local ESSID=$(get_options ESSID) ESSIDVAR=
+ [[ -n ${ESSID} ]] && ESSIDVAR=$(bash_variable "${ESSID}")
# Call user-defined predown function if it exists
if is_function predown ; then
@@ -1021,7 +1021,7 @@ run_stop() {
run() {
local iface="$1" cmd="$2" r=1 RC_INDENTATION="${RC_INDENTATION}"
local starting=true
- local -a MODULES mods
+ local -a MODULES=() mods=()
local IN_BACKGROUND="${IN_BACKGROUND}"
if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]] ; then
diff --git a/net-scripts/net/adsl.sh b/net-scripts/net/adsl.sh
index 2e1423b..97d620c 100644
--- a/net-scripts/net/adsl.sh
+++ b/net-scripts/net/adsl.sh
@@ -22,7 +22,7 @@ adsl_check_installed() {
#
# Checks to see if the ADSL script has been created or not
adsl_setup_vars() {
- local iface="$1" startstop="$2" cfgexe
+ local iface="$1" startstop="$2" cfgexe=
if [[ -x /usr/sbin/pppoe-start ]]; then
exe="/usr/sbin/pppoe-${startstop}"
@@ -52,7 +52,7 @@ adsl_setup_vars() {
#
# Returns 0 (true) when successful, non-zero otherwise
adsl_start() {
- local iface="$1" exe cfgfile user ifvar="$(bash_variable "$1")"
+ local iface="$1" exe= cfgfile= user= ifvar=$(bash_variable "$1")
adsl_setup_vars "${iface}" start || return 1
@@ -74,7 +74,7 @@ adsl_start() {
# Returns 0 when there is no ADSL to stop or we stop ADSL successfully
# Otherwise 1
adsl_stop() {
- local iface="$1" exe cfgfile
+ local iface="$1" exe= cfgfile=
adsl_check_installed || return 1
[[ ! -f "/var/run/rp-pppoe-${iface}.pid" ]] && return 0
diff --git a/net-scripts/net/apipa.sh b/net-scripts/net/apipa.sh
index 5ccdc18..b482e4b 100644
--- a/net-scripts/net/apipa.sh
+++ b/net-scripts/net/apipa.sh
@@ -14,7 +14,7 @@ apipa_depend() {
#
# Tries to detect a config based on arpinging things
apipa_start() {
- local iface="$1" i1 i2 addr i=0
+ local iface="$1" i1= i2= addr= i=0
interface_exists "$1" true || return 1
diff --git a/net-scripts/net/arping.sh b/net-scripts/net/arping.sh
index 01d9256..0200e63 100644
--- a/net-scripts/net/arping.sh
+++ b/net-scripts/net/arping.sh
@@ -28,7 +28,7 @@ arping_sleep() {
local iface="$1"
[[ ${ARPING_SLEPT} == "1" ]] && return
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
local s="arping_sleep_${ifvar}"
s="${!s}"
if [[ -z ${s} ]] ; then
@@ -60,22 +60,22 @@ arping_address_exists() {
arping_sleep
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
w="arping_wait_${ifvar}"
w="${!w}"
[[ -z ${w} ]] && w="${arping_wait:-3}"
if [[ -x /sbin/arping ]] ; then
- foundmac="$(arping -c 2 -w "${w}" -D -f -I "${iface}" \
+ foundmac=$(arping -c 2 -w "${w}" -D -f -I "${iface}" \
"${ip}" 2>/dev/null \
- | sed -n 's/.*\[\([^]]*\)\].*/\U\1/p')"
+ | sed -n 's/.*\[\([^]]*\)\].*/\U\1/p')
elif [[ -x /usr/sbin/arping2 ]] ; then
for (( i=0; i<w; i++ )) ; do
- foundmac="$(arping2 -r -0 -c 1 -i "${iface}" \
- "${ip}" 2>/dev/null)"
+ foundmac=$(arping2 -r -0 -c 1 -i "${iface}" \
+ "${ip}" 2>/dev/null)
if [[ $? == "0" ]] ; then
- foundmac="$(echo "${foundmac}" \
- | tr '[:lower:]' '[:upper:]')"
+ foundmac=$(echo "${foundmac}" \
+ | tr '[:lower:]' '[:upper:]')
break
fi
foundmac=
@@ -99,8 +99,8 @@ arping_address_exists() {
# arpings a list of gateways
# If one is foung then apply it's configuration
arping_start() {
- local iface="$1" gateways x conf i
- local ifvar="$(bash_variable "${iface}")"
+ local iface="$1" gateways= x= conf= i=
+ local ifvar=$(bash_variable "${iface}")
einfo "Pinging gateways on ${iface} for configuration"
@@ -116,8 +116,8 @@ arping_start() {
local -a a=( ${x//,/ } )
local ip="${a[0]}" mac="${a[1]}" extra=
if [[ -n ${mac} ]] ; then
- mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')"
- extra="(MAC ${mac})"
+ mac=$(echo "${mac}" | tr '[:lower:]' '[:upper:]')
+ extra=(MAC ${mac})
fi
vebegin "${ip} ${extra}"
diff --git a/net-scripts/net/bonding.sh b/net-scripts/net/bonding.sh
index 2b8a086..b206624 100644
--- a/net-scripts/net/bonding.sh
+++ b/net-scripts/net/bonding.sh
@@ -38,8 +38,8 @@ bonding_exists() {
#
# Bonds the interface
bonding_pre_start() {
- local iface="$1" s ifvar="$(bash_variable "$1")"
- local -a slaves
+ local iface="$1" s= ifvar=$(bash_variable "$1")
+ local -a slaves=()
slaves="slaves_${ifvar}[@]"
[[ -z ${!slaves} ]] && return 0
@@ -86,16 +86,16 @@ bonding_pre_start() {
#
# Always returns 0 (true)
bonding_stop() {
- local iface="$1" slaves s
+ local iface="$1" slaves= s=
# return silently if this is not a bonding interface
! bonding_exists "${iface}" && return 0
# don't trust the config, get the active list instead
- slaves="$( \
+ slaves=$( \
sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${iface}" \
| tr '\n' ' ' \
- )"
+ )
[[ -z ${slaves} ]] && return 0
# remove all slaves
diff --git a/net-scripts/net/br2684ctl.sh b/net-scripts/net/br2684ctl.sh
index e325817..50e4e7e 100644
--- a/net-scripts/net/br2684ctl.sh
+++ b/net-scripts/net/br2684ctl.sh
@@ -19,7 +19,7 @@ br2684ctl_check_installed() {
# bool br2684ctl_start(char *iface)
br2684ctl_pre_start() {
- local iface="$1" ifvar="$(bash_variable "$1")" opts=
+ local iface="$1" ifvar=$(bash_variable "$1") opts=
local number="${iface#${iface%%[0-9]}}"
opts="br2684ctl_${ifvar}"
diff --git a/net-scripts/net/bridge.sh b/net-scripts/net/bridge.sh
index 2d4e6f5..cf8a981 100644
--- a/net-scripts/net/bridge.sh
+++ b/net-scripts/net/bridge.sh
@@ -70,10 +70,10 @@ bridge_exists() {
# Creates the bridge - no ports are added here though
# Returns 0 on success otherwise 1
bridge_create() {
- local iface="$1" ifvar="$(bash_variable "$1")" x i opts
+ local iface="$1" ifvar=$(bash_variable "$1") x= i= opts=
ebegin "Creating bridge ${iface}"
- x="$(brctl addbr "${iface}" 2>&1)"
+ x=$(brctl addbr "${iface}" 2>&1)
if [[ -n ${x} ]] ; then
if [[ ${x//Package not installed/} != "${x}" ]] ; then
eend 1 "Bridging (802.1d) support is not present in this kernel"
@@ -87,7 +87,7 @@ bridge_create() {
for i in "${!opts}" ; do
x="${i/ / ${iface} }"
[[ ${x} == "${i}" ]] && x="${x} ${iface}"
- x="$(brctl ${x} 2>&1 1>/dev/null)"
+ x=$(brctl ${x} 2>&1 1>/dev/null)
[[ -n ${x} ]] && ewarn "${x}"
done
eend 0
@@ -97,11 +97,11 @@ bridge_create() {
#
# Adds the port to the bridge
bridge_add_port() {
- local iface="$1" port="$2" e
+ local iface="$1" port="$2" e=
interface_set_flag "${port}" promisc true
interface_up "${port}"
- e="$(brctl addif "${iface}" "${port}" 2>&1)"
+ e=$(brctl addif "${iface}" "${port}" 2>&1)
if [[ -n ${e} ]] ; then
interface_set_flag "${port}" promisc false
echo "${e}" >&2
@@ -124,7 +124,7 @@ bridge_delete_port() {
# This can also be called by non-bridges so that the bridge can be created
# dynamically
bridge_pre_start() {
- local iface="$1" ports briface i ifvar="$(bash_variable "$1")" opts
+ local iface="$1" ports= briface= i= ifvar=$(bash_variable "$1") opts=
ports="bridge_${ifvar}[@]"
briface="bridge_add_${ifvar}"
opts="brctl_${ifvar}[@]"
@@ -171,18 +171,18 @@ bridge_pre_start() {
# Removes the device
# returns 0
bridge_stop() {
- local iface="$1" ports i deletebridge=false extra=""
+ local iface="$1" ports= i= deletebridge=false extra=""
if bridge_exists "${iface}" ; then
ebegin "Destroying bridge ${iface}"
interface_down "${iface}"
- ports="$(bridge_get_ports "${iface}")"
+ ports=$(bridge_get_ports "${iface}")
deletebridge=true
eindent
else
# Work out if we're added to a bridge for removal or not
ports="${iface}"
- iface="$(bridge_get_bridge "${iface}")"
+ iface=$(bridge_get_bridge "${iface}")
[[ -z ${iface} ]] && return 0
extra=" from ${iface}"
fi
diff --git a/net-scripts/net/ccwgroup.sh b/net-scripts/net/ccwgroup.sh
index 3eca965..7091719 100644
--- a/net-scripts/net/ccwgroup.sh
+++ b/net-scripts/net/ccwgroup.sh
@@ -10,7 +10,7 @@ ccwgroup_expose() {
}
ccwgroup_pre_start() {
- local iface="$1" ifvar="$(bash_variable "$1")"
+ local iface="$1" ifvar=$(bash_variable "$1")
local ccw="ccwgroup_${ifvar}[@]"
local -a ccwgroup=( "${!ccw}" )
@@ -33,16 +33,16 @@ ccwgroup_pre_stop() {
save_options ccwgroup_device ""
[[ ! -L /sys/class/net/"${iface}"/driver ]] && return 0
- local driver="$(readlink /sys/class/net/"${iface}"/driver)"
+ local driver=$(readlink /sys/class/net/"${iface}"/driver)
[[ ${driver} != *"/bus/ccwgroup/"* ]] && return 0
- local device="$(readlink /sys/class/net/"${iface}"/device)"
+ local device=$(readlink /sys/class/net/"${iface}"/device)
device="${device##*/}"
save_options ccwgroup_device "${device}"
}
ccwgroup_post_stop() {
- local iface="$1" device="$(get_options ccwgroup_device)"
+ local iface="$1" device=$(get_options ccwgroup_device)
[[ -z ${device} ]] && return 0
diff --git a/net-scripts/net/dhclient.sh b/net-scripts/net/dhclient.sh
index 0e54d21..10dfa59 100644
--- a/net-scripts/net/dhclient.sh
+++ b/net-scripts/net/dhclient.sh
@@ -43,7 +43,7 @@ dhclient_stop() {
[[ ! -f ${pidfile} ]] && return 0
ebegin "Stopping dhclient on ${iface}"
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
local d="dhcp_${ifvar}"
[[ -z ${!d} ]] && d="dhcp"
if [[ " ${!d} " == *" release "* ]] ; then
@@ -60,7 +60,7 @@ dhclient_stop() {
#
# Returns 0 (true) when a DHCP address is obtained, otherwise 1
dhclient_start() {
- local iface="$1" ifvar="$(bash_variable "$1")" dhconf=
+ local iface="$1" ifvar=$(bash_variable "$1") dhconf=
local pidfile="/var/run/dhclient-${iface}.pid"
interface_exists "${iface}" true || return 1
@@ -95,7 +95,7 @@ dhclient_start() {
# Send our hostname by editing cffile
if [[ " ${!d} " != *" nosendhost "* ]] ; then
- local hname="$(hostname)"
+ local hname=$(hostname)
if [[ ${hname} != "(none)" && ${hname} != "localhost" ]]; then
dhconf="${dhconf} interface \"${iface}\" {\n"
dhconf="${dhconf} send host-name \"${hname}\"\n;"
@@ -110,7 +110,7 @@ dhclient_start() {
eend $? || return 1
# DHCP succeeded, show address retrieved
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} received address ${addr}"
return 0
diff --git a/net-scripts/net/dhcpcd.sh b/net-scripts/net/dhcpcd.sh
index 3cf6267..6e6055d 100644
--- a/net-scripts/net/dhcpcd.sh
+++ b/net-scripts/net/dhcpcd.sh
@@ -43,13 +43,13 @@ dhcpcd_check_installed() {
# Returns 0 (true) when a DHCP address dropped
# otherwise return 1
dhcpcd_stop() {
- local iface=$1 signal pidfile="/var/run/dhcpcd-$1.pid" d
+ local iface=$1 signal= pidfile="/var/run/dhcpcd-$1.pid" d=
[[ ! -f ${pidfile} ]] && return 0
ebegin "Stopping dhcpcd on ${iface}"
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
d="dhcp_${ifvar}"
d=" ${!d} "
[[ ${d} == " " ]] && d=" ${dhcp} "
@@ -68,8 +68,8 @@ dhcpcd_stop() {
#
# Returns 0 (true) when a DHCP address is obtained, otherwise 1
dhcpcd_start() {
- local iface="$1" opts pidfile="/var/run/dhcpcd-$1.pid"
- local ifvar="$(bash_variable "${iface}")" metric d
+ local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid"
+ local ifvar=$(bash_variable "${iface}") metric= d=
interface_exists "${iface}" true || return 1
@@ -88,7 +88,7 @@ dhcpcd_start() {
# We transmit the hostname by default
if [[ " ${d} " != *" nosendhost "* && " ${opts} " != *" -h "* ]]; then
- local hname="$(hostname)"
+ local hname=$(hostname)
[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
&& opts="-h \"${hname}\" ${opts}"
fi
@@ -107,7 +107,7 @@ dhcpcd_start() {
eend $? || return 1
# DHCP succeeded, show address retrieved
- local addr="$( interface_get_address "${iface}" )"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} received address ${addr}"
return 0
diff --git a/net-scripts/net/essidnet.sh b/net-scripts/net/essidnet.sh
index 689a6ea..4e37ec5 100644
--- a/net-scripts/net/essidnet.sh
+++ b/net-scripts/net/essidnet.sh
@@ -30,9 +30,9 @@ essidnet_pre_start() {
wireless_exists "${iface}" || return 0
- local mac="$(wireless_get_ap_mac_address "${iface}")"
- local ESSID="$(wireless_get_essid "${iface}")"
- local essid="$(bash_variable "${ESSID}")"
+ local mac=$(wireless_get_ap_mac_address "${iface}")
+ local ESSID=$(wireless_get_essid "${iface}")
+ local essid=$(bash_variable "${ESSID}")
mac="${mac//:/}"
vebegin "Configuring ${iface} for ESSID \"${ESSID//\\\\/\\\\}\"" 2>/dev/null
diff --git a/net-scripts/net/ifconfig.sh b/net-scripts/net/ifconfig.sh
index 6ced9e2..ddae01a 100644
--- a/net-scripts/net/ifconfig.sh
+++ b/net-scripts/net/ifconfig.sh
@@ -44,7 +44,7 @@ ifconfig_check_installed() {
#
# Returns 1 if the interface exists, otherwise 0
ifconfig_exists() {
- local e="$(ifconfig -a | grep -o "^$1")" report="${2:-false}"
+ local e=$(ifconfig -a | grep -o "^$1") report="${2:-false}"
[[ -n ${e} ]] && return 0
if ${report} ; then
@@ -60,7 +60,7 @@ ifconfig_exists() {
# Returns the netmask of a given CIDR
cidr2netmask() {
local cidr="$1" netmask="" done=0 i sum=0 cur=128
- local octets frac
+ local octets= frac=
(( octets=cidr/8 ))
(( frac=cidr%8 ))
@@ -129,7 +129,7 @@ ifconfig_set_flag() {
ifconfig_get_address() {
local -a x=( $( ifconfig "$1" \
| sed -n -e 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p' ) )
- x[1]="$(netmask2cidr "${x[1]}")"
+ x[1]=$(netmask2cidr "${x[1]}")
[[ -n ${x[0]} ]] && echo "${x[0]}/${x[1]}"
}
@@ -144,8 +144,8 @@ ifconfig_is_ethernet() {
#
# Fetch the mac address assingned to the network card
ifconfig_get_mac_address() {
- local mac="$(ifconfig "$1" | sed -n -e \
- 's/.*HWaddr[ \t]*\<\(..:..:..:..:..:..\)\>.*/\U\1/p')"
+ local mac=$(ifconfig "$1" | sed -n -e \
+ 's/.*HWaddr[ \t]*\<\(..:..:..:..:..:..\)\>.*/\U\1/p')
[[ ${mac} != '00:00:00:00:00:00' \
&& ${mac} != '44:44:44:44:44:44' \
&& ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \
@@ -167,7 +167,7 @@ ifconfig_set_name() {
[[ -z $2 ]] && return 1
local current="$1" new="$2"
- local mac="$(ifconfig_get_mac_address "${current}")"
+ local mac=$(ifconfig_get_mac_address "${current}")
if [[ -z ${mac} ]]; then
eerror "${iface} does not have a MAC address"
return 1
@@ -192,7 +192,7 @@ ifconfig_get_aliases_rev() {
# (false) if there were no addresses to remove.
# If onlyinet is true then we only delete IPv4 / inet addresses
ifconfig_del_addresses() {
- local iface="$1" i onlyinet="${2:-false}"
+ local iface="$1" i= onlyinet="${2:-false}"
# We don't remove addresses from aliases
[[ ${iface} == *:* ]] && return 0
@@ -221,7 +221,7 @@ ifconfig_del_addresses() {
#
# Returns config and config_fallback for the given interface
ifconfig_get_old_config() {
- local iface="$1" ifvar="$(bash_variable "$1")" i inet6
+ local iface="$1" ifvar=$(bash_variable "$1") i= inet6=
config="ifconfig_${ifvar}[@]"
config=( "${!config}" )
@@ -235,7 +235,7 @@ ifconfig_get_old_config() {
i="iface_${ifvar}"
if [[ -n ${!i} && -z ${config} ]]; then
# Make sure these get evaluated as arrays
- local -a aliases broadcasts netmasks
+ local -a aliases=() broadcasts=() netmasks=()
# Start with the primary interface
config=( ${!i} )
@@ -292,7 +292,7 @@ ifconfig_pre_start() {
interface_exists "${iface}" || return 0
- local ifvar="$(bash_variable "$1")" mtu
+ local ifvar=$(bash_variable "$1") mtu=
# MTU support
mtu="mtu_${ifvar}"
@@ -311,7 +311,7 @@ ifconfig_pre_start() {
# fail, the routine should still return success to indicate that
# net.eth0 was successful
ifconfig_post_start() {
- local iface="$1" ifvar="$(bash_variable "$1")" routes x metric mtu cidr
+ local iface="$1" ifvar=$(bash_variable "$1") routes= x= metric= mtu= cidr=
metric="metric_${ifvar}"
ifconfig_exists "${iface}" || return 0
@@ -374,7 +374,7 @@ ifconfig_post_start() {
#
# Adds the given address to the interface
ifconfig_add_address() {
- local iface="$1" i=0 r e real_iface="$(interface_device "$1")"
+ local iface="$1" i=0 r= e= real_iface=$(interface_device "$1")
ifconfig_exists "${real_iface}" true || return 1
@@ -390,17 +390,17 @@ ifconfig_add_address() {
# for multiple addresses
if ifconfig "${iface}" | grep -Eq "\<inet addr:.*" ; then
# Get the last alias made for the interface and add 1 to it
- i="$(ifconfig | tac | grep -m 1 -o "^${iface}:[0-9]*" \
- | sed -n -e 's/'"${iface}"'://p')"
+ i=$(ifconfig | tac | grep -m 1 -o "^${iface}:[0-9]*" \
+ | sed -n -e 's/'"${iface}"'://p')
i="${i:-0}"
(( i++ ))
iface="${iface}:${i}"
fi
# ifconfig doesn't like CIDR addresses
- local ip="${config[0]%%/*}" cidr="${config[0]##*/}" netmask
+ local ip="${config[0]%%/*}" cidr="${config[0]##*/}" netmask=
if [[ -n ${cidr} && ${cidr} != "${ip}" ]]; then
- netmask="$(cidr2netmask "${cidr}")"
+ netmask=$(cidr2netmask "${cidr}")
config[0]="${ip} netmask ${netmask}"
fi
diff --git a/net-scripts/net/ifplugd.sh b/net-scripts/net/ifplugd.sh
index 110b443..85a12c3 100644
--- a/net-scripts/net/ifplugd.sh
+++ b/net-scripts/net/ifplugd.sh
@@ -34,7 +34,7 @@ ifplugd_check_installed() {
#
# Start ifplugd on an interface
ifplugd_pre_start() {
- local iface="$1" ifvar="$(bash_variable "$1")" timeout opts
+ local iface="$1" ifvar=$(bash_variable "$1") timeout= opts=
local pidfile="/var/run/ifplugd.${iface}.pid"
# We don't start ifplugd if we're being called from the background
@@ -50,7 +50,7 @@ ifplugd_pre_start() {
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
- local mac="$(interface_get_mac_address "${iface}")"
+ local mac=$(interface_get_mac_address "${iface}")
if [[ -z ${mac} ]] ; then
vewarn "ifplugd only works on interfaces with a valid MAC address"
return 0
@@ -112,7 +112,7 @@ ifplugd_pre_start() {
local i=0
while true ; do
if service_started "net.${iface}" ; then
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} configured with address ${addr}"
exit 0
fi
diff --git a/net-scripts/net/ip6to4.sh b/net-scripts/net/ip6to4.sh
index cd3f1f6..cfdc466 100644
--- a/net-scripts/net/ip6to4.sh
+++ b/net-scripts/net/ip6to4.sh
@@ -26,7 +26,7 @@ ip6to4_expose() {
# Returns 0 on success, otherwise 1.
ip6to4_start() {
local iface="$1" addr=""
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
# Ensure the interface is sit0 if we're using ifconfig
if [[ " ${MODULES[@]} " == *" ifconfig "* && ${iface} != "sit0" ]] ; then
@@ -59,14 +59,14 @@ ip6to4_start() {
[[ ${ip} == "127."* ]] && continue
[[ ${ip} == "10."* ]] && continue
[[ ${ip} == "192.168."* ]] && continue
- local i
+ local i=
for ((i=16; i<32; i++)); do
[[ ${ip} == "172.${i}."* ]] && break
done
[[ ${i} -lt 32 ]] && continue
veinfo "IPv4 address on ${!host}: ${ip}"
- local ip6="$(printf "2002:%02x%02x:%02x%02x::1" ${ip//./ })"
+ local ip6=$(printf "2002:%02x%02x:%02x%02x::1" ${ip//./ })
veinfo "Derived IPv6 address: ${ip6}"
# Now apply our IPv6 address to our config
diff --git a/net-scripts/net/ipppd.sh b/net-scripts/net/ipppd.sh
index 943f558..cc84c20 100644
--- a/net-scripts/net/ipppd.sh
+++ b/net-scripts/net/ipppd.sh
@@ -30,7 +30,7 @@ ipppd_check_installed() {
#
# Returns 0 (true) when successful, non-zero otherwise
ipppd_pre_start() {
- local iface="$1" opts itype="$(interface_type "$1")"
+ local iface="$1" opts= itype=$(interface_type "$1")
local pidfile="/var/run/ipppd-${iface}.pid"
# Check that we are a valid isdn interface
@@ -39,7 +39,7 @@ ipppd_pre_start() {
# Check that the interface exists
interface_exists "${iface}" true || return 1
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
# Might or might not be set in conf.d/net
opts="ipppd_${ifvar}"
@@ -68,5 +68,4 @@ ipppd_stop() {
eend $?
}
-# vim:ts=4
# vim: set ts=4 :
diff --git a/net-scripts/net/iproute2.sh b/net-scripts/net/iproute2.sh
index f600704..4642326 100644
--- a/net-scripts/net/iproute2.sh
+++ b/net-scripts/net/iproute2.sh
@@ -46,7 +46,7 @@ iproute2_check_installed() {
#
# Returns 1 if the interface exists, otherwise 0
iproute2_exists() {
- local e="$( ip addr show label "$1" )" report="${2:-false}"
+ local e=$( ip addr show label "$1" ) report="${2:-false}"
[[ -n ${e} ]] && return 0
if ${report} ; then
@@ -109,8 +109,8 @@ iproute2_is_ethernet() {
#
# Fetch the mac address assingned to the network card
iproute2_get_mac_address() {
- local mac="$( ip link show "$1" | sed -n -e \
- '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )"
+ local mac=$( ip link show "$1" | sed -n -e \
+ '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
[[ ${mac} != '00:00:00:00:00:00' \
&& ${mac} != '44:44:44:44:44:44' \
&& ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \
@@ -138,7 +138,7 @@ iproute2_set_name() {
# Outputs a space-separated list on stdout, in reverse order, for
# example "eth0:2 eth0:1"
iproute2_get_aliases_rev() {
- local iface="$( interface_device "$1" )"
+ local iface=$( interface_device "$1" )
ip addr show dev "${iface}" | grep -o "${iface}:[0-9].*" | tac
}
@@ -147,7 +147,7 @@ iproute2_get_aliases_rev() {
# Remove addresses from interface.
# If onlyinet is true, then we only remove IPv4 / inet addresses.
iproute2_del_addresses() {
- local pre=""
+ local pre=
${2:-false} && pre="-f inet"
ip ${pre} addr flush label "$1" scope global &>/dev/null
ip ${pre} addr flush label "$1" scope site &>/dev/null
@@ -159,7 +159,7 @@ iproute2_del_addresses() {
#
# Returns config and config_fallback for the given interface
iproute2_get_old_config() {
- local ifvar="$( bash_variable "$1" )" inet6="" t=""
+ local ifvar=$( bash_variable "$1" ) inet6= t=
# iproute2-style config vars
t="ipaddr_${ifvar}[@]"
@@ -191,7 +191,7 @@ iproute2_get_old_config() {
#
# Returns 0 (true) when successful, non-zero (false) on failure
iproute2_iface_stop() {
- local label="$1" iface="$( interface_device "$1" )"
+ local label="$1" iface=$( interface_device "$1" )
# Shut down the link if this isn't an alias or vlan
if [[ ${label} == "${iface}" ]] ; then
@@ -206,7 +206,7 @@ iproute2_iface_stop() {
# Adds an the specified address to the interface
# returns 0 on success and non-zero on failure
iproute2_add_address() {
- local iface="$1" x=""
+ local iface="$1" x=
iproute2_exists "${iface}" true || return 1
@@ -263,7 +263,7 @@ iproute2_pre_start() {
interface_exists "${iface}" || return 0
- local ifvar="$( bash_variable "$1" )"
+ local ifvar=$( bash_variable "$1" )
# MTU support
local mtu="mtu_${ifvar}"
@@ -277,7 +277,7 @@ iproute2_pre_start() {
# Runs any post_start stuff on our interface and adds routes
# Always returns 0
iproute2_post_start() {
- local iface="$1" ifvar="$( bash_variable "$1" )" x=""
+ local iface="$1" ifvar=$( bash_variable "$1" ) x=
iproute2_exists "${iface}" || return 0
@@ -338,7 +338,7 @@ iproute2_post_start() {
# void iproute2_post_stop(char* interface)
iproute2_post_stop() {
- local iface="$1" rule=""
+ local iface="$1" rule=
iproute2_exists "${iface}" || return
diff --git a/net-scripts/net/iptunnel.sh b/net-scripts/net/iptunnel.sh
index 3a3568d..f85e70a 100644
--- a/net-scripts/net/iptunnel.sh
+++ b/net-scripts/net/iptunnel.sh
@@ -21,8 +21,8 @@ iptunnel_expose() {
#
# Create the device, give it the right perms
iptunnel_pre_start() {
- local iface="$1" opts ifvar="$(bash_variable "$1")"
-
+ local iface="$1" opts= ifvar=$(bash_variable "$1")
+
# Get our options
eval opts="iptunnel_${ifvar}"
[[ -z ${!opts} ]] && return 0
diff --git a/net-scripts/net/iwconfig.sh b/net-scripts/net/iwconfig.sh
index f3b1206..8c9a4f9 100644
--- a/net-scripts/net/iwconfig.sh
+++ b/net-scripts/net/iwconfig.sh
@@ -59,6 +59,9 @@ iwconfig_check_installed() {
#
# Checks to see if wireless extensions are enabled on the interface
iwconfig_exists() {
+ # Support new sysfs layout
+ [[ -L /sys/class/net/$1/wiphy ]] && return 0
+
[[ ! -e /proc/net/wireless ]] && return 1
grep -q "^[ \t]*$1:" /proc/net/wireless
}
@@ -68,12 +71,12 @@ iwconfig_exists() {
# Echos a string showing whether WEP is enabled or disabled
# for the given interface
iwconfig_get_wep_status() {
- local key="$( iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]" )"
- local mode status="disabled"
+ local key=$(iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]")
+ local mode= status="disabled"
if [[ -n ${key} ]]; then
status="enabled"
- mode="$( iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p' )"
+ mode=$(iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p')
[[ -n ${mode} ]] && mode=" - ${mode}"
fi
@@ -84,10 +87,10 @@ iwconfig_get_wep_status() {
#
# Gets the current ESSID of the iface
iwconfig_get_essid() {
- local i essid
+ local i= essid=
for (( i=0; i<5; i++ )); do
- essid="$( iwgetid --raw "$1" )"
+ essid=$( iwgetid --raw "$1" )
if [[ -n ${essid} ]] ; then
echo "${essid}"
return 0
@@ -124,20 +127,20 @@ iwconfig_get_type() {
#
# Output how our wireless interface has been configured
iwconfig_report() {
- local iface="$1" essid mac m="connected to"
+ local iface="$1" essid= mac= m="connected to"
- essid="$( iwconfig_get_essid "${iface}" )"
+ essid=$(iwconfig_get_essid "${iface}")
- local wep_status="$( iwconfig_get_wep_status "${iface}" )"
- local channel="$( iwgetid --raw --channel "${iface}" )"
+ local wep_status=$(iwconfig_get_wep_status "${iface}")
+ local channel=$(iwgetid --raw --channel "${iface}")
[[ -n ${channel} ]] && channel="on channel ${channel} "
essid="${essid//\\\\/\\\\}"
- local mode="$( iwconfig_get_mode "${iface}" )"
+ local mode=$(iwconfig_get_mode "${iface}")
if [[ ${mode} == "master" ]]; then
m="configured as"
else
- mac="$( iwconfig_get_ap_mac_address "${iface}" )"
+ mac=$(iwconfig_get_ap_mac_address "${iface}")
[[ -n ${mac} ]] && mac=" at ${mac}"
fi
@@ -152,7 +155,7 @@ iwconfig_report() {
# Returns the configured WEP key for the given mac address
# or the given ESSID. The mac address setting takes precendence
iwconfig_get_wep_key() {
- local mac="$1" key
+ local mac="$1" key=
key="mac_key_${mac//:/}"
[[ -z ${!key} ]] && key="key_${ESSIDVAR}"
echo "${!key:-off}"
@@ -162,8 +165,8 @@ iwconfig_get_wep_key() {
#
# Applies the user configuration to the interface
iwconfig_user_config() {
- local iface="$1" conf aconf ifvar="$2"
- [[ -z ${ifvar} ]] && ifvar="$( bash_variable "$1" )"
+ local iface="$1" conf= aconf= ifvar="$2"
+ [[ -z ${ifvar} ]] && ifvar=$(bash_variable "$1")
# Apply the user configuration
conf="iwconfig_${ifvar}"
@@ -193,8 +196,8 @@ iwconfig_user_config() {
#
# Sets up our wireless interface to operate in ad-hoc or master mode
iwconfig_setup_specific() {
- local iface="$1" mode="$2" channel key dessid
- local ifvar="$( bash_variable "$1" )"
+ local iface="$1" mode="$2" channel= key= dessid=
+ local ifvar=$(bash_variable "$1")
if [[ -z ${ESSID} ]]; then
eerror "${iface} requires an ESSID to be set to operate in ${mode} mode"
@@ -202,11 +205,11 @@ iwconfig_setup_specific() {
return 1
fi
dessid="${ESSID//\\\\/\\\\}"
- ESSIDVAR="$( bash_variable "${ESSID}" )"
- key="$( iwconfig_get_wep_key )"
+ ESSIDVAR=$(bash_variable "${ESSID}")
+ key=$(iwconfig_get_wep_key)
# We only change the mode if it's not the same
- local cur_mode="$( iwconfig_get_mode "${iface}" )"
+ local cur_mode=$(iwconfig_get_mode "${iface}")
if [[ ${cur_mode} != "${mode}" ]]; then
if ! iwconfig "${iface}" mode "${mode}" ; then
eerror "${iface} does not support setting the mode to \"${mode}\""
@@ -249,7 +252,7 @@ iwconfig_setup_specific() {
# Returns true if the AP MAC address is valid or not
iwconfig_associate_mac() {
# Checks if a MAC address has been assigned
- local mac="$( iwconfig_get_ap_mac_address "$1" )" i
+ local mac=$(iwconfig_get_ap_mac_address "$1") i=
local -a invalid_macs=(
"00:00:00:00:00:00"
"44:44:44:44:44:44"
@@ -268,10 +271,10 @@ iwconfig_associate_mac() {
#
# Returns true if the link quality is not 0 or 0.
iwconfig_associate_quality() {
- local quality="$( \
+ local quality=$( \
sed -n -e 's/^.*'"$1"': *[0-9]* *\([0-9]*\).*/\1/p' \
/proc/net/wireless
- )"
+ )
[[ ${quality} != "0" ]]
return "$?"
}
@@ -280,12 +283,12 @@ iwconfig_associate_quality() {
#
# Returns true if the interface has associated with an Access Point
iwconfig_test_associated() {
- local iface="$1" ttype ifvar="$( bash_variable "$1" )" x
+ local iface="$1" ttype= ifvar=$(bash_variable "$1") x=
# Some drivers don't set MAC to a bogus value when assocation is lost/fails
# whereas they do set link quality to 0
x="associate_test_${ifvar}"
- ttype="$( echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]' )"
+ ttype=$(echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]')
if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then
ewarn " associate_test_${iface} is not set to mac, quality or all"
ewarn " defaulting to \"mac\""
@@ -307,7 +310,7 @@ iwconfig_test_associated() {
# Waits for a configured ammount of time until
# we are assocaited with an Access Point
iwconfig_wait_for_association() {
- local iface="$1" i=0 timeout ifvar="$( bash_variable "$1" )"
+ local iface="$1" i=0 timeout= ifvar=$(bash_variable "$1")
timeout="associate_timeout_${ifvar}"
[[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}"
timeout="${!timeout:-10}"
@@ -334,11 +337,14 @@ iwconfig_wait_for_association() {
iwconfig_associate() {
local iface="$1" mode="${2:-managed}"
local mac="$3" wep_required="$4" w="(WEP Disabled)"
- local dessid="${ESSID//\\\\/\\\\}" key
+ local dessid="${ESSID//\\\\/\\\\}" key=
- if ! iwconfig "${iface}" mode "${mode}" ; then
- eerror "Unable to change mode to ${mode}"
- return 1
+ local cur_mode=$(iwconfig_get_mode "${iface}")
+ if [[ ${cur_mode} != "${mode}" ]]; then
+ if ! iwconfig "${iface}" mode "${mode}" ; then
+ eerror "Unable to change mode to ${mode}"
+ return 1
+ fi
fi
if [[ ${ESSID} == "any" ]]; then
@@ -346,8 +352,8 @@ iwconfig_associate() {
dessid="any"
unset ESSIDVAR
else
- ESSIDVAR="$( bash_variable "${ESSID}" )"
- key="$( iwconfig_get_wep_key "${mac}" )"
+ ESSIDVAR=$(bash_variable "${ESSID}")
+ key=$(iwconfig_get_wep_key "${mac}")
if [[ ${wep_required} == "on" && ${key} == "off" ]]; then
ewarn "WEP key is not set for \"${dessid}\" - not connecting"
return 1
@@ -364,9 +370,11 @@ iwconfig_associate() {
return 1
fi
fi
- [[ ${key} != "off" ]] && w="$( iwconfig_get_wep_status "${iface}" )"
+ [[ ${key} != "off" ]] && w=$(iwconfig_get_wep_status "${iface}")
fi
+ [[ -n ${mac} ]] && iwconfig "${iface}" ap "${mac}"
+
if ! iwconfig "${iface}" essid "${ESSID}" ; then
if [[ ${ESSID} != "any" ]]; then
ewarn "${iface} does not support setting ESSID to \"${dessid}\""
@@ -397,7 +405,7 @@ iwconfig_associate() {
veend 0
if [[ ${ESSID} == "any" ]]; then
- ESSID="$( iwconfig_get_essid "${iface}" )"
+ ESSID=$(iwconfig_get_essid "${iface}")
iwconfig_associate "${iface}"
return $?
fi
@@ -418,11 +426,11 @@ iwconfig_associate() {
#
# Fills 3 arrays with information from a wireless scan
iwconfig_scan() {
- local iface="$1" mode x ifvar="$( bash_variable "$1" )"
+ local iface="$1" mode= x= ifvar=$(bash_variable "$1")
# First, we may need to change mode to scan in
x="scan_mode_${ifvar}"
- mode="$( echo "${!x}" | tr '[:upper:]' '[:lower:]' )"
+ mode=$(echo "${!x}" | tr '[:upper:]' '[:lower:]')
if [[ -n ${mode} ]]; then
if ! iwconfig "${iface}" mode "${mode}" ; then
ewarn "${iface} does not support setting the mode to \"${mode}\""
@@ -447,22 +455,23 @@ iwconfig_scan() {
x="sleep_scan_${ifvar}"
[[ -z ${!x} || ${!x} -gt 0 ]] && sleep "${!x:-1}"
- local error=true i=-1 line
- local -a mac essid enc qual mode
+ local error=true i=-1 line=
+ local -a mac=() essid=() enc=() qual=() mode=()
while read line; do
error=false
case "${line}" in
*Address:*)
(( i++ ))
- mac[i]="$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' )"
+ mac[i]=$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')
+ qual[i]=0
;;
*ESSID:*)
essid[i]="${line#*\"}"
essid[i]="${essid[i]%*\"}"
;;
*Mode:*)
- mode[i]="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]' )"
+ mode[i]=$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')
[[ ${mode[i]} == "master" ]] && mode[i]="managed"
;;
*'Encryption key:'*)
@@ -475,7 +484,7 @@ iwconfig_scan() {
qual[i]="${qual[i]:-0}"
;;
esac
- done < <( iwlist "${iface}" scan 2>/dev/null )
+ done < <(iwlist "${iface}" scan 2>/dev/null)
if ${error}; then
ewarn "${iface} does not support scanning"
@@ -509,11 +518,11 @@ iwconfig_scan() {
# Change back mode if needed
x="mode_${ifvar}"
- x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )"
+ x=$(echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]')
[[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}"
# Strip any duplicates
- local i j x="${#mac[@]}" y
+ local i= j= x="${#mac[@]}" y=
for (( i=0; i<x-1; i++ )) ; do
[[ -z ${mac[i]} ]] && continue
for (( j=i+1; j<x; j++)) ; do
@@ -542,8 +551,7 @@ iwconfig_scan() {
[[ ${mode[i]} == "ad-hoc" ]] && (( qual[i]-=10000 ))
sortline="${sortline}${qual[i]} ${i}\n"
done
-
- sortline=( $( echo -e "${sortline}" | sort -nr ) )
+ sortline=( $(echo -e "${sortline}" | sort -nr) )
for (( i=0; i<${#mac[@]}; i++ )); do
(( x=(i * 2) + 1 ))
@@ -561,8 +569,8 @@ iwconfig_scan() {
# Report the results of the scan and re-map any ESSIDs if they
# have been configured for the MAC address found
iwconfig_scan_report() {
- local i k m remove
- local -a u
+ local i= k= m= remove=
+ local -a u=()
[[ -z ${mac_APs} ]] && ewarn " no access points found"
@@ -636,7 +644,7 @@ iwconfig_scan_report() {
# Forces the preferred_aps list to associate in order
# but only if they were not picked up by our scan
iwconfig_force_preferred() {
- local iface=$1 essid i
+ local iface=$1 essid= i=
[[ -z ${preferred_aps} ]] && return 1
@@ -664,7 +672,7 @@ iwconfig_force_preferred() {
# Connects to preferred_aps in order if they were picked up
# by our scan
iwconfig_connect_preferred() {
- local iface="$1" essid i
+ local iface="$1" essid= i=
for essid in "${preferred_aps[@]}"; do
for ((i=0; i<${#essid_APs[@]}; i++)); do
@@ -685,7 +693,7 @@ iwconfig_connect_preferred() {
# Connects to any AP's found that are not in
# our preferred list
iwconfig_connect_not_preferred() {
- local iface=$1 i ap has_preferred
+ local iface=$1 i= ap= has_preferred=
for ((i=0; i<${#mac_APs[@]}; i++)); do
has_preferred=false
@@ -713,11 +721,10 @@ iwconfig_defaults() {
local iface="$1"
# Set some defaults
+ iwconfig "${iface}" txpower auto 2>/dev/null
iwconfig "${iface}" rate auto 2>/dev/null
iwconfig "${iface}" rts auto 2>/dev/null
iwconfig "${iface}" frag auto 2>/dev/null
- iwconfig "${iface}" txpower auto 2>/dev/null
-
}
# void iwconfig_strip_associated(char *iface)
@@ -726,15 +733,15 @@ iwconfig_defaults() {
# given and remove those AP's from the scan list
# We also remove from the preferred list
iwconfig_strip_associated() {
- local iface="$1" e a j
- local essid="$( iwconfig_get_essid "${iface}" )"
+ local iface="$1" e= a= j=
+ local essid=$(iwconfig_get_essid "${iface}")
local -a ifaces=( $( iwconfig 2>/dev/null | grep -o "^\w*" ) )
for i in "${ifaces[@]}"; do
[[ ${i} == ${iface} ]] && continue
interface_is_up "${i}" || continue
iwconfig_test_associated "${i}" || continue
- e="$( iwconfig_get_essid "${i}" )"
+ e=$(iwconfig_get_essid "${i}")
local -a u=()
for ((j=0; j<${#mac_APs[@]}; j++)); do
if [[ ${essid_APs[j]} == "${e}" ]]; then
@@ -770,18 +777,15 @@ iwconfig_strip_associated() {
# Once we're connected we show a report and then configure any interface
# variables for the ESSID
iwconfig_configure() {
- local iface="$1" test x e ifvar="$( bash_variable "$1" )"
- local -a essid_APs mac_APs mode_APs enc_APs
-
- iwconfig_defaults "${iface}"
- iwconfig_user_config "${iface}"
+ local iface="$1" e= x= ifvar=$(bash_variable "$1")
+ local -a essid_APs=() mac_APs=() mode_APs=() enc_APs=()
ESSID="essid_${ifvar}"
ESSID="${!ESSID}"
# Setup ad-hoc mode?
x="mode_${ifvar}"
- x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )"
+ x=$(echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]')
if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then
iwconfig_setup_specific "${iface}" "${x}"
return $?
@@ -794,7 +798,7 @@ iwconfig_configure() {
# We only change the mode if it's not the same as some drivers
# only do managed and throw an error changing to managed
- local cur_mode="$( iwconfig_get_mode "${iface}" )"
+ local cur_mode=$(iwconfig_get_mode "${iface}")
if [[ ${cur_mode} != "${x}" ]]; then
if ! iwconfig "${iface}" mode "${x}" ; then
eerror "${iface} does not support setting the mode to \"${x}\""
@@ -802,9 +806,6 @@ iwconfig_configure() {
fi
fi
- # These arrays hold the results of our scan
- local -a mac_APs essid_APs enc_APs
-
# Has an ESSID been forced?
if [[ -n ${ESSID} ]]; then
iwconfig_associate "${iface}" && return 0
@@ -830,10 +831,8 @@ iwconfig_configure() {
# Are we forcing preferred only?
x="associate_order_${ifvar}"
[[ -n ${!x} ]] && associate_order="${!x}"
- associate_order="$(
- echo "${associate_order:-any}" \
- | tr '[:upper:]' '[:lower:]'
- )"
+ associate_order=$(echo "${associate_order:-any}" \
+ | tr '[:upper:]' '[:lower:]')
if [[ ${associate_order} == "forcepreferredonly" ]]; then
iwconfig_force_preferred "${iface}" && return 0
@@ -845,7 +844,7 @@ iwconfig_configure() {
# other wireless cards in the system if requested
x="unique_ap_${ifvar}"
[[ -n ${!x} ]] && unique_ap="${!x}"
- unique_ap="$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' )"
+ unique_ap=$(echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]')
[[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}"
iwconfig_connect_preferred "${iface}" && return 0
@@ -898,6 +897,9 @@ iwconfig_pre_start() {
return 0
fi
+ iwconfig_defaults "${iface}"
+ iwconfig_user_config "${iface}"
+
# Set the base metric to be 2000
metric=2000
@@ -913,11 +915,12 @@ iwconfig_pre_start() {
einfo "Configuring wireless network for ${iface}"
# Are we a proper IEEE device?
- # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE in lower case
- # and RA cards return RAPCI or similar which really sucks :(
- # For the time being, we will test prism54 not loading firmware which reports
- # NOT READY!
- x="$( iwconfig_get_type "${iface}" )"
+ # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE
+ # in lower case and RA cards return RAPCI or similar
+ # which really sucks :(
+ # For the time being, we will test prism54 not loading firmware
+ # which reports NOT READY!
+ x=$(iwconfig_get_type "${iface}")
if [[ ${x} == "NOT READY!" ]]; then
eerror "Looks like there was a probem loading the firmware for ${iface}"
return 1
@@ -933,14 +936,17 @@ iwconfig_pre_start() {
eerror "Failed to configure wireless for ${iface}"
iwconfig_defaults "${iface}"
+ iwconfig "${iface}" txpower off 2>/dev/null
unset ESSID ESSIDVAR
interface_down "${iface}"
return 1
}
iwconfig_post_stop() {
+ ${IN_BACKGROUND} && return 0
interface_exists "${iface}" || return 0
- iwconfig_defaults "${iface}"
+ iwconfig_defaults "${iface}"
+ iwconfig "${iface}" txpower off 2>/dev/null
}
# vim: set ts=4 :
diff --git a/net-scripts/net/macchanger.sh b/net-scripts/net/macchanger.sh
index 6331997..c02b3ff 100644
--- a/net-scripts/net/macchanger.sh
+++ b/net-scripts/net/macchanger.sh
@@ -24,7 +24,7 @@ macchanger_pre_start() {
# We don't change MAC addresses from background
${IN_BACKGROUND} && return 0
- local iface="$1" mac opts ifvar="$(bash_variable "$1")"
+ local iface="$1" mac= opts= ifvar=$(bash_variable "$1")
mac="mac_${ifvar}"
[[ -z ${!mac} ]] && return 0
@@ -36,7 +36,7 @@ macchanger_pre_start() {
# The interface needs to be up for macchanger to work most of the time
interface_down "${iface}"
- mac="$(echo "${!mac}" | tr '[:upper:]' '[:lower:]')"
+ mac=$(echo "${!mac}" | tr '[:upper:]' '[:lower:]')
case "${mac}" in
# specific mac-addr, i wish there were a shorter way to specify this
[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])
@@ -44,7 +44,7 @@ macchanger_pre_start() {
interface_set_mac_address "${iface}" "${mac}"
eend "$?"
if [[ $? == "0" ]] ; then
- mac="$(interface_get_mac_address "${iface}")"
+ mac=$(interface_get_mac_address "${iface}")
eindent
einfo "changed to ${mac}"
eoutdent
@@ -76,14 +76,14 @@ macchanger_pre_start() {
return 1
fi
- mac="$( /sbin/macchanger ${opts} "${iface}" \
- | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )"
+ mac=$(/sbin/macchanger ${opts} "${iface}" \
+ | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
# Sometimes the interface needs to be up ....
if [[ -z ${mac} ]] ; then
interface_up "${iface}"
- mac="$( /sbin/macchanger ${opts} "${iface}" \
- | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )"
+ mac=$(/sbin/macchanger ${opts} "${iface}" \
+ | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
fi
if [[ -z ${mac} ]] ; then
diff --git a/net-scripts/net/macnet.sh b/net-scripts/net/macnet.sh
index 86a3453..eca6b74 100644
--- a/net-scripts/net/macnet.sh
+++ b/net-scripts/net/macnet.sh
@@ -29,7 +29,7 @@ macnet_pre_start() {
# address isn't consistent - mainly wireless cards with firmware uploading.
interface_up "${iface}"
- local mac="$(interface_get_mac_address "${iface}")"
+ local mac=$(interface_get_mac_address "${iface}")
[[ -z ${mac} ]] && return 0
vebegin "Configuring ${iface} for MAC address ${mac}" 2>/dev/null
diff --git a/net-scripts/net/netplugd.sh b/net-scripts/net/netplugd.sh
index ac2690f..ebdd02a 100644
--- a/net-scripts/net/netplugd.sh
+++ b/net-scripts/net/netplugd.sh
@@ -45,7 +45,7 @@ netplugd_pre_start() {
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
- local mac="$(interface_get_mac_address "${iface}")"
+ local mac=$(interface_get_mac_address "${iface}")
if [[ -z ${mac} ]] ; then
vewarn "netplug only works on interfaces with a valid MAC address"
return 0
@@ -91,7 +91,7 @@ netplugd_pre_start() {
local i=0
while true ; do
if service_started "net.${iface}" ; then
- local addr="$( interface_get_address "${iface}" )"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} configured with address ${addr}"
exit 0
fi
diff --git a/net-scripts/net/pppd.sh b/net-scripts/net/pppd.sh
index 24a3d25..6a630d0 100644
--- a/net-scripts/net/pppd.sh
+++ b/net-scripts/net/pppd.sh
@@ -23,79 +23,6 @@ pppd_check_installed() {
return 0
}
-# char *pppd_regex_escape(char *string)
-#
-# Returns the supplied string with any special regex
-# characters escaped so they don't provide regex intructions
-# This may be a candidate for adding to /sbin/functions.sh or
-# net-scripts functions at some point
-pppd_regex_escape() {
- local escaped_result="$*"
- escaped_result="${escaped_result//\\/\\\\}"
- escaped_result="${escaped_result//./\\.}"
- escaped_result="${escaped_result//+/\\+}"
- escaped_result="${escaped_result//(/\\(}"
- escaped_result="${escaped_result//)/\\)}"
- escaped_result="${escaped_result//[/\\[}"
- escaped_result="${escaped_result//]/\\]}"
- escaped_result="${escaped_result//\{/\\\{}"
- escaped_result="${escaped_result//\}/\\\}}"
- escaped_result="${escaped_result//\?/\\\?}"
- escaped_result="${escaped_result//\*/\\\*}"
- escaped_result="${escaped_result//\//\\/}"
- escaped_result="${escaped_result//|/\\|}"
- escaped_result="${escaped_result//&/\\&}"
- escaped_result="${escaped_result//~/\\~}"
- escaped_result="${escaped_result//^/\\^}"
- escaped_result="${escaped_result//$/\\$}"
- echo "${escaped_result}"
-}
-
-# bool pppd_update_secrets_file(char* filepath, char* username, \
-# char* remotename, char* password)
-#
-# Add/update PAP/CHAP authentication information
-pppd_update_secrets_file() {
- local filepath="$1" username="$2" remotename="$3" password="$4"
- if [[ ! -s ${filepath} ]] ; then
- echo '#'client$'\t'server$'\t'secret$'\t'IP addresses > "${filepath}" \
- && chmod 0600 "${filepath}" \
- || return 1
- fi
-
- #escape username and remotename, used in following sed calls
- local regex_username="$(pppd_regex_escape "${username}")"
- local regex_remotename="$(pppd_regex_escape "${remotename}")"
- local regex_password
- local regex_filter="[ \t]*\"?${regex_username}\"?[ \t]*\"?${regex_remotename}\"?[ \t]*"
-
- #read old password, including " chars
- #for being able to distinct when we need to add or update auth info
- local old_password="$(
- sed -r -e "/^${regex_filter}\".*\"[ \t]*\$/\
- {s/^${regex_filter}(\".*\")[ \t]*\$/\1/;q;};\
- d;" \
- "${filepath}"
- )"
-
- if [[ -z "${old_password}" ]] ; then
- regex_username="${username//\\/\\\\}"
- regex_remotename="${remotename//\\/\\\\}"
- regex_password="${password//\\/\\\\}"
- regex_password=${password//"/\\\\"}
- sed -r -i -e "\$a\"${regex_username}\" ${regex_remotename} \"${regex_password}\"" ${filepath}
- vewarn "Authentication info has been added to ${filepath}"
- elif [[ "\"${password//\"/\\\"}\"" != "${old_password}" ]] ; then
- regex_password="${password//\\/\\\\}"
- regex_password="${regex_password//\//\\/}"
- regex_password="${regex_password//&/\\&}"
- regex_password=${regex_password//\"/\\\\\"}
- sed -r -i -e "s/^(${regex_filter}\").*(\"[ \t]*)\$/\1${regex_password}\2/" ${filepath}
- vewarn "Authentication info has been updated in ${filepath}"
- fi
- return 0
-}
-
# bool pppd_start(char *iface)
#
# Start PPP on an interface by calling pppd
@@ -104,7 +31,7 @@ pppd_update_secrets_file() {
pppd_start() {
${IN_BACKGROUND} && return 0
- local iface="$1" ifvar="$(bash_variable "$1")" opts="" link
+ local iface="$1" ifvar=$(bash_variable "$1") opts= link= i=
if [[ ${iface%%[0-9]*} != "ppp" ]] ; then
eerror "PPP can only be invoked from net.ppp[0-9]"
return 1
@@ -132,23 +59,6 @@ pppd_start() {
return 1
fi
- # Might or might not be set in conf.d/net
- local user password i
- username="username_${ifvar}"
- password="password_${ifvar}"
-
- #Add/update info in PAP/CHAP secrets files
- if [[ -n ${!username} ]] \
- && [[ -n ${!password} || -z ${!password-x} ]] ; then
- for i in chap pap ; do
- if ! pppd_update_secrets_file "/etc/ppp/${i}-secrets" \
- "${!username}" "${iface}" "${!password}" ; then
- eerror "Failed to update /etc/ppp/${i}-secrets"
- return 1
- fi
- done
- fi
-
# Load any commandline options
opts="pppd_${ifvar}[@]"
opts="${!opts}"
@@ -161,6 +71,26 @@ pppd_start() {
fi
done
+ # Might be set in conf.d/net
+ local username= password=
+ username="username_${ifvar}"
+ password="password_${ifvar}"
+ if [[ -n ${!username} ]] \
+ && [[ -n ${!password} || -z ${!password-x} ]] ; then
+ local fd=3
+ # fd 3 maybe in use, so find another one
+ while [[ -e /proc/$$/fd/${fd} ]] ; do
+ ((fd++))
+ # Don't use fd 5
+ [[ ${fd} == 5 ]] && ((fd++))
+ done
+
+ password="${!password//\\/\\\\}"
+ password="${password//\"/\\\"}"
+ opts="${opts} plugin passwordfd.so passwordfd ${fd}"
+ eval exec "${fd}< <(echo -e -n \"${password}\")"
+ fi
+
# Check for mtu/mru
local mtu="mtu_${ifvar}"
if [[ -n ${!mtu} ]] ; then
@@ -201,7 +131,7 @@ pppd_start() {
chatopts="${chatopts} -U '${phone_number[1]}'"
fi
fi
- opts="${opts} connect $(requote "${chatopts} $(requote "${!chat}")")"
+ opts="${opts} connect $(requote "${chatopts} $(requote "${!chat}")")" # "
fi
# Add plugins
@@ -209,6 +139,7 @@ pppd_start() {
for i in "${!plugins}" ; do
local -a plugin=( ${i} )
# Bound to be some users who do this
+ [[ ${plugin[0]} == "passwordfd" ]] && continue # Disable
[[ ${plugin[0]} == "pppoe" ]] && plugin[0]="rp-pppoe"
[[ ${plugin[0]} == "pppoa" ]] && plugin[0]="pppoatm"
[[ ${plugin[0]} == "capi" ]] && plugin[0]="capiplugin"
@@ -250,7 +181,8 @@ pppd_start() {
ebegin "Running pppd"
mark_service_inactive "net.${iface}"
eval start-stop-daemon --start --exec /usr/sbin/pppd \
- --pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null
+ --pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null
+
if [[ $? != "0" ]] ; then
eend $? "Failed to start PPP"
mark_service_starting "net.${iface}"
@@ -258,7 +190,7 @@ pppd_start() {
fi
if [[ " ${opts} " == *" updetach "* ]] ; then
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} received address ${addr}"
else
einfo "Backgrounding ..."
diff --git a/net-scripts/net/pump.sh b/net-scripts/net/pump.sh
index 51fc6ad..26b1a15 100644
--- a/net-scripts/net/pump.sh
+++ b/net-scripts/net/pump.sh
@@ -39,7 +39,7 @@ pump_check_installed() {
# Return 0 if pump is not running or we stop it successfully
# Otherwise 1
pump_stop() {
- local iface="$1" count e
+ local iface="$1" count= e=
# We check for a pump process first as querying for status
# causes pump to spawn a process
@@ -62,7 +62,7 @@ pump_stop() {
# Returns 0 (true) when a dhcp address is obtained, otherwise
# the return value from pump
pump_start() {
- local iface="$1" opts d ifvar="$(bash_variable "$1")" search
+ local iface="$1" opts= d= ifvar=$(bash_variable "$1") search=
interface_exists "${iface}" true || return 1
@@ -93,7 +93,7 @@ pump_start() {
eend $? || return $?
# pump succeeded, show address retrieved
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} received address ${addr}"
return 0
diff --git a/net-scripts/net/rename.sh b/net-scripts/net/rename.sh
index f3de442..2331f79 100644
--- a/net-scripts/net/rename.sh
+++ b/net-scripts/net/rename.sh
@@ -22,8 +22,7 @@ rename_expose() {
#
# Checks to see if we have to rename the interface
rename_pre_start() {
- local iface="$1" newname="" mac ifvar="$(bash_variable "$1")"
-
+ local iface="$1" newname= mac= ifvar=$(bash_variable "$1")
interface_exists "${iface}" || return 0
newname="rename_${ifvar}"
diff --git a/net-scripts/net/system.sh b/net-scripts/net/system.sh
index c32bb74..d4e6742 100644
--- a/net-scripts/net/system.sh
+++ b/net-scripts/net/system.sh
@@ -19,7 +19,7 @@ system_expose() {
}
system_dns() {
- local iface="$1" ifvar="$(bash_variable "$1")" x= domain= search=
+ local iface="$1" ifvar=$(bash_variable "$1") x= domain= search=
local buffer=
local -a servers=()
@@ -52,7 +52,7 @@ system_dns() {
}
system_ntp() {
- local iface="$1" ifvar="$(bash_variable "$1")" x= buffer=
+ local iface="$1" ifvar=$(bash_variable "$1") x= buffer=
local -a servers=()
servers="ntp_servers_${ifvar}[@]"
@@ -76,7 +76,7 @@ system_ntp() {
}
system_nis() {
- local iface="$1" ifvar="$(bash_variable "$1")" domain= x= buffer=
+ local iface="$1" ifvar=$(bash_variable "$1") domain= x= buffer=
local -a servers=()
servers="nis_servers_${ifvar}[@]"
diff --git a/net-scripts/net/tuntap.sh b/net-scripts/net/tuntap.sh
index 597cb12..921438e 100644
--- a/net-scripts/net/tuntap.sh
+++ b/net-scripts/net/tuntap.sh
@@ -55,7 +55,7 @@ tuntap_exists() {
#
# Create the device, give it the right perms
tuntap_pre_start() {
- local iface="$1" ifvar="$(bash_variable "$1")"
+ local iface="$1" ifvar=$(bash_variable "$1")
local tuntap="tuntap_${ifvar}"
[[ -z ${!tuntap} ]] && return 0
diff --git a/net-scripts/net/udhcpc.sh b/net-scripts/net/udhcpc.sh
index 6fc1a19..909c784 100644
--- a/net-scripts/net/udhcpc.sh
+++ b/net-scripts/net/udhcpc.sh
@@ -38,14 +38,14 @@ udhcpc_check_installed() {
# Stops udhcpc running on an interface
# Return 1 if we fail to stop udhcpc (if it's running) otherwise 0
udhcpc_stop() {
- local iface="$1" pidfile="/var/run/udhcpc-$1.pid" d
+ local iface="$1" pidfile="/var/run/udhcpc-$1.pid" d=
[[ ! -f ${pidfile} ]] && return 0
ebegin "Stopping udhcpc on ${iface}"
- local pid="$(<"${pidfile}")" e=true
+ local pid=$(<"${pidfile}") e=true
- local ifvar="$(bash_variable "${iface}")"
+ local ifvar=$(bash_variable "${iface}")
d="dhcp_${ifvar}"
[[ -z ${!d} ]] && d="dhcp"
@@ -69,12 +69,12 @@ udhcpc_stop() {
#
# Returns 0 (true) when a DHCP address is obtained, otherwise 1
udhcpc_start() {
- local iface="$1" opts pidfile="/var/run/udhcpc-$1.pid"
+ local iface="$1" opts= pidfile="/var/run/udhcpc-$1.pid"
local cachefile="/var/cache/udhcpc-$1.lease" d
interface_exists "${iface}" true || return 1
- local ifvar="$(bash_variable "${iface}" )" opts
+ local ifvar=$(bash_variable "${iface}" ) opts=
opts="udhcpc_${ifvar}"
opts="${!opts}"
@@ -83,7 +83,7 @@ udhcpc_start() {
if [[ " ${!d} " != *" nosendhost "* ]]; then
if [[ ! " ${opts}" =~ " -([hH] |-hostname=)" ]]; then
- local hname="$(hostname)"
+ local hname=$(hostname)
[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
&& opts="${opts} --hostname=${hname}"
fi
@@ -118,7 +118,7 @@ udhcpc_start() {
# Try and load the cache if it exists
if [[ -f ${cachefile} ]]; then
if [[ " ${opts}" != *" --request="* && " ${opts} " != *" -r "* ]]; then
- local x="$(<"${cachefile}")"
+ local x=$(<"${cachefile}")
# Check for a valid ip
[[ ${x} == *.*.*.* ]] && opts="${opts} --request=${x}"
fi
@@ -138,7 +138,7 @@ udhcpc_start() {
eend $? || return 1
# DHCP succeeded, show address retrieved
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} received address ${addr}"
return 0
diff --git a/net-scripts/net/vlan.sh b/net-scripts/net/vlan.sh
index f6c1e26..bf2e1fe 100644
--- a/net-scripts/net/vlan.sh
+++ b/net-scripts/net/vlan.sh
@@ -66,7 +66,7 @@ vlan_check_kernel() {
#
# Setup vconfig
vlan_pre_start() {
- local iface="$1" opts i x e ifvar="$(bash_variable "$1")"
+ local iface="$1" opts= i= x= e= ifvar=$(bash_variable "$1")
opts="vconfig_${ifvar}[@]"
[[ -z ${!opts} ]] && return 0
@@ -82,7 +82,7 @@ vlan_pre_start() {
x="${opts[i]/ / ${iface} }"
[[ ${x} == "${opts[i]}" ]] && x="${x} ${iface}"
fi
- e="$(vconfig ${x} 2>&1 1>/dev/null)"
+ e=$(vconfig ${x} 2>&1 1>/dev/null)
[[ -z ${e} ]] && continue
eerror "vconfig ${x}"
eerror "${e}"
@@ -98,8 +98,8 @@ vlan_pre_start() {
#
# Always returns 0 (true)
vlan_post_start() {
- local iface="$1" vlan vlans vlans_old ifname ifvar="$(bash_variable "$1")"
- vlans="vlans_${ifvar}[@]"
+ local iface="$1" ifvar=$(bash_variable "$1")
+ local vlan= vlans= vlans_old= ifname= vlans="vlans_${ifvar}[@]"
local start="vlan_start_${ifvar}"
# BACKWARD COMPATIBILITY: check for old vlan variable name
@@ -114,7 +114,7 @@ vlan_post_start() {
# Start vlans for this interface
for vlan in ${!vlans} ; do
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
eend 1 "${e}"
continue
@@ -127,11 +127,12 @@ vlan_post_start() {
[[ -n ${!start} && ${!start} != "yes" ]] && continue
# We need to work out the interface name of our new vlan id
- ifname="$( \
+ ifname=$( \
sed -n -e 's/^\([^ \t]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \
/proc/net/vlan/config
- )"
- iface_start "${ifname}"
+ )
+ mark_service_started "net.${ifname}"
+ iface_start "${ifname}" || mark_service_stopped "net.${ifname}"
done
return 0
@@ -143,14 +144,16 @@ vlan_post_start() {
#
# Always returns 0 (true)
vlan_stop() {
- local iface="$1" vlan
+ local iface="$1" vlan=
vlan_check_installed || return 0
for vlan in $(vlan_get_vlans "${iface}"); do
einfo "Removing VLAN ${vlan##*.} from ${iface}"
- iface_stop "${vlan}"
- vconfig rem "${vlan}" >/dev/null
+ if iface_stop "${vlan}" ; then
+ mark_service_stopped "net.${vlan}"
+ vconfig rem "${vlan}" >/dev/null
+ fi
done
return 0
diff --git a/net-scripts/net/wpa_supplicant.sh b/net-scripts/net/wpa_supplicant.sh
index 4ecff2d..a366577 100644
--- a/net-scripts/net/wpa_supplicant.sh
+++ b/net-scripts/net/wpa_supplicant.sh
@@ -56,6 +56,9 @@ wpa_supplicant_check_installed() {
#
# Checks to see if wireless extensions are enabled on the interface
wpa_supplicant_exists() {
+ # Support new sysfs layout
+ [[ -L /sys/class/net/$1/wiphy ]] && return 0
+
[[ ! -e /proc/net/wireless ]] && return 1
grep -q "^[ \t]*$1:" /proc/net/wireless
}
@@ -64,10 +67,10 @@ wpa_supplicant_exists() {
#
# Gets the current ESSID of iface
wpa_supplicant_get_essid() {
- local i essid
+ local i= essid=
for (( i=0; i<5; i++ )); do
- essid="$( wpa_cli -i"$1" status | sed -n -e 's/^ssid=//p' )"
+ essid=$( wpa_cli -i"$1" status | sed -n -e 's/^ssid=//p' )
if [[ -n ${essid} ]] ; then
echo "${essid}"
return 0
@@ -92,7 +95,7 @@ wpa_supplicant_get_ap_mac_address() {
# Note that just because we are associated does not mean we are using the
# correct encryption keys
wpa_supplicant_associated() {
- local -a status
+ local -a status=()
eval status=( $(wpa_cli -i"$1" status \
| sed -n -e 's/^\(key_mgmt\|wpa_state\|EAP state\)=\([^=]\+\).*/\U\"\2\"/p')
)
@@ -116,7 +119,7 @@ wpa_supplicant_associated() {
#
# Kills any existing wpa_supplicant process on the interface
wpa_supplicant_kill() {
- local iface="$1" report="${2:-false}" pidfile
+ local iface="$1" report="${2:-false}" pidfile=
# Shutdown wpa_cli first, if it's running
# This is important as future versions of wpa_supplicant
@@ -147,7 +150,7 @@ wpa_supplicant_kill() {
# Returns 0 if wpa_supplicant associates and authenticates to an AP
# otherwise, 1
wpa_supplicant_associate() {
- local iface="$1" ifvar="$(bash_variable "$1")" timeout
+ local iface="$1" ifvar=$(bash_variable "$1") timeout=
timeout="associate_timeout_${ifvar}"
[[ -z ${!timeout} ]] && timeout="wpa_timeout_${ifvar}"
timeout="${!timeout:--1}"
@@ -200,15 +203,15 @@ wpa_supplicant_associate() {
# Start wpa_supplicant on an interface and wait for association
# Returns 0 (true) when successful, non-zero otherwise
wpa_supplicant_pre_start() {
- local iface="$1" opts="" timeout="" actfile="" cfgfile=""
+ local iface="$1" opts= timeout= actfile= cfgfile=
# We don't configure wireless if we're being called from
# the background unless we're not currently running
if ${IN_BACKGROUND} ; then
if service_started_daemon "net.${iface}" /sbin/wpa_supplicant ; then
if wpa_supplicant_exists "${iface}" ; then
- ESSID="$( wpa_supplicant_get_essid "${iface}" )"
- ESSIDVAR="$( bash_variable "${ESSID}" )"
+ ESSID=$(wpa_supplicant_get_essid "${iface}")
+ ESSIDVAR=$(bash_variable "${ESSID}")
save_options "ESSID" "${ESSID}"
metric=2000
fi
@@ -218,7 +221,7 @@ wpa_supplicant_pre_start() {
save_options "ESSID" ""
- local ifvar="$( bash_variable "${iface}" )"
+ local ifvar=$(bash_variable "${iface}")
opts="wpa_supplicant_${ifvar}"
opts=" ${!opts} "
[[ ${opts} != *" -D"* ]] \
@@ -234,15 +237,6 @@ wpa_supplicant_pre_start() {
fi
fi
- # Check for rf_kill - only ipw supports this at present, but other
- # cards may in the future
- if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]] ; then
- if [[ $( < "/sys/class/net/${iface}/device/rf_kill" ) != 0 ]] ; then
- eerror "Wireless radio has been killed for interface ${iface}"
- return 1
- fi
- fi
-
# If wireless-tools is installed, try and apply our user config
# This is needed for some drivers - such as hostap because they start
# the card in Master mode which causes problems with wpa_supplicant.
@@ -253,6 +247,15 @@ wpa_supplicant_pre_start() {
fi
fi
+ # Check for rf_kill - only ipw supports this at present, but other
+ # cards may in the future
+ if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]] ; then
+ if [[ $( < "/sys/class/net/${iface}/device/rf_kill" ) != 0 ]] ; then
+ eerror "Wireless radio has been killed for interface ${iface}"
+ return 1
+ fi
+ fi
+
ebegin "Starting wpa_supplicant on ${iface}"
cfgfile="${opts##* -c}"
@@ -275,7 +278,7 @@ wpa_supplicant_pre_start() {
fi
# Work out where the ctrl_interface dir is if it's not specified
- local ctrl_dir="$( sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' "${cfgfile}" )"
+ local ctrl_dir=$(sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' "${cfgfile}")
if [[ -z ${ctrl_dir} ]] ; then
ctrl_dir="${opts##* -C}"
if [[ -n ${ctrl_dir} && ${ctrl_dir} != "${opts}" ]] ; then
@@ -330,11 +333,11 @@ wpa_supplicant_pre_start() {
# Only report wireless info for wireless interfaces
if wpa_supplicant_exists "${iface}" ; then
# Set ESSID for essidnet and report
- ESSID="$( wpa_supplicant_get_essid "${iface}" )"
- ESSIDVAR="$( bash_variable "${ESSID}" )"
+ ESSID=$(wpa_supplicant_get_essid "${iface}" )
+ ESSIDVAR=$(bash_variable "${ESSID}")
save_options "ESSID" "${ESSID}"
- local -a status
+ local -a status=()
eval status=( $(wpa_cli -i"${iface}" status | sed -n -e 's/^\(bssid\|pairwise_cipher\|key_mgmt\)=\([^=]\+\).*/\"\U\2\"/p' | tr '[:lower:]' '[:upper:]') )
einfo "${iface} connected to \"${ESSID//\\\\/\\\\}\" at ${status[0]}"
@@ -353,7 +356,7 @@ wpa_supplicant_pre_start() {
fi
if [[ -n ${actfile} ]] ; then
- local addr="$(interface_get_address "${iface}")"
+ local addr=$(interface_get_address "${iface}")
einfo "${iface} configured with address ${addr}"
exit 0
fi