aboutsummaryrefslogtreecommitdiff
path: root/net.Linux
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-11-28 15:45:03 +0000
committerRoy Marples <roy@marples.name>2007-11-28 15:45:03 +0000
commitac9279cc0d5a00bc17908b2914941186020cd3ce (patch)
tree850a4fe19917113e75bfd2e79d00b58208468503 /net.Linux
parent444f23e2d158389b22d40537fc9b027d9f575229 (diff)
Massive whitespace cleanup
Diffstat (limited to 'net.Linux')
-rw-r--r--net.Linux/apipa.sh7
-rw-r--r--net.Linux/arping.sh22
-rw-r--r--net.Linux/bonding.sh10
-rw-r--r--net.Linux/br2684ctl.sh4
-rw-r--r--net.Linux/bridge.sh4
-rw-r--r--net.Linux/ccwgroup.sh10
-rw-r--r--net.Linux/clip.sh24
-rw-r--r--net.Linux/ifconfig.sh48
-rw-r--r--net.Linux/ifplugd.sh28
-rw-r--r--net.Linux/ip6to4.sh24
-rw-r--r--net.Linux/ipppd.sh4
-rw-r--r--net.Linux/iproute2.sh54
-rw-r--r--net.Linux/iwconfig.sh216
-rw-r--r--net.Linux/netplugd.sh24
-rw-r--r--net.Linux/pppd.sh60
-rw-r--r--net.Linux/pump.sh10
-rw-r--r--net.Linux/udhcpc.sh22
-rw-r--r--net.Linux/vlan.sh10
18 files changed, 291 insertions, 290 deletions
diff --git a/net.Linux/apipa.sh b/net.Linux/apipa.sh
index d7c959eb..42e85f5d 100644
--- a/net.Linux/apipa.sh
+++ b/net.Linux/apipa.sh
@@ -28,8 +28,9 @@ apipa_depend() {
}
_random() {
- if [ -n "${BASH}" ] ; then
- echo "${RANDOM}"
+ local r=${RANDOM}
+ if [ -n "${r}" ]; then
+ echo "${r}"
else
uuidgen | sed -n -e 's/[^[:digit:]]//g' -e 's/\(^.\{1,7\}\).*/\1/p'
fi
@@ -49,7 +50,7 @@ apipa_start() {
addr="169.254.${i1}.${i2}"
vebegin "${addr}/16"
- if ! arping_address "${addr}" ; then
+ if ! arping_address "${addr}"; then
eval config_${config_index}="\"${addr}/16 broadcast 169.254.255.255\""
config_index=$((${config_index} - 1))
veend 0
diff --git a/net.Linux/arping.sh b/net.Linux/arping.sh
index 977b1911..d173465b 100644
--- a/net.Linux/arping.sh
+++ b/net.Linux/arping.sh
@@ -33,9 +33,9 @@ arping_address() {
# We only handle IPv4 addresses
case "${ip}" in
- 0.0.0.0|0) return 1 ;;
- *.*.*.*) ;;
- *) return 1 ;;
+ 0.0.0.0|0) return 1;;
+ *.*.*.*);;
+ *) return 1;;
esac
# We need to bring the interface up to test
@@ -64,8 +64,8 @@ arping_address() {
fi
[ -z "${foundmac}" ] && return 1
- if [ -n "${mac}" ] ; then
- if [ "${mac}" != "${foundmac}" ] ; then
+ if [ -n "${mac}" ]; then
+ if [ "${mac}" != "${foundmac}" ]; then
vewarn "Found ${ip} but MAC ${foundmac} does not match"
return 1
fi
@@ -86,7 +86,7 @@ arping_start() {
einfo "Pinging gateways on ${IFACE} for configuration"
eval gateways=\$gateways_${IFVAR}
- if [ -z "${gateways}" ] ; then
+ if [ -z "${gateways}" ]; then
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
return 1
fi
@@ -99,18 +99,18 @@ arping_start() {
local ip=$1 mac=$2 spoof=$3 extra=
unset IFS
- if [ -n "${mac}" ] ; then
+ if [ -n "${mac}" ]; then
mac="$(echo "${mac}" | tr '[:lower:]' '[:upper:]')"
extra="(MAC ${mac})"
fi
vebegin "${ip} ${extra}"
- if arping_address "${ip}" "${mac}" "${spoof}" ; then
+ if arping_address "${ip}" "${mac}" "${spoof}"; then
local IFS=.
- for i in ${ip} ; do
- if [ "${#i}" = "2" ] ; then
+ for i in ${ip}; do
+ if [ "${#i}" = "2" ]; then
conf="${conf}0${i}"
- elif [ "${#i}" = "1" ] ; then
+ elif [ "${#i}" = "1" ]; then
conf="${conf}00${i}"
else
conf="${conf}${i}"
diff --git a/net.Linux/bonding.sh b/net.Linux/bonding.sh
index 23c05db3..617f76f6 100644
--- a/net.Linux/bonding.sh
+++ b/net.Linux/bonding.sh
@@ -40,8 +40,8 @@ bonding_pre_start() {
[ -z "${slaves}" ] && return 0
# Load the kernel module if required
- if [ ! -d /proc/net/bonding ] ; then
- if ! modprobe bonding ; then
+ if [ ! -d /proc/net/bonding ]; then
+ if ! modprobe bonding; then
eerror "Cannot load the bonding module"
return 1
fi
@@ -49,12 +49,12 @@ bonding_pre_start() {
# We can create the interface name we like now, but this
# requires sysfs
- if ! _exists && [ -d /sys/class/net ] ; then
+ if ! _exists && [ -d /sys/class/net ]; then
echo "+${IFACE}" > /sys/class/net/bonding_masters
fi
_exists true || return 1
- if ! _is_bond ; then
+ if ! _is_bond; then
eerror "${IFACE} is not capable of bonding"
return 1
fi
@@ -107,7 +107,7 @@ bonding_stop() {
# reset all slaves
(
for IFACE in ${slaves}; do
- if _exists ; then
+ if _exists; then
_delete_addresses
_down
fi
diff --git a/net.Linux/br2684ctl.sh b/net.Linux/br2684ctl.sh
index ea5c0ef5..b3f186e4 100644
--- a/net.Linux/br2684ctl.sh
+++ b/net.Linux/br2684ctl.sh
@@ -35,7 +35,7 @@ br2684ctl_pre_start() {
eval opts=\$br2684ctl_${IFVAR}
[ -z "${opts}" ] && return 0
- if [ "${IFACE#nas[0-9]*}" = "${IFACE}" ] ; then
+ if [ "${IFACE#nas[0-9]*}" = "${IFACE}" ]; then
eerror "Interface must be called nas[0-9] for RFC 2684 Bridging"
return 1
fi
@@ -45,7 +45,7 @@ br2684ctl_pre_start() {
eerror "The -b and -c options are not allowed for br2684ctl_${IVAR}"
return 1
;;
- *" -a "*) ;;
+ *" -a "*);;
*)
eerror "-a option (VPI and VCI) is required in br2684ctl_${IFVAR}"
return 1
diff --git a/net.Linux/bridge.sh b/net.Linux/bridge.sh
index d0545890..6c3019bc 100644
--- a/net.Linux/bridge.sh
+++ b/net.Linux/bridge.sh
@@ -45,7 +45,7 @@ bridge_pre_start() {
[ -n "${ports}" ] && bridge_post_stop
(
- if [ -z "${ports}" -a -n "${brif}" ] ; then
+ if [ -z "${ports}" -a -n "${brif}" ]; then
ports="${IFACE}"
IFACE="${brif}"
else
@@ -100,7 +100,7 @@ bridge_pre_start() {
bridge_post_stop() {
local port= ports= delete=false extra=
- if _is_bridge ; then
+ if _is_bridge; then
ebegin "Destroying bridge ${IFACE}"
_down
ports="$(brctl show 2>/dev/null | \
diff --git a/net.Linux/ccwgroup.sh b/net.Linux/ccwgroup.sh
index 8fc4ce90..ed70bb54 100644
--- a/net.Linux/ccwgroup.sh
+++ b/net.Linux/ccwgroup.sh
@@ -33,9 +33,9 @@ ccwgroup_pre_start() {
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ -z "${ccwgroup}" ] && return 0
- if [ ! -d /sys/bus/ccwgroup ] ; then
+ if [ ! -d /sys/bus/ccwgroup ]; then
modprobe qeth
- if [ ! -d /sys/bus/ccwgroup ] ; then
+ if [ ! -d /sys/bus/ccwgroup ]; then
eerror "ccwgroup support missing in kernel"
return 1
fi
@@ -47,7 +47,7 @@ ccwgroup_pre_start() {
[ -z "${first}" ] && first=${x}
ccw="${ccw}${ccw:+,}${x}"
done
- if [ -e /sys/devices/qeth/"${first}" ] ; then
+ if [ -e /sys/devices/qeth/"${first}" ]; then
echo "0" > /sys/devices/qeth/"${first}"/online
else
echo "${ccw}" > /sys/bus/ccwgroup/drivers/qeth/group
@@ -65,8 +65,8 @@ ccwgroup_pre_stop() {
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
case "${diver}" in
- */bus/ccwgroup/*) ;;
- *) return 0 ;;
+ */bus/ccwgroup/*);;
+ *) return 0;;
esac
local device="$(readlink /sys/class/net/"${IFACE}"/device)"
diff --git a/net.Linux/clip.sh b/net.Linux/clip.sh
index 7c7ec7d4..329716b4 100644
--- a/net.Linux/clip.sh
+++ b/net.Linux/clip.sh
@@ -83,24 +83,24 @@ clip_pre_start() {
eval clip=\$clip_${IFVAR}
[ -z "${clip}" ] && return 0
- if [ ! -r /proc/net/atm/arp ] ; then
+ if [ ! -r /proc/net/atm/arp ]; then
modprobe clip && sleep 2
- if [ ! -r /proc/net/atm/arp ] ; then
+ if [ ! -r /proc/net/atm/arp ]; then
eerror "You need first to enable kernel support for ATM CLIP"
return 1
fi
fi
local started_here=
- if ! are_atmclip_svcs_running ; then
+ if ! are_atmclip_svcs_running; then
atmclip_svcs_start || return 1
started_here=1
fi
- if ! _exists ; then
+ if ! _exists; then
ebegin "Creating CLIP interface ${IFACE}"
atmarp -c "${IFACE}"
- if ! eend $? ; then
+ if ! eend $?; then
[ -z "${started_here}" ] && atmclip_svcs_stop
return 1
fi
@@ -130,7 +130,7 @@ 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 ${clip} ; do
+ for i in ${clip}; do
local IFS=","
set -- ${i}
unset IFS
@@ -139,14 +139,14 @@ clip_post_start() {
ebegin "Creating PVC ${ifvpivci} for peer ${peerip}"
local nleftretries=10 emsg= ecode=
- while [ ${nleftretries} -gt 0 ] ; do
+ while [ ${nleftretries} -gt 0 ]; do
nleftretries=$((${nleftretries} - 1))
emsg="$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1)"
ecode=$? && break
sleep 2
done
- if ! eend ${ecode} ; then
+ if ! eend ${ecode}; then
eerror "Creation failed for PVC ${ifvpivci}: ${emsg}"
has_failures=1
fi
@@ -175,7 +175,7 @@ clip_pre_stop() {
eindent
{
read left && \
- while read itf t encp idle ipaddr left ; do
+ while read itf t encp idle ipaddr left; do
if [ "${itf}" = "${IFACE}" ]; then
ebegin "Removing PVC to ${ipaddr}"
atmarp -d "${ipaddr}"
@@ -197,15 +197,15 @@ clip_post_stop() {
local itf= left= hasothers=
{
read left && \
- while read itf left ; do
- if [ "${itf}" != "${IFACE}" ] ; then
+ while read itf left; do
+ if [ "${itf}" != "${IFACE}" ]; then
hasothers=1
break
fi
done
} < /proc/net/atm/arp
- if [ -z "${hasothers}" ] ; then
+ if [ -z "${hasothers}" ]; then
atmclip_svcs_stop || return 1
fi
}
diff --git a/net.Linux/ifconfig.sh b/net.Linux/ifconfig.sh
index 2b1465a2..04a9ec1e 100644
--- a/net.Linux/ifconfig.sh
+++ b/net.Linux/ifconfig.sh
@@ -42,7 +42,7 @@ _exists() {
_ifindex() {
local line= i=-2
- while read line ; do
+ while read line; do
i=$((${i} + 1))
[ ${i} -lt 1 ] && continue
case "${line}" in
@@ -74,11 +74,11 @@ _get_mac_address() {
case "${mac}" in
- 00:00:00:00:00:00) ;;
- 44:44:44:44:44:44) ;;
- FF:FF:FF:FF:FF:FF) ;;
- "") ;;
- *) echo "${mac}"; return 0 ;;
+ 00:00:00:00:00:00);;
+ 44:44:44:44:44:44);;
+ FF:FF:FF:FF:FF:FF);;
+ "");;
+ *) echo "${mac}"; return 0;;
esac
return 1
@@ -102,7 +102,7 @@ _get_inet_addresses() {
local iface=${IFACE} i=0
local addrs="$(_get_inet_address)"
- while true ; do
+ while true; do
local IFACE="${iface}:${i}"
_exists || break
local addr="$(_get_inet_address)"
@@ -118,14 +118,14 @@ _cidr2netmask() {
local octets=$((${cidr} / 8))
local frac=$((${cidr} % 8))
- while [ ${octets} -gt 0 ] ; do
+ while [ ${octets} -gt 0 ]; do
netmask="${netmask}.255"
octets=$((${octets} - 1))
done=$((${done} + 1))
done
- if [ ${done} -lt 4 ] ; then
- while [ ${i} -lt ${frac} ] ; do
+ if [ ${done} -lt 4 ]; then
+ while [ ${i} -lt ${frac} ]; do
sum=$((${sum} + ${cur}))
cur=$((${cur} / 2))
i=$((${i} + 1))
@@ -133,7 +133,7 @@ _cidr2netmask() {
netmask="${netmask}.${sum}"
done=$((${done} + 1))
- while [ ${done} -lt 4 ] ; do
+ while [ ${done} -lt 4 ]; do
netmask="${netmask}.0"
done=$((${done} + 1))
done
@@ -143,7 +143,7 @@ _cidr2netmask() {
}
_add_address() {
- if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ] ; then
+ if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
ifconfig "${IFACE}" "$@" 2>/dev/null
return 0
fi
@@ -155,7 +155,7 @@ _add_address() {
# IPv4 is tricky - ifconfig requires an aliased device
# for multiple addresses
local iface="${IFACE}"
- if LC_ALL=C ifconfig "${iface}" | grep -Eq "\<inet addr:.*" ; then
+ if LC_ALL=C ifconfig "${iface}" | grep -Eq "\<inet addr:.*"; then
# Get the last alias made for the interface and add 1 to it
i=$(ifconfig | sed '1!G;h;$!d' | grep -m 1 -o "^${iface}:[0-9]*" \
| sed -n -e 's/'"${iface}"'://p')
@@ -172,17 +172,17 @@ _add_address() {
fi
local arg= cmd=
- while [ -n "$1" ] ; do
+ while [ -n "$1" ]; do
case "$1" in
brd)
- if [ "$2" = "+" ] ; then
+ if [ "$2" = "+" ]; then
shift
else
cmd="${cmd} broadcast"
fi
;;
peer) cmd="${cmd} pointtopoint";;
- *) cmd="${cmd} $1" ;;
+ *) cmd="${cmd} $1";;
esac
shift
done
@@ -193,15 +193,15 @@ _add_address() {
_add_route() {
local inet6=
- if [ -n "${metric}" ] ; then
+ if [ -n "${metric}" ]; then
set -- "$@" metric ${metric}
fi
- if [ $# -eq 3 ] ; then
+ if [ $# -eq 3 ]; then
set -- "$1" "$2" gw "$3"
- elif [ "$3" = "via" ] ; then
+ elif [ "$3" = "via" ]; then
local one=$1 two=$2
- shift ; shift; shift
+ shift; shift; shift
set -- "${one}" "${two}" gw "$@"
fi
@@ -218,7 +218,7 @@ _add_route() {
_delete_addresses() {
# We don't remove addresses from aliases
case "${IFACE}" in
- *:*) return 0 ;;
+ *:*) return 0;;
esac
einfo "Removing addresses"
@@ -227,11 +227,11 @@ _delete_addresses() {
# iproute2 added addresses cause problems for ifconfig
# as we delete an address, a new one appears, so we have to
# keep polling
- while true ; do
+ while true; do
local addr=$(_get_inet_address)
[ -z "${addr}" ] && break
- if [ "${addr}" = "127.0.0.1/8" ] ; then
+ if [ "${addr}" = "127.0.0.1/8" ]; then
# Don't delete the loopback address
[ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] && break
fi
@@ -242,7 +242,7 @@ _delete_addresses() {
# Remove IPv6 addresses
local addr=
for addr in $(LC_ALL=C ifconfig "${IFACE}" | \
- sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p') ; do
+ sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p'); do
[ "${addr}" = "::1/128" -a "${IFACE}" = "lo" ] && continue
einfo "${addr}"
ifconfig "${IFACE}" inet6 del "${addr}"
diff --git a/net.Linux/ifplugd.sh b/net.Linux/ifplugd.sh
index 3c90f860..58edffc7 100644
--- a/net.Linux/ifplugd.sh
+++ b/net.Linux/ifplugd.sh
@@ -35,22 +35,22 @@ ifplugd_depend() {
ifplugd_pre_start() {
local pidfile="/var/run/ifplugd.${IFACE}.pid" timeout= args=
- # We don't start netplug if we're being called from the background
+ # We don't start ifplugd if we're being called from the background
yesno ${IN_BACKGROUND} && return 0
_exists || return 0
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
- if ! _get_mac_address >/dev/null 2>/dev/null ; then
- vewarn "netplug only works on interfaces with a valid MAC address"
+ if ! _get_mac_address >/dev/null 2>&1; then
+ vewarn "ifplugd only works on interfaces with a valid MAC address"
return 0
fi
# We don't work on bonded, bridges, tun/tap, vlan or wireless
- for f in bond bridge tuntap vlan wireless ; do
- if type "_is_${f}" >/dev/null 2>/dev/null ; then
- if _is_${f} ; then
+ for f in bond bridge tuntap vlan wireless; do
+ if type "_is_${f}" >/dev/null 2>&1; then
+ if _is_${f}; then
veinfo "netplug does not work with" "${f}"
return 0
fi
@@ -73,28 +73,28 @@ ifplugd_pre_start() {
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=-1
- if [ ${timeout} -eq 0 ] ; then
- ewarn "WARNING: infinite timeout set for" "${IFACE}" "to come up"
- elif [ ${timeout} -lt 0 ] ; then
+ if [ ${timeout} -eq 0 ]; then
+ ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
+ elif [ ${timeout} -lt 0 ]; then
einfo "Backgrounding ..."
exit 1
fi
- veinfo "Waiting for" "${IFACE}" "to be marked as started"
+ veinfo "Waiting for ${IFACE} to be marked as started"
local i=0
- while true ; do
- if service_started "${SVCNAME}" ; then
+ while true; do
+ if service_started "${SVCNAME}"; then
_show_address
exit 0
fi
sleep 1
- [ ${timeout} -eq 0 ]] && continue
+ [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1))
[ ${i} -ge ${timeout} ] && break
done
- eend 1 "Failed to configure" "${IFACE}" "in the background"
+ eend 1 "Failed to configure ${IFACE} in the background"
exit 1
}
diff --git a/net.Linux/ip6to4.sh b/net.Linux/ip6to4.sh
index f70d5cbe..77b7de10 100644
--- a/net.Linux/ip6to4.sh
+++ b/net.Linux/ip6to4.sh
@@ -32,7 +32,7 @@ ip6to4_depend() {
ip6to4_start() {
case " ${MODULES} " in
*" ifconfig "*)
- if [ "${IFACE}" != "sit0" ] ; then
+ if [ "${IFACE}" != "sit0" ]; then
eerror "ip6to4 can only work on the sit0 interface using ifconfig"
eerror "emerge sys-apps/iproute2 to use other interfaces"
return 1
@@ -41,7 +41,7 @@ ip6to4_start() {
local host= suffix= relay= addr= iface=${IFACE} new= localip=
eval host=\$link_${IFVAR}
- if [ -z "${host}" ] ; then
+ if [ -z "${host}" ]; then
eerror "link_${IFVAR} not set"
return 1
fi
@@ -52,24 +52,24 @@ ip6to4_start() {
IFACE=${host}
addrs=$(_get_inet_addresses)
IFACE=${iface}
- if [ -z "${addrs}" ] ; then
+ if [ -z "${addrs}" ]; then
eerror "${host} is not configured with an IPv4 address"
return 1
fi
- for addr in ${addrs} ; do
+ for addr in ${addrs}; do
# Strip the subnet
local ip="${addr%/*}" subnet="${addr#*/}"
# We don't work on private IPv4 addresses
case "${ip}" in
- 127.*) continue ;;
- 10.*) continue ;;
- 192.168.*) continue ;;
+ 127.*) continue;;
+ 10.*) continue;;
+ 192.168.*) continue;;
172.*)
local i=16
- while [ ${i} -lt 32 ] ; do
+ while [ ${i} -lt 32 ]; do
case "${ip}" in
- 172.${i}.*) break ;;
+ 172.${i}.*) break;;
esac
i=$((${i} + 1))
done
@@ -89,19 +89,19 @@ ip6to4_start() {
# Now apply our IPv6 address to our config
new="${new}${new:+ }${ip6}/16"
- if [ -n "${localip}" ] ; then
+ if [ -n "${localip}" ]; then
localip="any"
else
localip="${ip}"
fi
done
- if [ -z "${new}" ] ; then
+ if [ -z "${new}" ]; then
eerror "No global IPv4 addresses found on interface ${host}"
return 1
fi
- if [ "${IFACE}" != "sit0" ] ; then
+ if [ "${IFACE}" != "sit0" ]; then
ebegin "Creating 6to4 tunnel on ${IFACE}"
_tunnel add "${IFACE}" mode sit ttl 255 remote any local "${localip}"
eend $? || return 1
diff --git a/net.Linux/ipppd.sh b/net.Linux/ipppd.sh
index 60e51062..4e113927 100644
--- a/net.Linux/ipppd.sh
+++ b/net.Linux/ipppd.sh
@@ -37,8 +37,8 @@ ipppd_pre_start() {
# Check that we are a valid ippp interface
case "${IFACE}" in
- ippp[0-9]*) ;;
- *) return 0 ;;
+ ippp[0-9]*);;
+ *) return 0;;
esac
# Check that the interface exists
diff --git a/net.Linux/iproute2.sh b/net.Linux/iproute2.sh
index 23183d60..d3f3e76a 100644
--- a/net.Linux/iproute2.sh
+++ b/net.Linux/iproute2.sh
@@ -43,7 +43,7 @@ _exists() {
_ifindex() {
local line= i=-2
- while read line ; do
+ while read line; do
i=$((${i} + 1))
[ ${i} -lt 1 ] && continue
case "${line}" in
@@ -80,11 +80,11 @@ _get_mac_address() {
-e '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\1/p')
case "${mac}" in
- 00:00:00:00:00:00) ;;
- 44:44:44:44:44:44) ;;
- FF:FF:FF:FF:FF:FF) ;;
- "") ;;
- *) echo "${mac}"; return 0 ;;
+ 00:00:00:00:00:00);;
+ 44:44:44:44:44:44);;
+ FF:FF:FF:FF:FF:FF);;
+ "");;
+ *) echo "${mac}"; return 0;;
esac
return 1
@@ -106,22 +106,22 @@ _get_inet_address() {
}
_add_address() {
- if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ] ; then
+ if [ "$1" = "127.0.0.1/8" -a "${IFACE}" = "lo" ]; then
ip addr add "$@" dev "${IFACE}" 2>/dev/null
return 0
fi
# Convert an ifconfig line to iproute2
- if [ "$2" = "netmask" ] ; then
+ if [ "$2" = "netmask" ]; then
local one="$1" three="$3"
- shift ; shift ; shift
+ shift; shift; shift
set -- "${one}/$(_netmask2cidr "${three}")" "$@"
fi
#config=( "${config[@]//pointopoint/peer}" )
# Always scope lo addresses as host unless specified otherwise
- if [ "${IFACE}" = "lo" ] ; then
+ if [ "${IFACE}" = "lo" ]; then
set -- "$@" "scope" "host"
fi
@@ -129,9 +129,9 @@ _add_address() {
case "$1" in
*.*.*.*)
case "$@" in
- *" brd "*) ;;
- *" broadcast "*) ;;
- *) set -- "$@" brd + ;;
+ *" brd "*);;
+ *" broadcast "*);;
+ *) set -- "$@" brd +;;
esac
;;
esac
@@ -140,27 +140,27 @@ _add_address() {
}
_add_route() {
- if [ $# -eq 3 ] ; then
+ if [ $# -eq 3 ]; then
set -- "$1" "$2" via "$3"
- elif [ "$3" = "gw" ] ; then
+ elif [ "$3" = "gw" ]; then
local one=$1 two=$2
- shift ; shift; shift
+ shift; shift; shift
set -- "${one}" "${two}" gw "$@"
fi
local cmd= have_metric=false
- while [ -n "$1" ] ; do
+ while [ -n "$1" ]; do
case "$1" in
- metric) cmd="${cmd} $1"; have_metric=true ;;
- netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift ;;
- -host|-net) ;;
- -A) [ "$2" = "inet6" ] && shift ;;
- *) cmd="${cmd} $1" ;;
+ metric) cmd="${cmd} $1"; have_metric=true;;
+ netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift;;
+ -host|-net);;
+ -A) [ "$2" = "inet6" ] && shift;;
+ *) cmd="${cmd} $1";;
esac
shift
done
- if ! ${have_metric} && [ -n "${metric}" ] ; then
+ if ! ${have_metric} && [ -n "${metric}" ]; then
cmd="${cmd} metric ${metric}"
fi
@@ -171,7 +171,7 @@ _add_route() {
_delete_addresses() {
ip addr flush dev "${IFACE}" scope global 2>/dev/null
ip addr flush dev "${IFACE}" scope site 2>/dev/null
- if [ "${IFACE}" != "lo" ] ; then
+ if [ "${IFACE}" != "lo" ]; then
ip addr flush dev "${IFACE}" scope host 2>/dev/null
fi
return 0
@@ -198,7 +198,7 @@ iproute2_pre_start() {
local tunnel=
eval tunnel=\$iptunnel_${IFVAR}
- if [ -n "${tunnel}" ] ; then
+ if [ -n "${tunnel}" ]; then
# Set our base metric to 1000
metric=1000
@@ -220,8 +220,8 @@ iproute2_post_start() {
iproute2_post_stop() {
# Don't delete sit0 as it's a special tunnel
- if [ "${IFACE}" != "sit0" ] ; then
- if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ] ; then
+ if [ "${IFACE}" != "sit0" ]; then
+ if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then
ebegin "Destroying tunnel ${IFACE}"
ip tunnel del "${IFACE}"
eend $?
diff --git a/net.Linux/iwconfig.sh b/net.Linux/iwconfig.sh
index 066f2581..4f8e12fd 100644
--- a/net.Linux/iwconfig.sh
+++ b/net.Linux/iwconfig.sh
@@ -36,7 +36,7 @@ iwconfig_get_wep_status() {
local mode= status="disabled"
# No easy way of doing this grep in bash regex :/
- if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]" ; then
+ if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]"; then
status="enabled"
mode=$(LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p')
[ -n "${mode}" ] && mode=" - ${mode}"
@@ -48,9 +48,9 @@ iwconfig_get_wep_status() {
_get_ssid() {
local i=5 ssid=
- while [ ${i} -gt 0 ] ; do
+ while [ ${i} -gt 0 ]; do
ssid=$(iwgetid --raw "${IFACE}")
- if [ -n "${ssid}" ] ; then
+ if [ -n "${ssid}" ]; then
echo "${ssid}"
return 0
fi
@@ -64,11 +64,11 @@ _get_ssid() {
_get_ap_mac_address() {
local mac="$(iwgetid --raw --ap "${IFACE}")"
case "${mac}" in
- "00:00:00:00:00:00") return 1 ;;
- "44:44:44:44:44:44") return 1 ;;
- "FF:00:00:00:00:00") return 1 ;;
- "FF:FF:FF:FF:FF:FF") return 1 ;;
- *) echo "${mac}" ;;
+ "00:00:00:00:00:00") return 1;;
+ "44:44:44:44:44:44") return 1;;
+ "FF:00:00:00:00:00") return 1;;
+ "FF:FF:FF:FF:FF:FF") return 1;;
+ *) echo "${mac}";;
esac
}
@@ -117,13 +117,13 @@ iwconfig_get_wep_key() {
[ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')"
eval key=\$mac_key_${mac}
[ -z "${key}" ] && eval key=\$key_${SSIDVAR}
- if [ -z "${key}" ] ; then
+ if [ -z "${key}" ]; then
echo "off"
else
set -- ${key}
local x= e=false
- for x in "$@" ; do
- if [ "${x}" = "enc" ] ; then
+ for x in "$@"; do
+ if [ "${x}" = "enc" ]; then
e=true
break
fi
@@ -141,7 +141,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
- if ! eval iwconfig "${IFACE}" "${conf}" ; then
+ if ! eval iwconfig "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following configuration commands"
ewarn " ${conf}"
fi
@@ -152,7 +152,7 @@ iwconfig_user_config() {
local IFS="$__IFS"
for conf in ${config}; do
unset IFS
- if ! eval iwpriv "${IFACE}" "${conf}" ; then
+ if ! eval iwpriv "${IFACE}" "${conf}"; then
ewarn "${IFACE} does not support the following private ioctls"
ewarn " ${conf}"
fi
@@ -172,7 +172,7 @@ iwconfig_setup_specific() {
iwconfig_set_mode "${mode}"
# Now set the key
- if ! eval iwconfig "${IFACE}" key "${key}" ; then
+ if ! eval iwconfig "${IFACE}" key "${key}"; then
if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
@@ -180,7 +180,7 @@ iwconfig_setup_specific() {
fi
# Then set the SSID
- if ! iwconfig "${IFACE}" essid "${SSID}" ; then
+ if ! iwconfig "${IFACE}" essid "${SSID}"; then
eerror "${IFACE} does not support setting SSID to \"${SSID}\""
return 1
fi
@@ -188,7 +188,7 @@ iwconfig_setup_specific() {
eval channel=\$channel_${SSIDVAR}
[ -z "${channel}" ] && eval channel=\$channel_${IFVAR}
# We default the channel to 3
- if ! iwconfig "${IFACE}" channel "${channel:-3}" ; then
+ if ! iwconfig "${IFACE}" channel "${channel:-3}"; then
ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\""
return 1
fi
@@ -210,8 +210,8 @@ iwconfig_wait_for_association() {
while true; do
# Use sysfs if we can
- if [ -e /sys/class/net/"${IFACE}"/carrier ] ; then
- if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ] ; then
+ if [ -e /sys/class/net/"${IFACE}"/carrier ]; then
+ if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ]; then
# Double check we have an ssid. This is mainly for buggy
# prism54 drivers that always set their carrier on :/
[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
@@ -220,10 +220,10 @@ iwconfig_wait_for_association() {
local atest=
eval atest=\$associate_test_${IFVAR}
atest=${atest:-mac}
- if [ "${atest}" = "mac" -o "${atest}" = "all" ] ; then
+ if [ "${atest}" = "mac" -o "${atest}" = "all" ]; then
[ -n "$(_get_ap_mac_address)" ] && return 0
fi
- if [ "${atest}" = "quality" -o "${atest}" = "all" ] ; then
+ if [ "${atest}" = "quality" -o "${atest}" = "all" ]; then
[ "$(sed -n -e 's/^.*'"${IFACE}"': *[0-9]* *\([0-9]*\).*/\1/p' \
/proc/net/wireless)" != "0" ] && return 0
fi
@@ -249,17 +249,17 @@ iwconfig_associate() {
else
SSIDVAR=$(_shell_var "${SSID}")
key="$(iwconfig_get_wep_key "${mac}")"
- if [ "${wep_required}" = "on" -a "${key}" = "off" ] ; then
+ if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
return 1
fi
- if [ "${wep_required}" = "off" -a "${key}" != "off" ] ; then
+ if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then
key="off"
ewarn "\"${SSID}\" is not WEP enabled - ignoring setting"
fi
- if ! eval iwconfig "${IFACE}" key "${key}" ; then
- if [ "${key}" != "off" ] ; then
+ if ! eval iwconfig "${IFACE}" key "${key}"; then
+ if [ "${key}" != "off" ]; then
ewarn "${IFACE} does not support setting keys"
ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
return 1
@@ -268,16 +268,16 @@ iwconfig_associate() {
[ "${key}" != "off" ] && w="$(iwconfig_get_wep_status "${iface}")"
fi
- if ! iwconfig "${IFACE}" essid "${SSID}" ; then
- if [ "${SSID}" != "any" ] ; then
+ if ! iwconfig "${IFACE}" essid "${SSID}"; then
+ if [ "${SSID}" != "any" ]; then
ewarn "${IFACE} does not support setting SSID to \"${SSID}\""
fi
fi
# Only use channel or frequency
- if [ -n "${chan}" ] ; then
+ if [ -n "${chan}" ]; then
iwconfig "${IFACE}" channel "${chan}"
- elif [ -n "${freq}" ] ; then
+ elif [ -n "${freq}" ]; then
iwconfig "${IFACE}" freq "${freq}"
fi
[ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}"
@@ -287,19 +287,19 @@ iwconfig_associate() {
ebegin "Connecting to \"${SSID}\" in ${mode} mode ${w}"
- if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>/dev/null ; then
+ if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>&1; then
veinfo "Running preassociate function"
veindent
( preassociate )
local e=$?
veoutdent
- if [ ${e} -eq 0 ] ; then
+ if [ ${e} -eq 0 ]; then
veend 1 "preassociate \"${SSID}\" on ${IFACE} failed"
return 1
fi
fi
- if ! iwconfig_wait_for_association ; then
+ if ! iwconfig_wait_for_association; then
eend 1
return 1
fi
@@ -313,7 +313,7 @@ iwconfig_associate() {
iwconfig_report
- if type postassociate >/dev/null 2>/dev/null ; then
+ if type postassociate >/dev/null 2>&1; then
veinfo "Running postassociate function"
veindent
( postassociate )
@@ -332,12 +332,12 @@ iwconfig_scan() {
eval x=\$sleep_scan_${IFVAR}
[ -n "${x}" ] && sleep "${x}"
- while [ ${i} -lt 3 ] ; do
+ while [ ${i} -lt 3 ]; do
local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")"
# If this is the first pass and txpower as off and we have no results
# then we need to wait for at least 2 seconds whilst the interface
# does an initial scan.
- if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ] ; then
+ if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ]; then
case "${scan}" in
"'${IFACE} "*"No scan results"*)
sleep 2
@@ -349,12 +349,12 @@ iwconfig_scan() {
i=$((${i} + 1))
done
- if [ -z "${scan}" ] ; then
+ if [ -z "${scan}" ]; then
ewarn "${iface} does not support scanning"
eoutdent
eval x=\$adhoc_ssid_${IFVAR}
[ -n "${x}" ] && return 0
- if [ -n "${preferred_aps}" ] ; then
+ if [ -n "${preferred_aps}" ]; then
[ "${associate_order}" = "forcepreferred" ] || \
[ "${associate_order}" = "forcepreferredonly" ] && return 0
fi
@@ -373,48 +373,48 @@ iwconfig_scan() {
APS=-1
eval set -- ${scan}
- for line in "$@" ; do
- case "${line}" in
- *Address:*)
- APS=$((${APS} + 1))
- eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"
- eval QUALITY_${APS}=0
- ;;
- *ESSID:*)
- x=${line#*\"}
- x=${x%*\"}
- eval SSID_${APS}=\$x
- ;;
- *Mode:*)
- x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
- if [ "${x}" = "master" ] ; then
- eval MODE_${APS}=\"managed\"
- else
- eval MODE_${APS}=\$x
- fi
- ;;
- *'Encryption key:'*)
- x=${line#*:}
- eval ENC_${APS}=\$x
- ;;
- #*Frequency:*)
- # freq[i]="${line#*:}"
- # x="${freq[i]#* }"
- # freq[i]="${freq[i]%% *}${x:0:1}"
- # ;;
- *Channel:*)
- x=${line#*:}
- x=${x%% *}
- eval CHAN_${APS}=\$x
- ;;
- *Quality*)
- x=${line#*:}
- x=${x%/*}
- x="$(echo "${x}" | sed -e 's/[^[:digit:]]//g')"
- x=${x:-0}
- eval QUALITY_${APS}=\$x
- ;;
- esac
+ for line in "$@"; do
+ case "${line}" in
+ *Address:*)
+ APS=$((${APS} + 1))
+ eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
+ eva l QUALITY_${APS}=0
+ ;;
+ *ESSID:*)
+ x=${line#*\"}
+ x=${x%*\"}
+ eval SSID_${APS}=\$x
+ ;;
+ *Mode:*)
+ x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
+ if [ "${x}" = "master" ]; then
+ eval MODE_${APS}=managed
+ else
+ eval MODE_${APS}=\$x
+ fi
+ ;;
+ *'Encryption key:'*)
+ x=${line#*:}
+ eval ENC_${APS}=\$x
+ ;;
+ #*Frequency:*)
+ # freq[i]="${line#*:}"
+ # x="${freq[i]#* }"
+ # freq[i]="${freq[i]%% *}${x:0:1}"
+ # ;;
+ *Channel:*)
+ x=${line#*:}
+ x=${x%% *}
+ eval CHAN_${APS}=\$x
+ ;;
+ *Quality*)
+ x=${line#*:}
+ x=${x%/*}
+ x="$(echo "${x}" | sed -e 's/[^[:digit:]]//g')"
+ x=${x:-0}
+ eval QUALITY_${APS}=\$x
+ ;;
+ esac
done
if [ -z "${MAC_0}" ]; then
@@ -425,14 +425,14 @@ iwconfig_scan() {
# Sort based on quality
local i=0 k=1 a= b= x= t=
- while [ ${i} -lt ${APS} ] ; do
+ while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
- while [ ${k} -le ${APS} ] ; do
+ while [ ${k} -le ${APS} ]; do
eval a=\$QUALITY_${i}
[ -z "${a}" ] && break
eval b=\$QUALITY_${k}
- if [ -n "${b}" -a "${a}" -lt "${b}" ] ; then
- for x in MAC SSID CHAN QUALITY ENC ; do
+ if [ -n "${b}" -a "${a}" -lt "${b}" ]; then
+ for x in MAC SSID CHAN QUALITY ENC; do
eval t=\$${x}_${i}
eval ${x}_${i}=\$${x}_${k}
eval ${x}_${k}=\$t
@@ -445,12 +445,12 @@ iwconfig_scan() {
# Strip any duplicates
local i=0 k=1 a= b=
- while [ ${i} -lt ${APS} ] ; do
+ while [ ${i} -lt ${APS} ]; do
k=$((${i} + 1))
- while [ ${k} -le ${APS} ] ; do
+ while [ ${k} -le ${APS} ]; do
eval a=\$MAC_${i}
eval b=\$MAC_${k}
- if [ "${a}" = "${b}" ] ; then
+ if [ "${a}" = "${b}" ]; then
eval a=\$QUALITY_${i}
eval b=\$QUALITY_${k}
local u=${k}
@@ -465,9 +465,9 @@ iwconfig_scan() {
local i=0 e= m= s=
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval x=\$MAC_${i}
- if [ -z "${x}" ] ; then
+ if [ -z "${x}" ]; then
i=$((${i} + 1))
continue
fi
@@ -476,12 +476,12 @@ iwconfig_scan() {
eval s=\$SSID_${i}
eval q=\$QUALITY_${i}
eval e=\$ENC_${i}
- if [ -n "${e}" -a "${e}" != "off" ] ; then
+ if [ -n "${e}" -a "${e}" != "off" ]; then
e=", encrypted"
else
e=""
fi
- if [ -z "${s}" ] ; then
+ if [ -z "${s}" ]; then
einfo "Found ${x}, ${m}${e}"
else
einfo "Found \"${s}\" at ${x}, ${m}${e}"
@@ -489,7 +489,7 @@ iwconfig_scan() {
x="$(echo "${x}" | sed -e 's/://g')"
eval x=\$mac_ssid_${x}
- if [ -n "${x}" ] ; then
+ if [ -n "${x}" ]; then
eval SSID_${i}=\$x
s=${x}
eindent
@@ -500,7 +500,7 @@ iwconfig_scan() {
eval set -- $(_flatten_array "blacklist_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "blacklist_aps")
for x in "$@"; do
- if [ "${x}" = "${s}" ] ; then
+ if [ "${x}" = "${s}" ]; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
@@ -518,15 +518,15 @@ iwconfig_force_preferred() {
ewarn "Trying to force preferred in case they are hidden"
for ssid in "$@"; do
local found_AP=false i=0 e=
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
found_AP=true
break
fi
i=$((${i} + 1))
done
- if ! ${found_AP} ; then
+ if ! ${found_AP}; then
SSID=${e}
iwconfig_associate && return 0
fi
@@ -544,9 +544,9 @@ iwconfig_connect_preferred() {
for ssid in "$@"; do
unset IFS
i=0
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@@ -566,19 +566,19 @@ iwconfig_connect_preferred() {
iwconfig_connect_not_preferred() {
local ssid= i=0 mode= mac= enc= freq= chan= pref=false
- while [ ${i} -le ${APS} ] ; do
+ while [ ${i} -le ${APS} ]; do
eval e=\$SSID_${i}
- if [ -n "${e}" ] ; then
+ if [ -n "${e}" ]; then
eval set -- $(_flatten_array "preferred_aps_${IFVAR}")
[ $# = 0 ] && eval set -- $(_flatten_array "preferred_aps")
for ssid in "$@"; do
- if [ "${e}" = "${ssid}" ] ; then
+ if [ "${e}" = "${ssid}" ]; then
pref=true
break
fi
done
- if ! ${pref} ; then
+ if ! ${pref}; then
SSID=${e}
eval mode=\$MODE_${i}
eval mac=\$MAC_${i}
@@ -597,7 +597,7 @@ iwconfig_connect_not_preferred() {
iwconfig_defaults() {
local x=
- for x in txpower rate rts frag ; do
+ for x in txpower rate rts frag; do
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
done
@@ -617,12 +617,12 @@ iwconfig_configure() {
# Setup ad-hoc mode?
eval x=\$mode_${IFVAR}
x=${x:-managed}
- if [ "${x}" = "ad-hoc" -o "${x}" = "master" ] ; then
+ if [ "${x}" = "ad-hoc" -o "${x}" = "master" ]; then
iwconfig_setup_specific "${x}"
return $?
fi
- if [ "${x}" != "managed" -a "${x}" != "auto" ] ; then
+ if [ "${x}" != "managed" -a "${x}" != "auto" ]; then
eerror "Only managed, ad-hoc, master and auto modes are supported"
return 1
fi
@@ -690,13 +690,13 @@ iwconfig_pre_start() {
save_options "SSID" ""
_exists || return 0
- if ! _is_wireless ; then
+ if ! _is_wireless; then
veinfo "Wireless extensions not found for ${IFACE}"
return 0
fi
# Warn about old file - we want to punt it really
- if [ -e /etc/conf.d/wireless ] ; then
+ if [ -e /etc/conf.d/wireless ]; then
ewarn "/etc/conf.d/wireless is deprecated"
ewarn "Please put all settings into /etc/conf.d/net"
. /etc/conf.d/wireless
@@ -715,8 +715,8 @@ iwconfig_pre_start() {
# 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 [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ] ; then
+ if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ]; then
+ if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ]; then
eerror "Wireless radio has been killed for interface ${IFACE}"
return 1
fi
@@ -736,7 +736,7 @@ iwconfig_pre_start() {
return 1
fi
- if iwconfig_configure ; then
+ if iwconfig_configure; then
save_options "SSID" "${SSID}"
return 0
fi
diff --git a/net.Linux/netplugd.sh b/net.Linux/netplugd.sh
index 160c6a60..b1460b96 100644
--- a/net.Linux/netplugd.sh
+++ b/net.Linux/netplugd.sh
@@ -45,15 +45,15 @@ netplugd_pre_start() {
# We need a valid MAC address
# It's a basic test to ensure it's not a virtual interface
- if ! _get_mac_address >/dev/null 2>/dev/null ; then
+ if ! _get_mac_address >/dev/null 2>&1; then
vewarn "netplug only works on interfaces with a valid MAC address"
return 0
fi
# We don't work on bonded, bridges, tun/tap, vlan or wireless
- for f in bond bridge tuntap vlan wireless ; do
- if type "_is_${f}" >/dev/null 2>/dev/null ; then
- if _is_${f} ; then
+ for f in bond bridge tuntap vlan wireless; do
+ if type "_is_${f}" >/dev/null 2>&1; then
+ if _is_${f}; then
veinfo "netplug does not work with" "${f}"
return 0
fi
@@ -75,28 +75,28 @@ netplugd_pre_start() {
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=-1
- if [ ${timeout} -eq 0 ] ; then
- ewarn "WARNING: infinite timeout set for" "${IFACE}" "to come up"
- elif [ ${timeout} -lt 0 ] ; then
+ if [ ${timeout} -eq 0 ]; then
+ ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
+ elif [ ${timeout} -lt 0 ]; then
einfo "Backgrounding ..."
exit 1
fi
- veinfo "Waiting for" "${IFACE}" "to be marked as started"
+ veinfo "Waiting for ${IFACE} to be marked as started"
local i=0
- while true ; do
- if service_started "${SVCNAME}" ; then
+ while true; do
+ if service_started "${SVCNAME}"; then
_show_address
exit 0
fi
sleep 1
- [ ${timeout} -eq 0 ]] && continue
+ [ ${timeout} -eq 0 ] && continue
i=$((${i} + 1))
[ ${i} -ge ${timeout} ] && break
done
- eend 1 "Failed to configure" "${IFACE}" "in the background"
+ eend 1 "Failed to configure ${IFACE} in the background"
exit 1
}
diff --git a/net.Linux/pppd.sh b/net.Linux/pppd.sh
index de63dc95..d5db153c 100644
--- a/net.Linux/pppd.sh
+++ b/net.Linux/pppd.sh
@@ -49,7 +49,7 @@ pppd_pre_start() {
local config=
eval config=\$config_${IFVAR}
# If no config for ppp then don't default to DHCP
- if [ -z "${config}" ] ; then
+ if [ -z "${config}" ]; then
eval config_${IFVAR}=null
fi
return 0
@@ -66,7 +66,7 @@ pppd_pre_start() {
case "${link}" in
/*)
- if [ ! -e "${link}" ] ; then
+ if [ ! -e "${link}" ]; then
eerror "${link} does not exist"
eerror "Please verify hardware or kernel module (driver)"
return 1
@@ -74,7 +74,7 @@ pppd_pre_start() {
;;
esac
- if [ -z "${unit}" ] ; then
+ if [ -z "${unit}" ]; then
eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp"
return 1
fi
@@ -91,12 +91,12 @@ pppd_pre_start() {
eerror "The option \"${i}\" is not allowed in pppd_${IFVAR}"
return 1
;;
- defaultmetric) hasdefaultmetric=true ;;
- mtu) hasmtu=true ;;
- mru) hasmru=true ;;
- maxfail) hasmaxfail=true ;;
- persist) haspersist=true ;;
- updetach) hasupdetach=true ;;
+ defaultmetric) hasdefaultmetric=true;;
+ mtu) hasmtu=true;;
+ mru) hasmru=true;;
+ maxfail) hasmaxfail=true;;
+ persist) haspersist=true;;
+ updetach) hasupdetach=true;;
esac
done
@@ -106,17 +106,17 @@ pppd_pre_start() {
eval password=\$password_${IFVAR}
eval passwordset=\$\{password_${IFVAR}-x\}
if [ -n "${username}" ] \
- && [ -n "${password}" -o -z "${passwordset}" ] ; then
+ && [ -n "${password}" -o -z "${passwordset}" ]; then
opts="${opts} plugin passwordfd.so passwordfd 0"
fi
- if ! ${hasdefaultmetric} ; then
+ if ! ${hasdefaultmetric}; then
local m=
eval m=\$metric_${IFVAR}
[ -z "${m}" ] && m=$((${metric} + $(_ifindex)))
opts="${opts} defaultmetric ${m}"
fi
- if [ -n "${mtu}" ] ; then
+ if [ -n "${mtu}" ]; then
${hasmtu} || opts="${opts} mtu ${mtu}"
${hasmru} || opts="${opts} mru ${mtu}"
fi
@@ -129,7 +129,7 @@ pppd_pre_start() {
opts="linkname ${IFACE} ${opts}"
# Setup auth info
- if [ -n "${username}" ] ; then
+ if [ -n "${username}" ]; then
opts="user '${username}' remotename ${IFACE} ${opts}"
fi
@@ -160,15 +160,15 @@ pppd_pre_start() {
set -- ${i}
case "$1" in
passwordfd) continue;;
- pppoa) shift; set -- "pppoatm" "$@" ;;
- pppoe) shift; set -- "rp-pppoe" "$@" ;;
- capi) shift; set -- "capiplugin" "$@" ;;
+ pppoa) shift; set -- "pppoatm" "$@";;
+ pppoe) shift; set -- "rp-pppoe" "$@";;
+ capi) shift; set -- "capiplugin" "$@";;
esac
case "$1" in
- rp-pppoe) haspppoe=true ;;
- pppoatm) haspppoa=true ;;
+ rp-pppoe) haspppoe=true;;
+ pppoatm) haspppoa=true;;
esac
- if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ] ; then
+ if [ "$1" = "rp-pppoe" ] || [ "$1" = "pppoatm" -a "${link}" != "/dev/null" ]; then
opts="${opts} connect true"
set -- "$@" "${link}"
fi
@@ -180,30 +180,30 @@ pppd_pre_start() {
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
local insert_link_in_opts=1
- if ${haspppoe} ; then
- if [ ! -e /proc/net/pppoe ] ; then
+ if ${haspppoe}; then
+ if [ ! -e /proc/net/pppoe ]; then
# Load the PPPoE kernel module
- if ! modprobe pppoe ; then
+ if ! modprobe pppoe; then
eerror "kernel does not support PPPoE"
return 1
fi
fi
# Ensure that the link exists and is up
- ( IFACE="${link}" ; _exists true && _up ) || return 1
+ ( IFACE="${link}"; _exists true && _up ) || return 1
insert_link_in_opts=0
fi
- if ${haspppoa} ; then
- if [ ! -d /proc/net/atm ] ; then
+ if ${haspppoa}; then
+ if [ ! -d /proc/net/atm ]; then
# Load the PPPoA kernel module
- if ! modprobe pppoatm ; then
+ if ! modprobe pppoatm; then
eerror "kernel does not support PPPoATM"
return 1
fi
fi
- if [ "${link}" != "/dev/null" ] ; then
+ if [ "${link}" != "/dev/null" ]; then
insert_link_in_opts=0
else
ewarn "WARNING: An [itf.]vpi.vci ATM address was expected in link_${IFVAR}"
@@ -215,7 +215,7 @@ pppd_pre_start() {
ebegin "Starting pppd in ${IFACE}"
mark_service_inactive "${SVCNAME}"
if [ -n "${username}" ] \
- && [ -n "${password}" -o -z "${passwordset}" ] ; then
+ && [ -n "${password}" -o -z "${passwordset}" ]; then
printf "%s" "${password}" | \
eval start-stop-daemon --start --exec /usr/sbin/pppd \
--pidfile "/var/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
@@ -224,12 +224,12 @@ pppd_pre_start() {
--pidfile "/var/run/ppp-${IFACE}.pid" -- "${opts}" >/dev/null
fi
- if ! eend $? "Failed to start PPP" ; then
+ if ! eend $? "Failed to start PPP"; then
mark_service_stopped "net.${IFACE}"
return 1
fi
- if ${hasupdetach} ; then
+ if ${hasupdetach}; then
_show_address
else
einfo "Backgrounding ..."
diff --git a/net.Linux/pump.sh b/net.Linux/pump.sh
index bb59dc5d..9e0fee0d 100644
--- a/net.Linux/pump.sh
+++ b/net.Linux/pump.sh
@@ -39,11 +39,11 @@ pump_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
- for opt in ${opts} ; do
+ for opt in ${opts}; do
case "${opt}" in
- nodns) args="${args} --no-dns" ;;
- nontp) args="${args} --no-ntp" ;;
- nogateway) args="${args} --no-gateway" ;;
+ nodns) args="${args} --no-dns";;
+ nontp) args="${args} --no-ntp";;
+ nogateway) args="${args} --no-gateway";;
esac
done
@@ -67,7 +67,7 @@ pump_stop() {
start-stop-daemon --quiet --test --stop --exec /sbin/pump || return 0
# Check that pump is running on the interface
- if ! pump --status --interface "${IFACE}" >/dev/null 2>/dev/null ; then
+ if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then
return 0
fi
diff --git a/net.Linux/udhcpc.sh b/net.Linux/udhcpc.sh
index bded5bb5..2e887b6e 100644
--- a/net.Linux/udhcpc.sh
+++ b/net.Linux/udhcpc.sh
@@ -42,11 +42,11 @@ udhcpc_start() {
[ -z "${opts}" ] && opts=${dhcp}
# Map some generic options to dhcpcd
- for opt in ${opts} ; do
+ for opt in ${opts}; do
case "${opt}" in
- nodns) args="${args} --env PEER_DNS=no" ;;
- nontp) args="${args} --env PEER_NTP=no" ;;
- nogateway) args="${args} --env PEER_ROUTERS=no" ;;
+ nodns) args="${args} --env PEER_DNS=no";;
+ nontp) args="${args} --env PEER_NTP=no";;
+ nogateway) args="${args} --env PEER_ROUTERS=no";;
nosendhost) sendhost=false;
esac
done
@@ -58,27 +58,27 @@ udhcpc_start() {
# Try and load the cache if it exists
if [ -f "${cachefile}" ]; then
case "$ {args} " in
- *" --request="*|*" -r "*) ;;
+ *" --request="*|*" -r "*);;
*)
local x=$(cat "${cachefile}")
# Check for a valid ip
case "${x}" in
- *.*.*.*) args="${args} --request=${x}" ;;
+ *.*.*.*) args="${args} --request=${x}";;
esac
;;
esac
fi
case " ${args} " in
- *" --quit "*|*" -q "*) x="/sbin/udhcpc" ;;
+ *" --quit "*|*" -q "*) x="/sbin/udhcpc";;
*) x="start-stop-daemon --start --exec /sbin/udhcpc \
- --pidfile \"${pidfile}\" --" ;;
+ --pidfile \"${pidfile}\" --";;
esac
case " ${args} " in
- *" --hosname="*|*" -h "*|*" -H "*) ;;
+ *" --hosname="*|*" -h "*|*" -H "*);;
*)
- if ${sendhost} ; then
+ if ${sendhost}; then
local hname="$(hostname)"
if [ "${hname}" != "(none)" ] && [ "${hname}" != "localhost" ]; then
args="${args} --hostname='${hname}'"
@@ -112,7 +112,7 @@ udhcpc_stop() {
*" release "*)
start-stop-daemon --stop --quiet --oknodo --signal USR2 \
--exec /sbin/udhcpc --pidfile "${pidfile}"
- if [ -f /var/cache/udhcpc-"${IFACE}".lease ] ; then
+ if [ -f /var/cache/udhcpc-"${IFACE}".lease ]; then
rm -f /var/cache/udhcpc-"${IFACE}".lease
fi
;;
diff --git a/net.Linux/vlan.sh b/net.Linux/vlan.sh
index 2410b950..28bd1974 100644
--- a/net.Linux/vlan.sh
+++ b/net.Linux/vlan.sh
@@ -43,9 +43,9 @@ _get_vlans() {
}
_check_vlan() {
- if [ ! -d /proc/net/vlan ] ; then
+ if [ ! -d /proc/net/vlan ]; then
modprobe 8021q
- if [ ! -d /proc/net/vlan ] ; then
+ if [ ! -d /proc/net/vlan ]; then
eerror "VLAN (802.1q) support is not present in this kernel"
return 1
fi
@@ -64,13 +64,13 @@ vlan_pre_start() {
for v in ${vc}; do
unset IFS
case "${v}" in
- set_name_type" "*) x=${v} ;;
+ set_name_type" "*) x=${v};;
*)
set -- ${v}
x="$1 ${IFACE}"
shift
x="${x} $@"
- ;;
+ ;;
esac
e="$(vconfig ${x} 2>&1 1>/dev/null)"
@@ -92,7 +92,7 @@ vlan_post_start() {
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
+ if [ -n "${e}" ]; then
eend 1 "${e}"
continue
fi