summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-02-14 12:33:22 +0000
committerChristian Heim <phreak@gentoo.org>2006-02-14 12:33:22 +0000
commit0cf90cef0affacabbdddcab7ff6623fca21e8c8b (patch)
treeba719e4bc8320f8bfadafd1824282fea2f2a2cd8
parentFix wording (this ain't the rc-scripts branch) (diff)
downloadbaselayout-vserver-0cf90cef0affacabbdddcab7ff6623fca21e8c8b.tar.gz
baselayout-vserver-0cf90cef0affacabbdddcab7ff6623fca21e8c8b.tar.bz2
baselayout-vserver-0cf90cef0affacabbdddcab7ff6623fca21e8c8b.zip
Merging r1881
svn path=/baselayout-vserver/branches/baselayout-1_12/; revision=234
-rw-r--r--ChangeLog27
-rw-r--r--ChangeLog.vserver28
-rw-r--r--etc/group4
-rw-r--r--etc/passwd3
-rw-r--r--etc/shadow2
-rw-r--r--net-scripts/conf.d/net.example25
-rwxr-xr-xnet-scripts/init.d/net.lo124
-rw-r--r--net-scripts/net.modules.d/bonding3
-rw-r--r--net-scripts/net.modules.d/bridge3
-rw-r--r--net-scripts/net.modules.d/dhcpcd10
-rw-r--r--net-scripts/net.modules.d/essidnet2
-rw-r--r--net-scripts/net.modules.d/ifconfig4
-rw-r--r--net-scripts/net.modules.d/ip6to490
-rw-r--r--net-scripts/net.modules.d/iproute2156
-rw-r--r--net-scripts/net.modules.d/iptunnel4
-rw-r--r--net-scripts/net.modules.d/iwconfig89
-rw-r--r--net-scripts/net.modules.d/macnet2
-rw-r--r--net-scripts/net.modules.d/pppd64
-rw-r--r--net-scripts/net.modules.d/tuntap3
-rw-r--r--net-scripts/net.modules.d/wpa_supplicant51
-rwxr-xr-xsbin/rc-services.sh6
-rwxr-xr-xsbin/runscript.sh6
22 files changed, 450 insertions, 256 deletions
diff --git a/ChangeLog b/ChangeLog
index 9552932..522d6cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,33 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 08 Feb 2006; Roy Marples <uberlord@gentoo.org>:
+
+ New module ip6to4 that creates tunnels with IPv6 addresses based off
+ global IPv4 addresses on a specified interface, #122015.
+ Thanks to Antti Mäkelä for testing and ideas.
+
+ 07 Feb 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Always ensure the end_service is called, #119233 again.
+
+ You can now specify a maxfail value for pppd (default 0), #115346.
+
+ net.lo now depends on isapnp to work with older NICs, #121539.
+
+ chat commands in pppd are now re-quoted, #121665.
+
+ ip routing policies are now supports via the rule_eth0=( ... )
+ variable (only supported by iproute2), #107628.
+
+ wpa_supplicant now looks for config files in order
+ /etc/wpa_supplicant/wpa_supplicant-$iface.conf
+ /etc/wpa_supplicant/wpa_supplicant.conf
+ /etc/wpa_supplicant.conf
+ and for these wpa_cli scripts
+ /etc/wpa_supplicant/wpa_cli.sh
+ /sbin/wpa_cli.action
+
25 Jan 2006; Roy Marples <uberlord@gentoo.org>:
New variable RC_ULIMIT applies ulimit commands before starting a service.
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index d6ef7a1..f86fe7c 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,34 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 14 Feb 2006; Christian Heim <phreak@gentoo.org>:
+ Merging latest changes to the baselayout-1_12 branch. This merge is based
+ upon revision 1881.
+
+ ChangeLog | 27 +++
+ ChangeLog.vserver | 28 +++
+ etc/group | 4
+ etc/passwd | 3
+ etc/shadow | 2
+ net-scripts/conf.d/net.example | 25 ++
+ net-scripts/init.d/net.lo | 124 +++++++-------
+ net-scripts/net.modules.d/bonding | 3
+ net-scripts/net.modules.d/bridge | 3
+ net-scripts/net.modules.d/dhcpcd | 10 -
+ net-scripts/net.modules.d/essidnet | 2
+ net-scripts/net.modules.d/ifconfig | 4
+ net-scripts/net.modules.d/ip6to4 | 90 ++++++++++
+ net-scripts/net.modules.d/iproute2 | 152 +++++++++++-------
+ net-scripts/net.modules.d/iptunnel | 4
+ net-scripts/net.modules.d/iwconfig | 89 +++++-----
+ net-scripts/net.modules.d/macnet | 2
+ net-scripts/net.modules.d/pppd | 64 +++----
+ net-scripts/net.modules.d/tuntap | 3
+ net-scripts/net.modules.d/wpa_supplicant | 51 +++---
+ sbin/rc-services.sh | 6
+ sbin/runscript.sh | 6
+ 22 files changed, 448 insertions(+), 254 deletions(-)
+
06 Feb 2006; Christian Heim <phreak@gentoo.org>:
Merging latest changes to the baselayout-1_12 branch. This merge is based
upon revision 1851.
diff --git a/etc/group b/etc/group
index f954ac7..3823306 100644
--- a/etc/group
+++ b/etc/group
@@ -19,14 +19,10 @@ cdrom::19:
dialout::20:root
tape::26:root
video::27:root
-postgres::70:
cdrw::80:
-nut::84:
usb::85:
users::100:games
nofiles:x:200:
-postfix:x:207:
-postdrop:x:208:
smmsp:x:209:smmsp
portage::250:portage
utmp:x:406:
diff --git a/etc/passwd b/etc/passwd
index 10496a0..1505cb6 100644
--- a/etc/passwd
+++ b/etc/passwd
@@ -11,9 +11,6 @@ news:x:9:13:news:/usr/lib/news:/bin/false
uucp:x:10:14:uucp:/var/spool/uucppublic:/bin/false
operator:x:11:0:operator:/root:/bin/bash
postmaster:x:14:12:postmaster:/var/spool/mail:/bin/false
-postgres:x:70:70::/var/lib/postgresql:/bin/bash
-nut:x:84:84:nut:/var/state/nut:/bin/false
-postfix:x:207:207:postfix:/var/spool/postfix:/bin/false
smmsp:x:209:209:smmsp:/var/spool/mqueue:/bin/false
portage:x:250:250:portage:/var/tmp/portage:/bin/false
nobody:x:65534:65534:nobody:/:/bin/false
diff --git a/etc/shadow b/etc/shadow
index 03ecc34..99d5ecc 100644
--- a/etc/shadow
+++ b/etc/shadow
@@ -4,7 +4,6 @@ operator:*:9797:0:::::
shutdown:*:9797:0:::::
sync:*:9797:0:::::
bin:*:9797:0:::::
-ftp:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
@@ -12,7 +11,6 @@ mail:*:9797:0:::::
postmaster:*:9797:0:::::
news:*:9797:0:::::
uucp:*:9797:0:::::
-man:*:9797:0:::::
games:*:9797:0:::::
guest:*:9797:0:::::
nobody:*:9797:0:::::
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index ebf1236..d637731 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -119,6 +119,13 @@
# "::/0" # IPv6 unicast
#)
+# If you're using iproute2 then you can also do policy routing.
+# This is not available with ifconfig.
+#rules_eth0=(
+# "from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100"
+# "from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100"
+#)
+
# If a specified module fails (like dhcp - see below), you can specify a
# fallback like so
#fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" )
@@ -396,6 +403,8 @@
#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
# "debug" # Enables syslog debugging
# "noauth" # Do not require the peer to authenticate itself
# "defaultroute" # Make this PPP interface the default route
@@ -546,6 +555,9 @@
#-----------------------------------------------------------------------------
# Tunnelling
+# WARNING: For tunnelling it is highly recommended that you
+# emerge sys-apps/iproute2
+#
# For GRE tunnels
#iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255"
@@ -556,6 +568,19 @@
#config_vpn0=( "192.168.0.2 pointopoint 192.168.1.2" ) # ifconfig style
#config_vpn0=( "192.168.0.2 peer 192.168.1.1" ) # iproute2 style
+# 6to4 Tunnels allow IPv6 to work over IPv4 addresses, provided you
+# have a non-private address configured on an interface.
+# link_6to4="eth0" # Interface to base it's addresses on
+# config_6to4=( "ip6to4" )
+# You may want to depend on eth0 like so
+# depend_6to4() {
+# need net.eth0
+# }
+# To ensure that eth0 is configured before 6to4. Of course, the tunnel could be
+# any name and this also works for any configured interface.
+# NOTE: If you're not using iproute2 then your 6to4 tunnel has to be called
+# sit0 - otherwise use a different name like 6to4 in the example above.
+
#-----------------------------------------------------------------------------
# System
# For configuring system specifics such as domain, dns, ntp and nis servers
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index 43bfd46..53a51c9 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -12,7 +12,7 @@
# runlevel as the net.* script that needs it.
depend() {
need localmount
- use pcmcia usb isdn wlan
+ use isapnp isdn pcmcia usb wlan
# Load any custom depend functions for the given interface
# For example, br0 may need eth0 and eth1
@@ -60,7 +60,7 @@ variables() {
module_load_minimum() {
local f="$1" MODULE="${1##*/}"
- if [[ ! -f ${f} ]]; then
+ if [[ ! -f ${f} ]] ; then
eerror "${f} does not exist"
return 1
fi
@@ -103,7 +103,7 @@ modules_load_auto() {
j="${#MODULES[@]}"
loaded_interface=false
for (( i=0; i<j; i++ )); do
- if [[ ${MODULES[i]##*/} == "interface" ]]; then
+ if [[ ${MODULES[i]##*/} == "interface" ]] ; then
eerror "interface is a reserved name - cannot load a module called interface"
return 1
fi
@@ -111,7 +111,7 @@ modules_load_auto() {
(
u=0;
module_load_minimum "${MODULES[i]}" || u=1;
- if [[ ${u} == 0 ]]; then
+ if [[ ${u} == 0 ]] ; then
inst="${MODULES[i]##*/}_check_installed";
if is_function "${inst}" ; then
${inst} false || u=1;
@@ -120,7 +120,7 @@ modules_load_auto() {
exit "${u}";
)
- if [[ $? == 0 ]]; then
+ if [[ $? == 0 ]] ; then
source "${MODULES[i]}"
MODULES[i]="${MODULES[i]##*/}"
else
@@ -188,11 +188,11 @@ modules_check_user() {
[[ ${umods[i]} == "dhcp" ]] && continue
# We remove any modules we explicitly don't want
- if [[ ${umods[i]} == "!"* ]]; then
+ if [[ ${umods[i]} == "!"* ]] ; then
for (( j=0; j<nmods; j++ )); do
[[ -z ${MODULES[j]} ]] && continue
if [[ ${umods[i]:1} == "${MODULES[j]}" \
- || ${umods[i]:1} == "${PROVIDES[j]}" ]]; then
+ || ${umods[i]:1} == "${PROVIDES[j]}" ]] ; then
# We may need to setup a class wrapper for it even though
# we don't use it directly
# However, we put it into an array and wrap later as
@@ -217,7 +217,7 @@ modules_check_user() {
# The function may not exist because the modules software is
# not installed. Load the module and report its error
- if [[ -e "${MODULES_DIR}/${umods[i]}" ]]; then
+ if [[ -e "${MODULES_DIR}/${umods[i]}" ]] ; then
source "${MODULES_DIR}/${umods[i]}"
is_function "${umods[i]}_check_installed" \
&& ${umods[i]}_check_installed true
@@ -228,18 +228,18 @@ modules_check_user() {
fi
if is_function "${umods[i]}_provide" ; then
- mod=$( ${umods[i]}_provide )
+ mod="$(${umods[i]}_provide )"
else
mod="${umods[i]}"
fi
for (( j=0; j<nmods; j++ )); do
[[ -z ${MODULES[j]} ]] && continue
- if [[ ${PROVIDES[j]} == "${mod}" && ${umods[i]} != "${MODULES[j]}" ]]; then
+ if [[ ${PROVIDES[j]} == "${mod}" && ${umods[i]} != "${MODULES[j]}" ]] ; then
# We don't have a match - now ensure that we still provide an
# alternative. This is to handle our preferred modules.
for (( l=0; l<nmods; l++ )); do
[[ ${l} == "${j}" || -z ${MODULES[l]} ]] && continue
- if [[ ${PROVIDES[l]} == "${mod}" ]]; then
+ if [[ ${PROVIDES[l]} == "${mod}" ]] ; then
unset MODULES[j]
unset PROVIDES[j]
break
@@ -280,7 +280,7 @@ modules_sort() {
if [[ ${MODULES[i]} != "${PROVIDES[i]}" ]] ; then
local provided=false
for ((j=0; j<${#provide[@]}; j++)); do
- if [[ ${provide[j]} == "${PROVIDES[i]}" ]]; then
+ if [[ ${provide[j]} == "${PROVIDES[i]}" ]] ; then
provide_list[j]="${provide_list[j]} ${MODULES[i]}"
provided=true
fi
@@ -301,7 +301,7 @@ modules_sort() {
if is_function "${MODULES[i]}_before" ; then
for m in $(${MODULES[i]}_before); do
for ((j=0; j<nmods; j++)) ; do
- if [[ ${PROVIDES[j]} == "${m}" ]]; then
+ if [[ ${PROVIDES[j]} == "${m}" ]] ; then
after[j]=" ${after[j]} ${MODULES[i]} "
break
fi
@@ -312,7 +312,7 @@ modules_sort() {
# Replace the after list modules with real modules
for ((i=0; i<nmods; i++)); do
- if [[ -n ${after[i]} ]]; then
+ if [[ -n ${after[i]} ]] ; then
for ((j=0; j<${#provide[@]}; j++)); do
after[i]="${after[i]// ${provide[j]} / ${provide_list[j]} }"
done
@@ -357,7 +357,7 @@ modules_check_depends() {
missingdeps=true
for (( j=0; j<nmods; j++ )); do
if [[ ${needmod} == "${MODULES[j]}" \
- || ${needmod} == "${PROVIDES[j]}" ]]; then
+ || ${needmod} == "${PROVIDES[j]}" ]] ; then
missingdeps=false
break
fi
@@ -404,10 +404,10 @@ modules_load() {
local RC_INDENTATION="${RC_INDENTATION}"
local -a PROVIDES WRAP_MODULES
- if [[ ${iface} != "lo" ]]; then
+ if [[ ${iface} != "lo" ]] ; then
x="modules_force_${iface}[@]"
[[ -n ${!x} ]] && modules_force=( "${!x}" )
- if [[ -n ${modules_force} ]]; then
+ if [[ -n ${modules_force} ]] ; then
ewarn "WARNING: You are forcing modules!"
ewarn "Do not complain or file bugs if things start breaking"
report=true
@@ -417,7 +417,7 @@ modules_load() {
veinfo "Loading networking modules for ${iface}"
eindent
- if [[ -z ${modules_force} ]]; then
+ if [[ -z ${modules_force} ]] ; then
modules_load_auto || return 1
else
j="${#modules_force[@]}"
@@ -439,19 +439,19 @@ 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
done
- if [[ -n ${modules_force[@]} ]]; then
+ if [[ -n ${modules_force[@]} ]] ; then
# Strip any duplicate modules providing the same thing
j="${#MODULES[@]}"
for (( i=0; i<j-1; i++ )); do
[[ -z ${MODULES[i]} ]] && continue
for (( k=i+1; k<j; k++ )); do
- if [[ ${PROVIDES[i]} == ${PROVIDES[k]} ]]; then
+ if [[ ${PROVIDES[i]} == ${PROVIDES[k]} ]] ; then
unset MODULES[k]
unset PROVIDES[k]
fi
@@ -465,7 +465,7 @@ modules_load() {
else
# Always prefer iproute2 for taking down interfaces
if is_function iproute2_provide ; then
- function_wrap iproute2 $(iproute2_provide)
+ function_wrap iproute2 "$(iproute2_provide)"
fi
fi
fi
@@ -480,7 +480,7 @@ modules_load() {
function_wrap ${WRAP_MODULES[i]}
done
- if [[ -z ${modules_force[@]} ]]; then
+ if [[ -z ${modules_force[@]} ]] ; then
modules_check_installed || return 1
modules_sort || return 1
fi
@@ -507,9 +507,9 @@ iface_start() {
# Try and work out a metric for the interface if we're on auto
x="metric_${ifvar}"
- if [[ -z ${!x} ]]; then
- if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
- eval "metric_${ifvar}=\""$( calculate_metric ${iface} )"\""
+ if [[ -z ${!x} ]] ; then
+ if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
+ eval "metric_${ifvar}=\"$(calculate_metric ${iface})\""
else
eval "metric_${ifvar}=0"
fi
@@ -528,14 +528,14 @@ iface_start() {
a="config_${ifvar}[@]"
a=( "${!a}" )
for (( i=0; i<${#a[@]}; i++ )); do
- eval b=( $( expand_parameters "${a[i]}" ) )
+ eval b=( $(expand_parameters "${a[i]}") )
config=( "${config[@]}" "${b[@]}" )
done
a="fallback_${ifvar}[@]"
a=( "${!a}" )
for (( i=0; i<${#a[@]}; i++ )); do
- eval b=( $( expand_parameters "${a[i]}" ) )
+ eval b=( $(expand_parameters "${a[i]}") )
fallback=( "${fallback[@]}" "${b[@]}" )
done
@@ -544,16 +544,16 @@ iface_start() {
fallback_route=( "${!fallback_route}" )
# We must support old configs
- if [[ -z ${config} ]]; then
+ if [[ -z ${config} ]] ; then
interface_get_old_config "${iface}" || return 1
- if [[ -n ${config} ]]; then
+ if [[ -n ${config} ]] ; then
ewarn "You are using a depreciated configuration syntax for ${iface}"
ewarn "You are advised to read /etc/conf.d/net.example and upgrade it accordingly"
fi
fi
# Handle "noop" correctly
- if [[ ${config[0]} == "noop" ]]; then
+ if [[ ${config[0]} == "noop" ]] ; then
if interface_is_up "${iface}" true ; then
einfo "Keeping current configuration for ${iface}"
eend 0
@@ -566,8 +566,8 @@ iface_start() {
# Provide a default of DHCP if no configuration is set and we're auto
# Otherwise a default of NULL
- if [[ -z ${config} ]]; then
-# if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
+ if [[ -z ${config} ]] ; then
+# if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
ewarn "Configuration not set for ${iface} - assuming DHCP"
if is_function "dhcp_start" ; then
config=( "dhcp" )
@@ -586,7 +586,7 @@ iface_start() {
for (( config_counter=0; config_counter<${#config[@]}; config_counter++ )); do
# Handle null and noop correctly
if [[ ${config[config_counter]} == "null" \
- || ${config[config_counter]} == "noop" ]]; then
+ || ${config[config_counter]} == "noop" ]] ; then
eend 0
config_worked=true
continue
@@ -605,7 +605,7 @@ iface_start() {
[[ ${x} == 0 ]] && config_worked=true && continue
# We need to test to see if it's an IP address or a function
# We do this by testing if the 1st character is a digit
- elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]]; then
+ elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]] ; then
x="0"
if [[ ${RC_AUTO_INTERFACE} == "yes" ]] \
&& is_function arping_address_exists ; then
@@ -624,13 +624,13 @@ iface_start() {
fi
fi
- if [[ -n ${fallback[config_counter]} ]]; then
+ if [[ -n ${fallback[config_counter]} ]] ; then
einfo "Trying fallback configuration"
config[config_counter]="${fallback[config_counter]}"
fallback[config_counter]=""
# Do we have a fallback route?
- if [[ -n ${fallback_route[config_counter]} ]]; then
+ if [[ -n ${fallback_route[config_counter]} ]] ; then
x="fallback_route[config_counter]"
eval "routes_${ifvar}=( \"\${!x}\" )"
fallback_route[config_counter]=""
@@ -676,7 +676,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.
@@ -700,7 +700,7 @@ iface_stop() {
# Do final shut down of this alias
if [[ ${IN_BACKGROUND} != "true" \
- && ${RC_DOWN_INTERFACE} == "yes" ]]; then
+ && ${RC_DOWN_INTERFACE} == "yes" ]] ; then
ebegin "Shutting down ${i}"
interface_iface_stop "${i}"
eend "$?"
@@ -724,12 +724,12 @@ 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
# However, no extra modules are loaded as they are just not needed
- if [[ ${iface} == "lo" ]]; then
+ if [[ ${iface} == "lo" ]] ; then
metric_lo="0"
config_lo=( "127.0.0.1/8 brd 127.255.255.255" "${config_lo[@]}" )
routes_lo=( "127.0.0.0/8" "${routes_lo[@]}" )
@@ -772,13 +772,13 @@ run_start() {
# There may be existing ip address info - so we strip it
if [[ ${RC_INTERFACE_KEEP_CONFIG} != "yes" \
- && ${IN_BACKGROUND} != "true" ]]; then
+ && ${IN_BACKGROUND} != "true" ]] ; then
interface_del_addresses "${iface}"
fi
# Start the interface
if ! iface_start "${iface}" ; then
- if [[ ${IN_BACKGROUND} != "true" ]]; then
+ if [[ ${IN_BACKGROUND} != "true" ]] ; then
interface_exists "${iface}" && interface_down "${iface}"
fi
eend 1
@@ -806,12 +806,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
@@ -855,7 +855,7 @@ run() {
local -a MODULES mods
local IN_BACKGROUND="${IN_BACKGROUND}"
- if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]]; then
+ if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]] ; then
IN_BACKGROUND=true
else
IN_BACKGROUND=false
@@ -872,7 +872,7 @@ run() {
[[ ${iface} == "lo" ]] && modules_force=( "iproute2" "ifconfig" "system" )
if modules_load "${iface}" "${starting}" ; then
- if [[ ${cmd} == "stop" ]]; then
+ if [[ ${cmd} == "stop" ]] ; then
# Reverse the module list for stopping
mods=( "${MODULES[@]}" )
for ((i = 0; i < ${#mods[@]}; i++)); do
@@ -895,19 +895,19 @@ run() {
fi
# Only apply best state if we're on auto
- if [[ ${r} == "0" ]]; then
+ if [[ ${r} == "0" ]] ; then
local siface=""
- if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
- siface=$( select_best_interface )
- if [[ -n ${siface} ]]; then
+ if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
+ siface="$(select_best_interface)"
+ if [[ -n ${siface} ]] ; then
einfo "Selecting best interface: ${siface}"
fi
- elif [[ ${cmd} == "start" ]]; then
+ elif [[ ${cmd} == "start" ]] ; then
siface="${iface}"
fi
[[ -n ${siface} ]] && apply_state "${siface}"
else
- if [[ ${cmd} == "start" ]]; then
+ if [[ ${cmd} == "start" ]] ; then
# Call user-defined failup if it exists
if is_function failup ; then
einfo "Running failup function"
@@ -938,9 +938,9 @@ run() {
# and allow /etc to become read only.
link_file() {
local file="$1"
- local link=$( readlink "/etc/${file}" 2>/dev/null )
- if [[ ${link} != "${netdir}/${file}" ]]; then
- if [[ -f "/etc/${file}" ]]; then
+ local link="$(readlink "/etc/${file}" 2>/dev/null)"
+ if [[ ${link} != "${netdir}/${file}" ]] ; then
+ if [[ -f "/etc/${file}" ]] ; then
vewarn "Moving /etc/${file} to ${netdir}/${file} and creating link"
mv "/etc/${file}" "${netdir}"
ln -snf "${netdir}/${file}" "/etc/${file}"
@@ -953,12 +953,12 @@ link_file() {
# Start entry point so that we only have one function
# which localises variables and unsets functions
start() {
- if [[ ${IN_HOTPLUG} == "1" ]]; then
+ if [[ ${IN_HOTPLUG} == "1" ]] ; then
# If we've been called by hotplug, check if we have
# a policy for the interface for not starting
- local x ifvar=$( bash_variable "${IFACE}" )
+ local x ifvar="$(bash_variable "${IFACE}")"
x="hotplug_${ifvar}"
- if [[ ${!x} == "no" || ${!x} == "false" ]]; then
+ if [[ ${!x} == "no" || ${!x} == "false" ]] ; then
eerror "Not starting interface ${IFACE} due to hotplug policy"
unset -f exit
mark_service_stopped "net.${IFACE}"
@@ -966,14 +966,14 @@ start() {
fi
fi
- if [[ ! -d "${statedir}/${IFACE}" ]]; then
+ if [[ ! -d "${statedir}/${IFACE}" ]] ; then
if ! mkdir -m 0755 -p "${statedir}/${IFACE}" ; then
eerror "Unable to create state directory!"
return 1
fi
fi
- if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
+ if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
link_file "resolv.conf"
link_file "ntp.conf"
link_file "yp.conf"
diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding
index 62431aa..100ca28 100644
--- a/net-scripts/net.modules.d/bonding
+++ b/net-scripts/net.modules.d/bonding
@@ -8,8 +8,7 @@
#
# Sets up the dependancies for the module
bonding_depend() {
- after interface macnet
- before vlan dhcp bridge
+ before interface macchanger
functions interface_exists interface_up interface_down \
interface_del_addresses
variables slaves
diff --git a/net-scripts/net.modules.d/bridge b/net-scripts/net.modules.d/bridge
index 23a0be1..747dd1f 100644
--- a/net-scripts/net.modules.d/bridge
+++ b/net-scripts/net.modules.d/bridge
@@ -13,8 +13,7 @@ brctl() {
#
# Sets up the dependancies for the module
bridge_depend() {
- after interface macnet tuntap
- before dhcp
+ before interface macnet
functions interface_down interface_del_addresses interface_set_flag
variables bridge bridge_add brctl
}
diff --git a/net-scripts/net.modules.d/dhcpcd b/net-scripts/net.modules.d/dhcpcd
index ab8f9dc..c467f2a 100644
--- a/net-scripts/net.modules.d/dhcpcd
+++ b/net-scripts/net.modules.d/dhcpcd
@@ -28,7 +28,7 @@ dhcpcd_check_installed() {
if dhcpcd -h 2>&1 | grep -q "etcDir" ; then
return 0
else
- ${1:-false} && eerror "We require dhcpcd-1.3.22_p4-r12 or newer"
+ ${1:-false} && eerror "We require dhcpcd-2.0.0 or newer"
return 1
fi
fi
@@ -37,14 +37,6 @@ dhcpcd_check_installed() {
return 1
}
-# char* dhcpcd_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-dhcpcd_get_vars() {
- echo "dhcpcd_$1 dhcp_$1"
-}
-
# bool dhcpcd_stop(char *iface)
#
# Stop DHCP on an interface by calling dhcpcd -z $iface
diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet
index f2bd823..eb114ea 100644
--- a/net-scripts/net.modules.d/essidnet
+++ b/net-scripts/net.modules.d/essidnet
@@ -22,7 +22,7 @@ essidnet_depend() {
# bool essidnet_start(char *iface)
#
-# All interfaces and module scripts expose modulename_get_vars
+# All interfaces and module scripts can depend on the variables function
# which returns a space seperated list of user configuration variables
# We can override each variable here from a given ESSID or the MAC
# of the AP connected to. MAC configuration takes precedence
diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig
index eacbd57..3e3e5b9 100644
--- a/net-scripts/net.modules.d/ifconfig
+++ b/net-scripts/net.modules.d/ifconfig
@@ -391,7 +391,7 @@ ifconfig_add_address() {
local metric ifvar=$(bash_variable "${real_iface}")
# Remove the newly added route and replace with our metric
metric="metric_${ifvar}"
- [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r}
+ [[ ${!metric:-0} == "0" ]] && return ${r}
if [[ -z ${netmask} ]]; then
for (( i=1; i<${#config[@]}-1; i++ )); do
@@ -408,7 +408,7 @@ ifconfig_add_address() {
if route del -net "${network}/${cidr}" metric 0 dev "${iface}" \
2>/dev/null ; then
- route add -net "${network}/${cidr}" metric "${!metric}" dev "${iface}"
+ route add -net "${network}/${cidr}" metric "${!metric:-0}" dev "${iface}"
fi
return ${r}
diff --git a/net-scripts/net.modules.d/ip6to4 b/net-scripts/net.modules.d/ip6to4
new file mode 100644
index 0000000..a833609
--- /dev/null
+++ b/net-scripts/net.modules.d/ip6to4
@@ -0,0 +1,90 @@
+#!/bin/bash
+# Copyright (c) 2004-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# Contributed by Roy Marples (uberlord@gentoo.org)
+
+# void ip6to4_depend(void)
+#
+# Sets up the dependancies for the module
+ip6to4_depend() {
+ after interface
+ functions interface_exists interface_get_address interface_tunnel
+ variables link
+}
+
+# bool ip6to4_start(char *interface)
+#
+# Configures IPv6 addresses to be added to the tunnel based on a IPv4
+# addresses on a pre-configured interface.
+# Returns 0 on success, otherwise 1.
+ip6to4_start() {
+ local iface="$1" addr=""
+ local ifvar="$(bash_variable "${iface}")"
+
+ # Ensure the interface is sit0 if we're using ifconfig
+ if [[ " ${MODULES[@]} " == *" ifconfig "* && ${iface} != "sit0" ]] ; then
+ eerror "ip6to4 can only on interface sit0 using ifconfig"
+ eerror "emerge sys-apps/iproute2 to use other interfaces"
+ return 1
+ fi
+
+ local host="link_${ifvar}"
+ if [[ -z ${!host} ]] ; then
+ eerror "link_${ifvar} is not set"
+ return 1
+ fi
+
+ interface_exists "${!host}" true || return 1
+
+ # An interface can have more than 1 ip address
+ local -a addrs=( $(interface_get_address "${!host}") )
+ if [[ -z ${addrs} ]] ; then
+ eerror "${!host} is not configured with an IPv4 address"
+ return 1
+ fi
+
+ local -a new=()
+ local addr=""
+ for addr in "${addrs[@]}" ; do
+ # Strip the subnet
+ local ip="${addr%/*}" subnet="${addr#*/}"
+ # We don't work on private IPv4 addresses
+ [[ ${ip} == "127."* ]] && continue
+ [[ ${ip} == "10."* ]] && continue
+ [[ ${ip} == "192.168."* ]] && continue
+ 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//./ })"
+ veinfo "Derived IPv6 address: ${ip6}"
+
+ # Now apply our IPv6 address to our config
+ new=( "${new[@]}" "${ip6}/16" )
+ done
+
+ if [[ -z ${new} ]] ; then
+ eerror "No global IPv4 addresses found on interface ${!host}"
+ return 1
+ fi
+
+ if [[ ${iface} != "sit0" ]] ; then
+ ebegin "Creating 6to4 tunnel on ${iface}"
+ interface_tunnel add "${iface}" mode sit ttl 255 remote any local "${ip}"
+ eend $? || return 1
+ fi
+
+ # Now apply our config
+ config=( "${config[@]}" "${new[@]}" )
+
+ # Add a route for us, ensuring we don't delete anything else
+ local routes="routes_${ifvar}[@]"
+ eval "routes_${ifvar}=( \"\${!routes}\" \
+ \"2003::/3 via ::192.88.99.1 metric 2147483647\" )"
+}
+
+# vim:ts=4
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2
index 09fcfa5..2052998 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2
@@ -28,11 +28,11 @@ iproute2_depend() {
# Returns 1 if iproute2 is installed, otherwise 0
iproute2_check_installed() {
local report="${1:-false}" installed="0"
- if [[ ! -x /sbin/ip ]]; then
+ if [[ ! -x /sbin/ip ]] ; then
installed="1"
${report} && eerror "For iproute2 support, emerge sys-apps/iproute2"
fi
- if [[ ! -e /proc/net/netlink ]]; then
+ if [[ ! -e /proc/net/netlink ]] ; then
installed="1"
${report} && eerror "iproute2 requires NetLink enabled in the kernel"
fi
@@ -43,7 +43,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
@@ -93,8 +93,7 @@ iproute2_set_flag() {
# Fetch the address retrieved by DHCP. If successful, echoes the
# address on stdout, otherwise echoes nothing.
iproute2_get_address() {
- ip -family inet addr show "$1" \
- | sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
+ ip -family inet addr show "$1" | sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
}
# bool iproute2_is_ethernet(char *interface)
@@ -108,8 +107,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' ]] \
@@ -137,7 +136,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
}
@@ -158,7 +157,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}[@]"
@@ -190,10 +189,10 @@ 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
+ if [[ ${label} == "${iface}" ]] ; then
iproute2_down "${iface}"
return $?
fi
@@ -205,7 +204,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
@@ -218,7 +217,7 @@ iproute2_add_address() {
for (( x=0; x<n; x++ )); do
case "${config[x]}" in
netmask)
- config[0]="${config[0]}/$( netmask2cidr ${config[x+1]} )"
+ config[0]="${config[0]}/$( netmask2cidr "${config[x+1]}" )"
unset config[x] config[x+1]
;;
mtu)
@@ -231,10 +230,10 @@ iproute2_add_address() {
# Always scope lo addresses as host unless specified otherwise
[[ ${iface} == "lo" && " ${config[@]} " != *" scope "* ]] \
- && config=( "${config[@]}" "scope host" )
+ && config=( "${config[@]}" "scope host" )
# IPv4 specifics
- if [[ ${config[@]} == *.*.*.* ]]; then
+ if [[ ${config[@]} == *.*.*.* ]] ; then
# Work out a broadcast if none supplied
[[ ${config[@]} != *" brd "* && ${config[@]} != *" broadcast "* ]] \
&& config=( "${config[@]}" "brd +" )
@@ -245,7 +244,7 @@ iproute2_add_address() {
# Some kernels like to apply lo with an address when they are brought up
if [[ ${iface} == "lo" \
- && ${config[@]} == "127.0.0.1/8 brd 127.255.255.255 scope host" ]]; then
+ && ${config[@]} == "127.0.0.1/8 brd 127.255.255.255 scope host" ]] ; then
ip addr del dev "${iface}" 127.0.0.1/8 2>/dev/null
fi
@@ -253,18 +252,18 @@ iproute2_add_address() {
local r="$?"
[[ ${r} != "0" ]] && return "${r}"
- local metric ifvar=$( bash_variable "${iface}" )
+ local ifvar="$( bash_variable "${iface}" )"
# Remove the newly added route and replace with our metric
- metric="metric_${ifvar}"
- [[ ${!metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return "${r}"
+ local metric="metric_${ifvar}"
+ [[ ${!metric:-0} == "0" ]] && return "${r}"
- local network=$( ip_network "${config[0]}" )
+ local network="$( ip_network "${config[0]}" )"
[[ -z ${network} ]] && return "${r}"
local cidr="${config[0]##*/}"
if ip route del "${network}/${cidr}" metric 0 dev "${iface}" \
2>/dev/null ; then
- ip route add "${network}/${cidr}" metric "${!metric}" dev "${iface}"
+ ip route add "${network}/${cidr}" metric "${!metric:-0}" dev "${iface}"
fi
return "${r}"
@@ -280,10 +279,10 @@ iproute2_pre_start() {
interface_exists "${iface}" || return 0
- local ifvar=$( bash_variable "$1" ) mtu
+ local ifvar="$( bash_variable "$1" )"
# MTU support
- mtu="mtu_${ifvar}"
+ local mtu="mtu_${ifvar}"
[[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}"
return 0
@@ -294,7 +293,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" ) routes metric mtu x netmask
+ local iface="$1" ifvar="$( bash_variable "$1" )" x=""
iproute2_exists "${iface}" || return 0
@@ -302,50 +301,73 @@ iproute2_post_start() {
iproute2_up "${iface}"
# MTU support
- mtu="mtu_${ifvar}"
+ local mtu="mtu_${ifvar}"
[[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}"
- x="routes_${ifvar}[@]"
- routes=( "${!x}" )
- metric="metric_${ifvar}"
+ local x="routes_${ifvar}[@]"
+ local -a routes=( "${!x}" )
+ local metric="metric_${ifvar}"
# Test for old style ipaddr variable
- if [[ -z ${routes} ]]; then
+ if [[ -z ${routes} ]] ; then
t="iproute_${ifvar}[@]"
routes=( "${!t}" )
fi
- [[ -z ${routes} ]] && return 0
-
# Set routes with ip route -- this might also include default route
- einfo "Adding routes"
- eindent
- for x in "${routes[@]}"; do
- ebegin "${x}"
-
- # Support net-tools routing too
- x="${x//gw/via}"
- x="${x//-A inet6/}"
- x="${x//-net/}"
- [[ " ${x} " == *" -host "* ]] && x="${x//-host/} scope host"
-
- # Attempt to support net-tools route netmask option
- netmask="${x##* netmask }"
- if [[ -n ${netmask} && ${x} != "${netmask}" ]]; then
- netmask="${netmask%% *}"
- x="${x// netmask ${netmask} / }"
- local -a a=( ${x} )
- a[0]="${a[0]}/$( netmask2cidr ${netmask} )"
- x="${a[@]}"
- fi
+ if [[ -n ${routes} ]] ; then
+ einfo "Adding routes"
+ eindent
+ for x in "${routes[@]}"; do
+ ebegin "${x}"
+
+ # Support net-tools routing too
+ x="${x//gw/via}"
+ x="${x//-A inet6/}"
+ x="${x//-net/}"
+ [[ " ${x} " == *" -host "* ]] && x="${x//-host/} scope host"
+
+ # Attempt to support net-tools route netmask option
+ netmask="${x##* netmask }"
+ if [[ -n ${netmask} && ${x} != "${netmask}" ]] ; then
+ netmask="${netmask%% *}"
+ x="${x// netmask ${netmask} / }"
+ local -a a=( ${x} )
+ a[0]="${a[0]}/$( netmask2cidr "${netmask}")"
+ x="${a[@]}"
+ fi
+
+ # Add a metric if we don't have one
+ [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}"
+
+ ip route append ${x} dev "${iface}"
+ eend $?
+ done
+ eoutdent
+ fi
- # Add a metric if we don't have one
- [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}"
+ # Now apply any rules we may want
+ x="rules_${ifvar}[@]"
+ local -a rules=( "${!x}" )
+ if [[ -n ${rules} ]] ; then
+ einfo "Adding IP policy routing rules"
+ eindent
+ # Ensure that the kernel supports policy routing
+ if ! ip rule list | grep -q "^" ; then
+ eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
+ eerror "in your kernel to use ip rules"
+ else
+ for x in "${rules[@]}" ; do
+ ebegin "${x}"
+ ip rule add ${x} dev "${iface}"
+ eend $?
+ done
+ fi
+ eoutdent
+ fi
- ip route append ${x} dev "${iface}"
- eend $?
- done
- eoutdent
+ # Flush the route cache
+ ip route flush cache dev "${iface}"
return 0
}
@@ -354,7 +376,7 @@ iproute2_post_start() {
#
# Change all routes for an interface to a given metric
iproute2_route_metric() {
- local route
+ local route=""
ip route | grep " dev $1" | {
while read route ; do
ip route del ${route}
@@ -374,4 +396,22 @@ iproute2_default_route() {
|| ip route append default via "$2" metric "${metric}" dev "$1" 2>/dev/null
}
+# void iproute2_post_stop(char* interface)
+iproute2_post_stop() {
+ local iface="$1" rule=""
+
+ iproute2_exists "${iface}" || return
+
+ # Remove any rules for this interface
+ ip rule list | grep " iif ${iface}[ ]*" | {
+ while read rule ; do
+ rule="${rule#*:}"
+ ip rule del ${rule}
+ done
+ }
+
+ # Flush the route cache
+ ip route flush cache dev "${iface}"
+}
+
# vim:ts=4
diff --git a/net-scripts/net.modules.d/iptunnel b/net-scripts/net.modules.d/iptunnel
index 73e7594..13fd824 100644
--- a/net-scripts/net.modules.d/iptunnel
+++ b/net-scripts/net.modules.d/iptunnel
@@ -8,7 +8,6 @@
#
# Sets up the dependancies for the module
iptunnel_depend() {
- after wireless
before interface
functions interface_exists interface_tunnel
variables iptunnel
@@ -35,6 +34,9 @@ iptunnel_pre_start() {
iptunnel_stop() {
local iface="$1"
+ # Don't delete sit0 as it's a special tunnel
+ [[ ${iface} == "sit0" ]] && return 0
+
interface_exists "${iface}" || return 0
[[ -z $( interface_tunnel show "${iface}" 2>/dev/null ) ]] && return 0
diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig
index 68f70b3..30e0249 100644
--- a/net-scripts/net.modules.d/iwconfig
+++ b/net-scripts/net.modules.d/iwconfig
@@ -63,12 +63,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 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
@@ -82,7 +82,7 @@ iwconfig_get_essid() {
local i essid
for (( i=0; i<5; i++ )); do
- essid="$( iwgetid $1 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )"
+ essid="$( iwgetid "$1" 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )"
if [[ -n ${essid} ]]; then
echo "${essid}"
return 0
@@ -121,18 +121,18 @@ iwconfig_get_type() {
iwconfig_report() {
local iface="$1" essid mac m="to"
- essid=$( iwconfig_get_essid "${iface}" )
+ essid="$( iwconfig_get_essid "${iface}" )"
- local wep_status=$( iwconfig_get_wep_status "${iface}" )
- local channel=$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 )
+ local wep_status="$( iwconfig_get_wep_status "${iface}" )"
+ local channel="$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 )"
[[ -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="as"
elif [[ ${mode} != "ad-hoc" ]]; then
- mac=$( iwconfig_get_ap_mac_address "${iface}" )
+ mac="$( iwconfig_get_ap_mac_address "${iface}" )"
[[ -n ${mac} ]] && mac=" at ${mac}"
fi
@@ -158,7 +158,7 @@ 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" )
+ [[ -z ${ifvar} ]] && ifvar="$( bash_variable "$1" )"
# Apply the user configuration
conf="iwconfig_${ifvar}"
@@ -189,7 +189,7 @@ 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 ifvar="$( bash_variable "$1" )"
if [[ -z ${ESSID} ]]; then
eerror "${iface} requires an ESSID to be set to operate in ${mode} mode"
@@ -197,11 +197,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}\""
@@ -218,7 +218,7 @@ iwconfig_setup_specific() {
fi
# Now set the key
- if ! eval iwconfig "${iface}" key "${key}" ; then
+ if ! iwconfig "${iface}" key ${key} ; then
if [[ ${key} != "off" ]]; then
ewarn "${iface} does not support setting keys"
ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect"
@@ -230,7 +230,6 @@ iwconfig_setup_specific() {
eerror "${iface} does not support setting ESSID to \"${dessid}\""
return 1
fi
- iwconfig "${iface}" nick "${ESSID}" 2>/dev/null
# Finally apply the user Config
iwconfig_user_config "${iface}" "${ESSIDVAR}"
@@ -245,7 +244,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"
@@ -264,10 +263,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 "$?"
}
@@ -276,12 +275,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\""
@@ -303,7 +302,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}"
@@ -338,8 +337,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
eerror "WEP key is not set for \"${dessid}\" - not connecting"
return 1
@@ -349,14 +348,14 @@ iwconfig_associate() {
ewarn "\"${dessid}\" is not WEP enabled - ignoring setting"
fi
- if ! eval iwconfig "${iface}" key "${key}" ; then
+ if ! iwconfig "${iface}" key ${key} ; then
if [[ ${key} != "off" ]]; then
ewarn "${iface} does not support setting keys"
ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect"
return 1
fi
fi
- [[ ${key} != "off" ]] && w=$( iwconfig_get_wep_status "${iface}" )
+ [[ ${key} != "off" ]] && w="$( iwconfig_get_wep_status "${iface}" )"
fi
if ! iwconfig "${iface}" essid "${ESSID}" ; then
@@ -364,7 +363,6 @@ iwconfig_associate() {
ewarn "${iface} does not support setting ESSID to \"${dessid}\""
fi
fi
- iwconfig "${iface}" nick "${ESSID}" 2>/dev/null
# Finally apply the user Config
iwconfig_user_config "${iface}" "${ESSIDVAR}"
@@ -390,7 +388,7 @@ iwconfig_associate() {
veend 0
if [[ ${ESSID} == "any" ]]; then
- ESSID=$( iwconfig_get_essid "${iface}" )
+ ESSID="$( iwconfig_get_essid "${iface}" )"
iwconfig_associate "${iface}"
return $?
fi
@@ -411,11 +409,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}\""
@@ -448,14 +446,14 @@ iwconfig_scan() {
case "${line}" in
*Address:*)
(( i++ ))
- mac[i]=$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' )
+ mac[i]="$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' )"
;;
*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:'*)
@@ -502,7 +500,7 @@ 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}"
for (( i=0; i<${#mac[@]}; i++ )); do
@@ -681,12 +679,13 @@ iwconfig_defaults() {
# Set some defaults
iwconfig "${iface}" rate auto &>/dev/null
- iwconfig "${iface}" rts off &>/dev/null
- iwconfig "${iface}" frag off &>/dev/null
- iwconfig "${iface}" power off &>/dev/null
+ iwconfig "${iface}" rts auto &>/dev/null
+ iwconfig "${iface}" frag auto &>/dev/null
iwconfig "${iface}" txpower auto &>/dev/null
iwconfig "${iface}" key [1] off &>/dev/null
iwconfig "${iface}" mode managed &>/dev/null
+ iwconfig "${iface}" essid -- off &>/dev/null
+ iwconfig "${iface}" ap off &>/dev/null
}
# void iwconfig_strip_associated(char *iface)
@@ -696,15 +695,15 @@ iwconfig_defaults() {
# We also remove from the preferred list
iwconfig_strip_associated() {
local iface="$1" e a j
- local essid=$( iwconfig_get_essid "${iface}" )
+ 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}" )
- u=()
+ e="$( iwconfig_get_essid "${i}" )"
+ local -a u=()
for ((j=0; j<${#mac_APs[@]}; j++)); do
if [[ ${essid_APs[j]} == "${e}" ]]; then
ewarn "${e} has already been associated with ${i}"
@@ -739,7 +738,7 @@ 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 iface="$1" test x e ifvar="$( bash_variable "$1" )"
local -a essid_APs mac_APs mode_APs enc_APs
iwconfig_defaults "${iface}"
@@ -750,7 +749,7 @@ iwconfig_configure() {
# 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 $?
@@ -763,7 +762,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}\""
@@ -799,10 +798,10 @@ iwconfig_configure() {
# Are we forcing preferred only?
x="associate_order_${ifvar}"
[[ -n ${!x} ]] && associate_order="${!x}"
- associate_order=$(
+ associate_order="$(
echo "${associate_order:-any}" \
| tr '[:upper:]' '[:lower:]'
- )
+ )"
if [[ ${associate_order} == "forcepreferredonly" ]]; then
iwconfig_force_preferred "${iface}" && return 0
@@ -814,7 +813,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
@@ -883,7 +882,7 @@ iwconfig_pre_start() {
# 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}" )
+ x="$( iwconfig_get_type "${iface}" )"
if [[ ${x} == "NOT READY!" ]]; then
eerror "Looks like there was a probem loading the firmware for ${iface}"
return 1
diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet
index ec01449..4c84b2d 100644
--- a/net-scripts/net.modules.d/macnet
+++ b/net-scripts/net.modules.d/macnet
@@ -18,7 +18,7 @@ macnet_depend() {
# bool macnet_start(char *iface)
#
-# All interfaces and module scripts expose modulename_get_vars
+# All interfaces and module scripts can depend on the variables function
# which returns a space seperated list of user configuration variables
# We can override each variable here from a given MAC address of the interface
# Always returns 0
diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd
index bd707c8..4a46045 100644
--- a/net-scripts/net.modules.d/pppd
+++ b/net-scripts/net.modules.d/pppd
@@ -15,7 +15,7 @@ pppd_depend() {
#
# Returns 1 if pppd is installed, otherwise 0
pppd_check_installed() {
- if [[ ! -x /usr/sbin/pppd ]]; then
+ if [[ ! -x /usr/sbin/pppd ]] ; then
${1:-false} && eerror "For PPP support, emerge net-dialup/ppp"
return 1
fi
@@ -56,7 +56,7 @@ pppd_regex_escape() {
# Add/update PAP/CHAP authentication information
pppd_update_secrets_file() {
local filepath="$1" username="$2" remotename="$3" password="$4"
- if [[ ! -s ${filepath} ]]; then
+ if [[ ! -s ${filepath} ]] ; then
echo '#'client$'\t'server$'\t'secret$'\t'IP addresses > "${filepath}" \
&& chmod 0600 "${filepath}" \
|| return 1
@@ -77,14 +77,14 @@ pppd_update_secrets_file() {
${filepath}
)
- if [[ -z "${old_password}" ]]; then
+ 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
+ elif [[ "\"${password//\"/\\\"}\"" != "${old_password}" ]] ; then
regex_password="${password//\\/\\\\}"
regex_password="${regex_password//\//\\/}"
regex_password="${regex_password//&/\\&}"
@@ -104,7 +104,7 @@ pppd_start() {
${IN_BACKGROUND} && return 0
local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link
- if [[ ${iface%%[0-9]*} != "ppp" ]]; then
+ if [[ ${iface%%[0-9]*} != "ppp" ]] ; then
eerror "PPP can only be invoked from net.ppp[0-9]"
return 1
fi
@@ -120,7 +120,7 @@ pppd_start() {
# PPPoA communicates over ATM
# In all cases, the link needs to be available before we start PPP
link="link_${ifvar}"
- if [[ -z ${!link} ]]; then
+ if [[ -z ${!link} ]] ; then
eerror "${link} has not been set in /etc/conf.d/net"
return 1
fi
@@ -131,7 +131,7 @@ pppd_start() {
password="password_${ifvar}"
#Add/update info in PAP/CHAP secrets files
- if [[ -n ${!username} && -n ${!password} ]]; then
+ if [[ -n ${!username} && -n ${!password} ]] ; then
for i in chap pap ; do
if ! pppd_update_secrets_file "/etc/ppp/${i}-secrets" \
"${!username}" "${iface}" "${!password}" ; then
@@ -146,16 +146,16 @@ pppd_start() {
opts="${!opts}"
# We don't work with these options set by the user
- for i in unit nodetach linkname maxfail persist ; do
- if [[ " ${opts} " == *" ${i} "* ]]; then
- eerror "The option \"${i}\" is not allowed"
+ for i in unit nodetach linkname ; do
+ if [[ " ${opts} " == *" ${i} "* ]] ; then
+ eerror "The option \"${i}\" is not allowed in pppd_${ifvar}"
return 1
fi
done
# Check for mtu/mru
local mtu="mtu_${ifvar}"
- if [[ -n ${!mtu} ]]; then
+ if [[ -n ${!mtu} ]] ; then
[[ " ${opts} " != *" mtu "* ]] && opts="${opts} mtu ${!mtu}"
[[ " ${opts} " != *" mru "* ]] && opts="${opts} mru ${!mtu}"
fi
@@ -172,28 +172,28 @@ pppd_start() {
[[ -f "/etc/ppp/options.${iface}" ]] \
&& opts="${opts} file /etc/ppp/options.${iface}"
- # Set forced options
- opts="unit ${unit} persist maxfail 0 ${opts}"
+ # Set unit
+ opts="unit ${unit} ${opts}"
+ # Default maxfail to 0 unless specified
+ [[ " ${opts} " != *" maxfail "* ]] && opts="${opts} maxfail 0"
+
+ # Append persist
+ [[ " ${opts} " != *" persist "* ]] && opts="${opts} persist"
+
# Setup connect script
local chat="chat_${ifvar}[@]"
- if [[ -n "${!chat}" ]]; then
- opts="${opts} connect \"/usr/sbin/chat -e -E -v"
-
+ if [[ -n "${!chat}" ]] ; then
+ local chatopts="/usr/sbin/chat -e -E -v"
local -a phone_number="phone_number_${ifvar}[@]"
phone_number=( "${!phone_number}" )
- if [[ ${#phone_number[@]} -ge 1 ]]; then
- opts="${opts} -T '${phone_number[0]}'"
- if [[ ${#phone_number[@]} -ge 2 ]]; then
- opts="${opts} -U '${phone_number[1]}'"
+ if [[ ${#phone_number[@]} -ge 1 ]] ; then
+ chatopts="${chatopts} -T '${phone_number[0]}'"
+ if [[ ${#phone_number[@]} -ge 2 ]] ; then
+ chatopts="${chatopts} -U '${phone_number[1]}'"
fi
fi
-
- for i in "${!chat}"; do
- opts="${opts} '${i}'"
- done
-
- opts="${opts}\""
+ opts="${opts} connect $(requote "${chatopts} $(requote "${!chat}")")"
fi
# Add plugins
@@ -212,8 +212,8 @@ pppd_start() {
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi)
local insert_link_in_opts=1
- if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]]; then
- if [[ ! -e /proc/net/pppoe ]]; then
+ if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]] ; then
+ if [[ ! -e /proc/net/pppoe ]] ; then
# Load the PPPoE kernel module
if ! modprobe pppoe ; then
eerror "kernel does not support PPPoE"
@@ -228,8 +228,8 @@ pppd_start() {
insert_link_in_opts=0
fi
- if [[ " ${opts} " == *" plugin pppoatm.so "* ]]; then
- if [[ ! -d /proc/net/atm ]]; then
+ if [[ " ${opts} " == *" plugin pppoatm.so "* ]] ; then
+ if [[ ! -d /proc/net/atm ]] ; then
# Load the PPPoA kernel module
if ! modprobe pppoatm ; then
eerror "kernel does not support PPPoATM"
@@ -243,13 +243,13 @@ pppd_start() {
[[ " ${opts} " != *" updetach "* ]] && mark_service_inactive "net.${iface}"
eval start-stop-daemon --start --exec /usr/sbin/pppd \
--pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null
- if [[ $? != "0" ]]; then
+ if [[ $? != "0" ]] ; then
eend $? "Failed to start PPP"
mark_service_starting "net.${iface}"
return $?
fi
- if [[ " ${opts} " == *" updetach "* ]]; then
+ if [[ " ${opts} " == *" updetach "* ]] ; then
local addr=$( interface_get_address "${iface}" )
einfo "${iface} received address ${addr}"
else
diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap
index dffa5ad..bdea08c 100644
--- a/net-scripts/net.modules.d/tuntap
+++ b/net-scripts/net.modules.d/tuntap
@@ -14,8 +14,7 @@ tunctl() {
#
# Sets up the dependancies for the module
tuntap_depend() {
- after interface macnet
- before dhcp
+ before interface macchanger
functions interface_exists interface_type
variables tunctl
}
diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant
index 4f621d1..77fc29c 100644
--- a/net-scripts/net.modules.d/wpa_supplicant
+++ b/net-scripts/net.modules.d/wpa_supplicant
@@ -58,7 +58,7 @@ wpa_supplicant_get_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
@@ -120,7 +120,7 @@ wpa_supplicant_kill() {
${report} && eend "$?"
else
# Support wpa_supplicant-0.3.x
- local pid=$( pgrep -f '^/sbin/wpa_supplicant .* -i'"${iface}"'[ ]*$' )
+ local pid="$( pgrep -f "^/sbin/wpa_supplicant .* -i${iface}[ ]*$" )"
if [[ -n ${pid} ]]; then
${report} && ebegin "Stopping wpa_supplicant on ${iface}"
kill -s TERM "${pid}"
@@ -138,7 +138,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 i
+ local iface="$1" ifvar="$( bash_variable "$1" )" timeout i
timeout="associate_timeout_${ifvar}"
[[ -z ${!timeout} ]] && timeout="wpa_timeout_${ifvar}"
timeout="${!timeout:--1}"
@@ -151,7 +151,7 @@ wpa_supplicant_associate() {
fi
while true ; do
- if ${action} ; then
+ if [[ -n ${actfile} ]] ; then
service_started "net.${iface}" && return 0
else
if ! wpa_cli -i"${iface}" status &>/dev/null ; then
@@ -166,7 +166,7 @@ wpa_supplicant_associate() {
done
# Spit out an appropriate error
- if ${action} ; then
+ if [[ -n ${actfile} ]] ; then
eend 1 "Failed to configure ${iface} in the background"
else
eend 1 "Timed out"
@@ -174,7 +174,7 @@ wpa_supplicant_associate() {
# exit without error with wpa_supplicant-0.4.x as we may get kickstarted
# when an AP comes in range
- ${action} && exit 0
+ [[ -n ${actfile} ]] && exit 0
# Kill wpa_supplicant for 0.3.x
wpa_supplicant_kill "${iface}"
@@ -186,16 +186,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 action=false cfgfile
- local actfile="/sbin/wpa_cli.action"
+ 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}"
fi
return 0
@@ -204,7 +203,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"* ]] \
@@ -246,8 +245,13 @@ wpa_supplicant_pre_start() {
[[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}"
cfgfile="${cfgfile%% *}"
else
- cfgfile="/etc/wpa_supplicant.conf"
- opts="${opts} -c/etc/wpa_supplicant.conf"
+ # Support new and old style locations
+ cfgfile="/etc/wpa_supplicant/wpa_supplicant-${iface}.conf"
+ [[ ! -e ${cfgfile} ]] \
+ && cfgfile="/etc/wpa_supplicant/wpa_supplicant.conf"
+ [[ ! -e ${cfgfile} ]] \
+ && cfgfile="/etc/wpa_supplicant.conf"
+ opts="${opts} -c${cfgfile}"
fi
if [[ ! -f ${cfgfile} ]]; then
@@ -255,7 +259,7 @@ wpa_supplicant_pre_start() {
return 1
fi
- 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 [[ ${ctrl_dir} != "/var/run/wpa_supplicant" ]]; then
eerror "${cfgfile} must set"
eerror " ctrl_interface=/var/run/wpa_supplicant"
@@ -266,7 +270,7 @@ wpa_supplicant_pre_start() {
# Some drivers require the interface to be up
interface_up "${iface}"
- version=$( wpa_cli -v | sed -n -e 's/wpa_cli v//p' )
+ version="$( wpa_cli -v | sed -n -e 's/wpa_cli v//p' )"
version=( ${version//./ } )
(( version = version[0] * 1000 + version[1] * 100 + version[2] ))
@@ -276,9 +280,12 @@ wpa_supplicant_pre_start() {
# wpa_cli is now responsible for informing us of success/failure.
# The downside of this is that we don't see the interface being configured
# for DHCP/static.
- if [[ ${version} -gt 399 && -x ${actfile} ]]; then
+ if [[ ${version} -gt 399 ]]; then
opts="${opts} -W -P/var/run/wpa_supplicant-${iface}.pid"
- action=true
+ actfile="/etc/wpa_supplicant/wpa_cli.sh"
+ # Support old file location
+ [[ ! -x ${actfile} ]] && actfile="/sbin/wpa_cli.action"
+ [[ ! -x ${actfile} ]] && unset actfile
fi
eval start-stop-daemon --start --exec /sbin/wpa_supplicant \
@@ -288,7 +295,7 @@ wpa_supplicant_pre_start() {
# Starting wpa_supplication-0.4.0, we can get wpa_cli to
# start/stop our scripts from wpa_supplicant messages
- if ${action} ; then
+ if [[ -n ${actfile} ]] ; then
mark_service_inactive "net.${iface}"
ebegin "Starting wpa_cli on ${iface}"
start-stop-daemon --start --exec /bin/wpa_cli \
@@ -307,8 +314,8 @@ 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
@@ -329,8 +336,8 @@ wpa_supplicant_pre_start() {
einfo "${iface} connected"
fi
- if ${action} ; then
- local addr=$( interface_get_address "${iface}" )
+ if [[ -n ${actfile} ]] ; then
+ local addr="$( interface_get_address "${iface}" )"
einfo "${iface} configured with address ${addr}"
exit 0
fi
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 1b68506..96940d0 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -460,8 +460,6 @@ mark_service_started() {
"${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
"${svcdir}"/scheduled/*/"$1"
- end_service "$1" 0
-
return 0
}
@@ -477,8 +475,6 @@ mark_service_inactive() {
rm -f "${svcdir}/started/$1" "${svcdir}/wasinactive/$1" \
"${svcdir}/starting/$1" "${svcdir}/stopping/$1"
- end_service "$1" 0
-
return 0
}
@@ -510,8 +506,6 @@ mark_service_stopped() {
"${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
"${svcdir}/scheduled/$1"
- end_service "$1" 0
-
return 0
}
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index d57b725..a4357aa 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -549,6 +549,7 @@ for arg in $* ; do
rm -rf "${svcdir}/snapshot/$$"
mkdir -p "${svcdir}/snapshot/$$"
cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/"
+ rm -f "${svcdir}/snapshot/$$/${myservice}"
fi
svc_stop
@@ -592,6 +593,7 @@ for arg in $* ; do
rm -rf "${svcdir}/snapshot/$$"
mkdir -p "${svcdir}/snapshot/$$"
cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/"
+ rm -f "${svcdir}/snapshot/$$/${myservice}"
# Simple way to try and detect if the service use svc_{start,stop}
# to restart if it have a custom restart() funtion.
@@ -614,7 +616,7 @@ for arg in $* ; do
[[ -e "${svcdir}/scheduled/${myservice}" ]] \
&& rm -Rf "${svcdir}/scheduled/${myservice}"
-
+
# Restart dependencies as well
for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
if service_stopped "${x##*/}" ; then
@@ -622,7 +624,7 @@ for arg in $* ; do
|| service_wasinactive "${myservice}" ; then
svc_schedule_start "${myservice}" "${x##*/}"
ewarn "WARNING: ${x##*/} is scheduled to start when ${myservice} has started."
- else
+ elif service_started "${myservice}" ; then
start_service "${x##*/}"
fi
fi