summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2005-11-05 06:31:33 +0000
committerChristian Heim <phreak@gentoo.org>2005-11-05 06:31:33 +0000
commitc19e259b2b3334adde61c3db89774b9db41b8704 (patch)
treed6aa04fd4bd07e9bb83abae6d63f7cb9c7b82c2f /net-scripts
parentMerging changes from baselayout 1583 (diff)
downloadbaselayout-vserver-c19e259b2b3334adde61c3db89774b9db41b8704.tar.gz
baselayout-vserver-c19e259b2b3334adde61c3db89774b9db41b8704.tar.bz2
baselayout-vserver-c19e259b2b3334adde61c3db89774b9db41b8704.zip
Merging changes between baselayout r1583 and r1596.
svn path=/baselayout-vserver/trunk/; revision=64
Diffstat (limited to 'net-scripts')
-rwxr-xr-xnet-scripts/init.d/net.lo307
-rw-r--r--net-scripts/net.modules.d/adsl62
-rw-r--r--net-scripts/net.modules.d/apipa47
-rw-r--r--net-scripts/net.modules.d/arping100
-rw-r--r--net-scripts/net.modules.d/bonding35
-rw-r--r--net-scripts/net.modules.d/bridge41
-rw-r--r--net-scripts/net.modules.d/dhclient42
-rw-r--r--net-scripts/net.modules.d/dhcpcd36
-rw-r--r--net-scripts/net.modules.d/essidnet35
-rwxr-xr-xnet-scripts/net.modules.d/helpers.d/dhcp6
-rw-r--r--net-scripts/net.modules.d/helpers.d/functions49
-rw-r--r--net-scripts/net.modules.d/helpers.d/module-loader26
-rw-r--r--net-scripts/net.modules.d/ifconfig49
-rw-r--r--net-scripts/net.modules.d/ifplugd38
-rw-r--r--net-scripts/net.modules.d/ipppd26
-rw-r--r--net-scripts/net.modules.d/iproute250
-rw-r--r--net-scripts/net.modules.d/iptunnel42
-rw-r--r--net-scripts/net.modules.d/iwconfig34
-rw-r--r--net-scripts/net.modules.d/macchanger32
-rw-r--r--net-scripts/net.modules.d/macnet35
-rw-r--r--net-scripts/net.modules.d/netplugd36
-rw-r--r--net-scripts/net.modules.d/pppd15
-rw-r--r--net-scripts/net.modules.d/pump35
-rw-r--r--net-scripts/net.modules.d/rename33
-rw-r--r--net-scripts/net.modules.d/system37
-rw-r--r--net-scripts/net.modules.d/tuntap34
-rw-r--r--net-scripts/net.modules.d/udhcpc52
-rw-r--r--net-scripts/net.modules.d/vlan40
-rw-r--r--net-scripts/net.modules.d/wpa_supplicant54
29 files changed, 449 insertions, 979 deletions
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index 523dd65..f1dbfdc 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -17,7 +17,7 @@ depend() {
# Load any custom depend functions for the given interface
# For example, br0 may need eth0 and eth1
local iface="${myservice##*.}"
- [[ $( type -t depend_${iface} ) == "function" ]] && depend_${iface}
+ [[ $(type -t "depend_${iface}") == "function" ]] && depend_${iface}
return 0
}
@@ -34,30 +34,27 @@ source "${MODULES_DIR}/helpers.d/functions"
# Make some wrappers to fudge after/before/need/use depend flags.
# These are callbacks so MODULE will be set.
after() {
- local x="$*"
- [[ $# -gt 1 ]] && x=$( echo -e "${x// /\n}" | sort | xargs )
- eval "${MODULE}_after() { echo \"$x\"; }"
+ eval "${MODULE}_after() { echo \"$*\"; }"
}
before() {
- local x="$*"
- [[ $# -gt 1 ]] && x=$( echo -e "${x// /\n}" | sort | xargs )
- eval "${MODULE}_before() { echo \"$x\"; }"
+ eval "${MODULE}_before() { echo \"$*\"; }"
}
need() {
- local x="$*"
- [[ $# -gt 1 ]] && x=$( echo -e "${x// /\n}" | sort | xargs )
- eval "${MODULE}_need() { echo \"$x\"; }"
+ eval "${MODULE}_need() { echo \"$*\"; }"
}
installed() {
- local x="$*"
- [[ $# -gt 1 ]] && x=$( echo -e "${x// /\n}" | sort | xargs )
# We deliberately misspell this as _installed will probably be used
# at some point
- eval "${MODULE}_instlled() { echo \"$x\"; }"
+ eval "${MODULE}_instlled() { echo \"$*\"; }"
}
-
-sort() {
- LC_ALL=C /bin/sort "$@"
+provide() {
+ eval "${MODULE}_provide() { echo \"$*\"; }"
+}
+functions() {
+ eval "${MODULE}_functions() { echo \"$*\"; }"
+}
+variables() {
+ eval "${MODULE}_variables() { echo \"$*\"; }"
}
# void go_background(void)
@@ -85,8 +82,8 @@ module_load_minimum() {
return 1
fi
- for f in check_installed provides check_depends depend; do
- [[ $( type -t "${MODULE}_${f}" ) == "function" ]] && continue
+ for f in depend; do
+ is_function "${MODULE}_${f}" && continue
eerror "${MODULE} does not support the required function ${f}"
return 1
done
@@ -99,7 +96,7 @@ module_load_minimum() {
# Load and check each module for sanity
# If the module is not installed, the functions are to be removed
modules_load_auto() {
- local i j
+ local i j inst
# Populate the MODULES array
# Basically we treat evey file in ${MODULES_DIR} as a module
@@ -122,10 +119,16 @@ modules_load_auto() {
eerror "interface is a reserved name - cannot load a module called interface"
return 1
fi
+
(
u=0;
module_load_minimum "${MODULES[i]}" || u=1;
- [[ ${u} == 0 ]] && ${MODULES[i]##*/}_check_installed false || u=1;
+ if [[ ${u} == 0 ]]; then
+ inst="${MODULES[i]##*/}_check_installed";
+ if is_function "${inst}" ; then
+ ${inst} false || u=1;
+ fi
+ fi
exit "${u}";
)
@@ -154,11 +157,13 @@ modules_check_installed() {
local i j missingdeps nmods="${#MODULES[@]}"
for (( i=0; i<nmods; i++ )); do
- [[ $( type -t "${MODULES[i]}_instlled" ) != "function" ]] && continue
+ is_function "${MODULES[i]}_instlled" || continue
for j in $( ${MODULES[i]}_instlled ); do
missingdeps=true
- if [[ $( type -t "${j}_check_installed" ) == "function" ]]; then
+ if is_function "${j}_check_installed" ; then
${j}_check_installed && missingdeps=false
+ elif is_function "${j}_depend" ; then
+ missingdeps=false
fi
${missingdeps} && unset MODULES[i] && unset PROVIDES[i] && break
done
@@ -209,13 +214,12 @@ modules_check_user() {
)
unset MODULES[j]
unset PROVIDES[j]
- break
fi
done
continue
fi
- if [[ $( type -t "${umods[i]}_provides" ) != "function" ]]; then
+ if ! is_function "${umods[i]}_depend" ; then
# If the module is one of our preferred modules, then
# ignore this error; whatever is available will be
# used instead.
@@ -225,14 +229,19 @@ modules_check_user() {
# not installed. Load the module and report its error
if [[ -e "${MODULES_DIR}/${umods[i]}" ]]; then
source "${MODULES_DIR}/${umods[i]}"
- ${umods[i]}_check_installed true
+ is_function "${umods[i]}_check_installed" \
+ && ${umods[i]}_check_installed true
else
eerror "The module \"${umods[i]}\" does not exist"
fi
return 1
fi
- mod=$( ${umods[i]}_provides )
+ if is_function "${umods[i]}_provide" ; then
+ 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
@@ -269,84 +278,82 @@ modules_check_user() {
}
# void modules_sort(void)
-
+#
+# Sort our modules
modules_sort() {
- local -a modnums sort_history modafter modbefore
- local i j k p changed_something nmods="${#MODULES[@]}"
-
- # Sort our modules
- # We do this by assigning numbers to each module
- # We also assign modbefore and modafter so we don't
- # shell out as much because it's expensive on CPU.
- modnums=()
- for (( i=0; i<nmods; i++ )); do
- modnums[i]="${i}"
- [[ $( type -t "${MODULES[i]}_after" ) == "function" ]] \
- && modafter[i]=$( ${MODULES[i]}_after )
- [[ $( type -t "${MODULES[i]}_before" ) == "function" ]] \
- && modbefore[i]=$( ${MODULES[i]}_before )
+ local i j nmods=${#MODULES[@]} m
+ local -a provide=() provide_list=() after=() dead=() sorted=() sortedp=()
+
+ # Make our provide list
+ for ((i=0; i<nmods; i++)); do
+ dead[i]="false"
+ if [[ ${MODULES[i]} != "${PROVIDES[i]}" ]] ; then
+ local provided=false
+ for ((j=0; j<${#provide[@]}; j++)); do
+ if [[ ${provide[j]} == "${PROVIDES[i]}" ]]; then
+ provide_list[j]="${provide_list[j]} ${MODULES[i]}"
+ provided=true
+ fi
+ done
+ if ! ${provided}; then
+ provide[j]="${PROVIDES[i]}"
+ provide_list[j]="${MODULES[i]}"
+ fi
+ fi
done
- # Then we swap numbers based on and after/before flags
- # until we don't swap anymore. The sort_history array prevents
- # the possibility of an infinite loop
- sort_history[0]="${modnums[*]}"
- for (( k=1; 1; k++ )); do
- changed_something=false
- for (( i=0; i<nmods; i++ )); do
- for p in ${modafter[i]}; do
- for (( j=0; j<nmods; j++ )); do
- [[ ${p} != "${MODULES[j]}" && ${p} != "${PROVIDES[j]}" ]] \
- && continue
-
- if [[ ${modnums[i]} -lt "${modnums[j]}" ]]; then
- tmp="${modnums[i]}"
- modnums[i]="${modnums[j]}"
- modnums[j]="${tmp}"
- changed_something=true
- fi
- done
- done
- for p in ${modbefore[i]}; do
- for (( j=0; j<nmods; j++ )); do
- [[ ${p} != "${MODULES[j]}" && ${p} != "${PROVIDES[j]}" ]] \
- && continue
-
- if [[ ${modnums[i]} -gt "${modnums[j]}" ]]; then
- tmp="${modnums[i]}"
- modnums[i]="${modnums[j]}"
- modnums[j]="${tmp}"
- changed_something=true
+ # Create an after array, which holds which modules the module at
+ # index i must be after
+ for ((i=0; i<nmods; i++)); do
+ if is_function "${MODULES[i]}_after" ; then
+ after[i]=" ${after[i]} $(${MODULES[i]}_after) "
+ fi
+ 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
+ after[j]=" ${after[j]} ${MODULES[i]} "
+ break
fi
done
done
- done
- ${changed_something} || break
-
- # Make sure we aren't repeating a previous state
- # First time through, k=1, k/2=0
- sort_history[k]="${modnums[*]}"
- if [[ ${sort_history[k]} == "${sort_history[k/2]}" ]]; then
- eerror "Detected an infinite loop sorting modules; blundering ahead"
- break
fi
done
- # Finally we sort our modules in number order
- um=""
- for (( i=0; i<nmods; i++ )); do
- um="${um}${modnums[i]} ${MODULES[i]} ${PROVIDES[i]}\n"
+ # Replace the after list modules with real modules
+ for ((i=0; i<nmods; i++)); do
+ if [[ -n ${after[i]} ]]; then
+ for ((j=0; j<${#provide[@]}; j++)); do
+ after[i]="${after[i]// ${provide[j]} / ${provide_list[j]} }"
+ done
+ fi
done
+
+ # We then use the below code to provide a topologial sort
+ module_after_visit() {
+ local name=$1 i x
- p=( $( echo -e "${um}" | sort -n | cut -d' ' -f2,3 ) )
- MODULES=()
- PROVIDES=()
- j=0
- for (( i=0; i<${#p[@]}; i+=2 )); do
- MODULES[j]="${p[i]}"
- PROVIDES[j]="${p[i+1]}"
- (( j++ ))
+ for ((i=0; i<nmods; i++)); do
+ [[ ${MODULES[i]} == "$1" ]] && break
+ done
+
+ ${dead[i]} && return
+ dead[i]="true"
+
+ for x in ${after[i]} ; do
+ module_after_visit "${x}"
+ done
+
+ sorted=( "${sorted[@]}" "${MODULES[i]}" )
+ sortedp=( "${sortedp[@]}" "${PROVIDES[i]}" )
+ }
+
+ for x in ${MODULES[@]}; do
+ module_after_visit "${x}"
done
+
+ MODULES=( "${sorted[@]}" )
+ PROVIDES=( "${sortedp[@]}" )
}
# bool modules_check_depends(bool showprovides)
@@ -355,7 +362,7 @@ modules_check_depends() {
local missingdeps p interface=false
for (( i=0; i<nmods; i++ )); do
- if [[ $( type -t "${MODULES[i]}_need" ) == "function" ]]; then
+ if is_function "${MODULES[i]}_need" ; then
for needmod in $( ${MODULES[i]}_need ); do
missingdeps=true
for (( j=0; j<nmods; j++ )); do
@@ -372,7 +379,15 @@ modules_check_depends() {
done
fi
- ${MODULES[i]}_check_depends || return 1
+ if is_function "${MODULES[i]}_functions" ; then
+ for f in $( ${MODULES[i]}_functions ); do
+ if ! is_function "${f}" ; then
+ eerror "${MODULES[i]}: missing required function \"${f}\""
+ return 1
+ fi
+ done
+ fi
+
[[ ${PROVIDES[i]} == "interface" ]] && interface=true
if ${showprovides} ; then
@@ -418,57 +433,63 @@ modules_load() {
j="${#modules_force[@]}"
for (( i=0; i<j; i++ )); do
module_load_minimum "${MODULES_DIR}/${modules_force[i]}" || return 1
- ${modules_force[i]}_check_installed || unset modules_force[i]
- done
- modules_force=( "${modules_force[@]}" )
-
- # Strip any duplicate modules providing the same thing
- j="${#modules_force[@]}"
- for (( i=0; i<j-1; i++ )); do
- [[ -z ${modules_force[i]} ]] && continue
- for (( k=i+1; k<j; k++ )); do
- [[ -z ${modules_force[k]} ]] && continue
- [[ $( ${modules_force[i]}_provides ) \
- == $( ${modules_force[k]}_provides ) ]] \
- && unset modules_force[k]
- done
+ if is_function "${modules_force[i]}_check_installed" ; then
+ ${modules_force[i]}_check_installed || unset modules_force[i]
+ fi
done
-
MODULES=( "${modules_force[@]}" )
fi
- # We now buffer the _provides functions for a big speed boost
j="${#MODULES[@]}"
for (( i=0; i<j; i++ )); do
- PROVIDES[i]=$( ${MODULES[i]}_provides )
+ # Now load our dependencies - we need to use the MODULE variable
+ # here as the after/before/need functions use it
+ MODULE="${MODULES[i]}"
+ ${MODULE}_depend
+
+ # If no provide is given, assume module name
+ if is_function "${MODULES[i]}_provide" ; then
+ PROVIDES[i]=$( ${MODULES[i]}_provide )
+ else
+ PROVIDES[i]="${MODULES[i]}"
+ fi
done
- if [[ -z ${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
+ unset MODULES[k]
+ unset PROVIDES[k]
+ fi
+ done
+ done
+ MODULES=( "${MODULES[@]}" )
+ PROVIDES=( "${PROVIDES[@]}" )
+ else
if ${starting}; then
modules_check_user || return 1
+ else
+ # Always prefer iproute2 for taking down interfaces
+ if is_function iproute2_provide ; then
+ function_wrap iproute2 $(iproute2_provide)
+ fi
fi
fi
-
- # Setup class wrappers: interface_up -> iproute2_up, for example
+
+ # Wrap our modules
j="${#MODULES[@]}"
for (( i=0; i<j; i++ )); do
function_wrap "${MODULES[i]}" "${PROVIDES[i]}"
-
- # Now load our dependencies - we need to use the MODULE variable
- # here as the after/before/need functions use it
- if [[ -z ${modules_force[@]} ]]; then
- MODULE="${MODULES[i]}"
- ${MODULE}_depend
- fi
done
-
- # Some modules may be installed, but not selected by user preference
- # so we wrap these if needed
j="${#WRAP_MODULES[@]}"
for (( i=0; i<j; i++ )); do
- function_wrap "${WRAP_MODULES[i]}"
+ function_wrap ${WRAP_MODULES[i]}
done
-
+
if [[ -z ${modules_force[@]} ]]; then
modules_check_installed || return 1
modules_sort || return 1
@@ -506,7 +527,7 @@ iface_start() {
# pre Start any modules with
for mod in ${MODULES[@]}; do
- if [[ $( type -t "${mod}_pre_start" ) == "function" ]]; then
+ if is_function "${mod}_pre_start" ; then
${mod}_pre_start "${iface}" || { eend 1; return 1; }
fi
done
@@ -554,7 +575,7 @@ iface_start() {
# Otherwise a default of NULL
if [[ -z ${config} ]]; then
# if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
- if [[ $( type -t "dhcp_start" ) == "function" ]]; then
+ if is_function "dhcp_start" ; then
config=( "dhcp" )
ewarn "Configuration not set for ${iface} - assuming dhcp"
else
@@ -585,7 +606,7 @@ iface_start() {
einfo "${conf[0]}"
# Do we have a function for our config?
- if [[ $( type -t "${conf[0]}_start" ) == "function" ]]; then
+ if is_function "${conf[0]}_start" ; then
eindent
${conf[0]}_start "${iface}" ; x=$?
eoutdent
@@ -594,9 +615,9 @@ iface_start() {
# We do this by testing if the 1st character is a digit
elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]]; then
x="0"
- if [[ ${RC_AUTO_INTERFACE} == "yes" \
- && $(type -t address_exists ) == "function" ]]; then
- if address_exists "${iface}" "${conf[0]}" ; then
+ if [[ ${RC_AUTO_INTERFACE} == "yes" ]] \
+ && is_function arping_address_exists ; then
+ if arping_address_exists "${iface}" "${conf[0]}" ; then
eerror "${conf[0]%%/*} already taken on ${iface}"
x="1"
fi
@@ -629,7 +650,7 @@ iface_start() {
# Start any modules with _post_start
for mod in ${MODULES[@]}; do
- if [[ $( type -t "${mod}_post_start" ) == "function" ]]; then
+ if is_function "${mod}_post_start" ; then
${mod}_post_start "${iface}" || return 1
fi
done
@@ -649,8 +670,7 @@ iface_stop() {
# pre Stop any modules
for mod in ${MODULES[@]}; do
- [[ $( type -t "${mod}_pre_stop" ) == "function" ]] \
- && ${mod}_pre_stop "${iface}"
+ is_function "${mod}_pre_stop" && ${mod}_pre_stop "${iface}"
done
einfo "Bringing down ${iface}"
@@ -667,7 +687,7 @@ iface_stop() {
for i in ${aliases} ${iface}; do
# Stop all our modules
for mod in ${MODULES[@]}; do
- [[ $( type -t "${mod}_stop" ) == "function" ]] && ${mod}_stop "${i}"
+ is_function "${mod}_stop" && ${mod}_stop "${i}"
done
# A module may have removed the interface
@@ -690,8 +710,7 @@ iface_stop() {
# post Stop any modules
for mod in ${MODULES[@]}; do
# We have already taken down the interface, so no need to error
- [[ $( type -t "${mod}_post_stop" ) == "function" ]] \
- && ${mod}_post_stop "${iface}"
+ is_function "${mod}_post_stop" && ${mod}_post_stop "${iface}"
done
return 0
@@ -730,7 +749,7 @@ run_start() {
fi
# Call user-defined preup function if it exists
- if [[ $( type -t preup ) == "function" ]]; then
+ if is_function preup ; then
einfo "Running preup function"
eindent
( preup "${iface}" )
@@ -762,7 +781,7 @@ run_start() {
fi
# Call user-defined postup function if it exists
- if [[ $( type -t postup ) == "function" ]]; then
+ if is_function postup ; then
einfo "Running postup function"
eindent
( postup "${iface}" )
@@ -786,7 +805,7 @@ run_stop() {
[[ -n ${ESSID} ]] && ESSIDVAR=$( bash_variable "${ESSID}" )
# Call user-defined predown function if it exists
- if [[ $( type -t predown ) == "function" ]]; then
+ if is_function predown ; then
einfo "Running predown function"
eindent
( predown "${iface}" )
@@ -800,7 +819,7 @@ run_stop() {
iface_stop "${iface}" || return 1 # always succeeds, btw
# Call user-defined postdown function if it exists
- if [[ $( type -t postdown ) == "function" ]]; then
+ if is_function postdown ; then
einfo "Running postdown function"
eindent
( postdown "${iface}" )
@@ -870,7 +889,7 @@ run() {
else
if [[ ${cmd} == "start" ]]; then
# Call user-defined failup if it exists
- if [[ $( type -t failup ) == "function" ]]; then
+ if is_function failup ; then
einfo "Running failup function"
eindent
( failup "${iface}" )
@@ -878,7 +897,7 @@ run() {
fi
else
# Call user-defined faildown if it exists
- if [[ $( type -t faildown ) == "function" ]]; then
+ if is_function faildown ; then
einfo "Running faildown function"
eindent
( faildown "${iface}" )
diff --git a/net-scripts/net.modules.d/adsl b/net-scripts/net.modules.d/adsl
index 87bf6ab..dbf6be7 100644
--- a/net-scripts/net.modules.d/adsl
+++ b/net-scripts/net.modules.d/adsl
@@ -4,18 +4,10 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* adsl_provides(void)
-#
-# Returns a string to change module definition for starting up
-adsl_provides() {
- echo "adsl"
-}
-
# void adsl_depend(void)
#
# Sets up the dependancies for the module
adsl_depend() {
- after interface
before dhcp
}
@@ -23,23 +15,24 @@ adsl_depend() {
#
# Returns 1 if rp-pppoe is installed, otherwise 0
adsl_check_installed() {
- [[ -x /usr/sbin/adsl-start ]] && return 0
+ [[ -x /usr/sbin/adsl-start || -x /usr/sbin/pppoe-start ]] && return 0
${1:-false} && eerror "For ADSL support, emerge net-dialup/rp-pppoe"
return 1
}
-# bool adsl_check_depends(void)
-#
-# Checks to see if we have the needed functions
-adsl_check_depends() {
- return 0
-}
-
# bool adsl_setup_vars(char *iface)
#
# Checks to see if the ADSL script has been created or not
adsl_setup_vars() {
- local iface="$1"
+ local iface="$1" startstop="$2" cfgexe
+
+ if [[ -x /usr/sbin/pppoe-start ]]; then
+ exe="/usr/sbin/pppoe-${startstop}"
+ cfgexe=pppoe-setup
+ else
+ exe="/usr/sbin/adsl-${startstop}"
+ cfgexe=adsl-setup
+ fi
# Decide which configuration to use. Hopefully there is an
# interface-specific one
@@ -48,7 +41,7 @@ adsl_setup_vars() {
if [[ ! -f ${cfgfile} ]]; then
eerror "no pppoe.conf file found!"
- eerror "Please run adsl-setup to create one"
+ eerror "Please run ${cfgexe} to create one"
return 1
fi
@@ -61,41 +54,42 @@ adsl_setup_vars() {
#
# Returns 0 (true) when successful, non-zero otherwise
adsl_start() {
- local iface="$1" user ifvar=$( bash_variable "$1" ) cfgfile
+ local iface="$1" exe cfgfile user ifvar=$( bash_variable "$1" )
- adsl_setup_vars "${iface}" || return 1
+ adsl_setup_vars "${iface}" start || return 1
# Might or might not be set in conf.d/net
eval user=\"\$\{adsl_user_${ifvar}\}\"
# Start ADSL with the cfgfile, but override ETH and PIDFILE
einfo "Starting ADSL for ${iface}"
- /usr/sbin/adsl-start <(cat "${cfgfile}"; \
- echo "ETH=${iface}"; \
- echo "PIDFILE=/var/run/adsl-${iface}.pid"; \
- [[ -n ${user} ]] && echo "USER=${user}") \
- >/dev/null
+ ${exe} <(cat "${cfgfile}"; \
+ echo "ETH=${iface}"; \
+ echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid"; \
+ [[ -n ${user} ]] && echo "USER=${user}") \
+ >/dev/null
eend $?
}
# bool adsl_stop(char *iface)
#
-# Stop ADSL on an interface by calling adsl-stop
# Returns 0 when there is no ADSL to stop or we stop ADSL successfully
# Otherwise 1
adsl_stop() {
- local iface="$1" cfgfile
+ local iface="$1" exe cfgfile
- adsl_check_installed || return 0
- [[ ! -f "/var/run/adsl-${iface}.pid" ]] && return 0
+ adsl_check_installed || return 1
+ [[ ! -f "/var/run/rp-pppoe-${iface}.pid" ]] && return 0
- adsl_setup_vars "${iface}" || return 0
+ adsl_setup_vars "${iface}" stop || return 1
einfo "Stopping ADSL for ${iface}"
- /usr/sbin/adsl-stop <(cat "${cfgfile}"; \
- echo "ETH=${iface}"; echo "PIDFILE=/var/run/adsl-${iface}.pid") \
- >/dev/null
+ ${exe} <(cat "${cfgfile}"; \
+ echo "ETH=${iface}"; echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid") \
+ >/dev/null
eend $?
+
+ return 0
}
-# vim:ts=4
+# vim: ts=4
diff --git a/net-scripts/net.modules.d/apipa b/net-scripts/net.modules.d/apipa
new file mode 100644
index 0000000..9e6bbfa
--- /dev/null
+++ b/net-scripts/net.modules.d/apipa
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Copyright (c) 2004-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# Contributed by Roy Marples (uberlord@gentoo.org)
+# void apipa_depend(void)
+#
+# Sets up the dependancies for the module
+apipa_depend() {
+ installed arping
+ functions interface_exists
+}
+
+# bool apipa_start(char *iface)
+#
+# Tries to detect a config based on arpinging things
+apipa_start() {
+ local iface="$1" i1 i2 addr i=0
+
+ interface_exists "$1" true || return 1
+
+ einfo "Searching for free addresses in 169.254.0.0/16"
+ eindent
+
+ while [[ ${i} -lt 64516 ]]; do
+ (( i1=${RANDOM}%255 ))
+ (( i2=${RANDOM}%255 ))
+
+ addr="169.254.${i1}.${i2}"
+ vebegin "${addr}/16"
+ if ! arping_address_exists "${iface}" "${addr}" ; then
+ config[config_counter]="${addr}/16 broadcast 169.254.255.255"
+ (( config_counter-- ))
+ veend 0
+ eoutdent
+ return 0
+ fi
+
+ (( i++ ))
+ done
+
+ eerror "No free address found!"
+ eoutdent
+ return 1
+}
+
+# vim:ts=4
diff --git a/net-scripts/net.modules.d/arping b/net-scripts/net.modules.d/arping
index 5f04978..aed04e7 100644
--- a/net-scripts/net.modules.d/arping
+++ b/net-scripts/net.modules.d/arping
@@ -4,18 +4,11 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* arping_provides(void)
-#
-# Returns a string to change module definition for starting up
-arping_provides() {
- echo "arping"
-}
-
# void arping_depend(void)
#
# Sets up the dependancies for the module
arping_depend() {
- after system dhcp vlan
+ functions interface_exists interface_up
}
# bool arping_check_installed(void)
@@ -29,28 +22,13 @@ arping_check_installed() {
return 1
}
-# bool arping_check_depends(void)
-#
-# Checks to see if we have the needed functions
-arping_check_depends() {
- local f
-
- for f in interface_exists interface_up ; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "arping: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# bool address_exists(char *interface, char *address)
+# bool arping_address_exists(char *interface, char *address)
#
# Returns 0 if the address on the interface responds to an arping
# 1 if not - packets defaults to 1
# If neither arping (net-misc/iputils) or arping2 (net-analyzer/arping)
# is installed then we return 1
-address_exists() {
+arping_address_exists() {
local iface="$1" address="${2%%/*}" i
# We only handle IPv4 addresses
@@ -74,22 +52,28 @@ address_exists() {
return 1
}
-# bool arping_gateways(void)
+# bool arping_start(char *iface)
#
# arpings a list of gateways
# If one is foung then apply it's configuration
-arping_gateways() {
- local gateways x conf i
-
- eval gateways=\"\$\{arping_${ifvar}\}\"
- [[ -z ${gateways} ]] && return 1
+arping_start() {
+ local iface="$1" gateways x conf i
+
+ interface_exists "${iface}" true || return 1
einfo "Pinging gateways on ${iface} for configuration"
- eindent
+ eval gateways=\"\$\{arping_${ifvar}\}\"
+ if [[ -z ${gateways} ]]; then
+ eerror "No gateways have been defined (gateways_${ifvar}=\"...\")"
+ return 1
+ fi
+
+ eindent
+
for x in ${gateways}; do
vebegin "${x}"
- if address_exists "${iface}" "${x}" ; then
+ if arping_address_exists "${iface}" "${x}" ; then
for i in ${x//./ } ; do
if [[ ${#i} == "2" ]]; then
conf="${conf}0${i}"
@@ -103,6 +87,10 @@ arping_gateways() {
eoutdent
veinfo "Configuring ${iface} for ${x}"
configure_variables "${iface}" "${conf}"
+ eval config=( \"\$\{config_${ifvar}\[@\]\}\" )
+ eval fallback_config=( \"\$\{fallback_config_${ifvar}\[@\]\}\" )
+ eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" )
+ config_counter=-1
return 0
fi
veend 1
@@ -112,50 +100,4 @@ arping_gateways() {
return 1
}
-# bool arping_apipa(char *iface)
-#
-# Tries to locate an address in the 169.254.0.0 netmask 169.254.255.255 range
-arping_apipa() {
- local iface="$1" i1 i2 addr i=0
-
- einfo "Searching for free addresses in 169.254.0.0/16"
- eindent
-
- while [[ ${i} -lt 64516 ]]; do
- (( i1=${RANDOM}%255 ))
- (( i2=${RANDOM}%255 ))
-
- addr="169.254.${i1}.${i2}"
- vebegin "${addr}/16"
- if ! address_exists "${iface}" "${addr}" ; then
- config[config_counter]="${addr}/16 broadcast 169.254.255.255"
- (( config_counter-- ))
- veend 0
- eoutdent
- return 0
- fi
-
- (( i++ ))
- done
-
- eerror "No free address found!"
- eoutdent
- return 1
-}
-
-# bool arping_start(char *iface)
-#
-# Tries to detect a config based on arpinging things
-arping_start() {
- local iface="$1"
-
- interface_exists "${iface}" true || return 1
- interface_up "${iface}"
-
- arping_gateways "${iface}" && return 0
- arping_apipa "${iface}" && return 0
-
- return 1
-}
-
# vim:ts=4
diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding
index b1e7dbe..8a9b13f 100644
--- a/net-scripts/net.modules.d/bonding
+++ b/net-scripts/net.modules.d/bonding
@@ -4,19 +4,15 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* bonding_provides(void)
-#
-# Returns a string to change module definition for starting up
-bonding_provides() {
- echo "bonding"
-}
-
# void bonding_depend(void)
#
# Sets up the dependancies for the module
bonding_depend() {
- after interface
- before vlan dhcp arping
+ after interface macnet
+ before vlan dhcp bridge
+ functions interface_exists interface_up interface_down \
+ interface_del_addresses
+ variables slaves
}
# bool bonding_check_installed(void)
@@ -28,21 +24,6 @@ bonding_check_installed() {
return 1
}
-# bool bonding_check_depends(void)
-#
-# Checks to see if we have the needed functions
-bonding_check_depends() {
- local f
-
- for f in interface_exists interface_up interface_down interface_del_addresses; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "bonding: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool bonding_post_start(char *iface)
#
# Bonds the interface
@@ -87,15 +68,13 @@ bonding_pre_start() {
return 0 #important
}
-# bool bonding_pre_stop(void)
+# bool bonding_stop(void)
# Unbonds bonded interfaces
#
# Always returns 0 (true)
-bonding_pre_stop() {
+bonding_stop() {
local iface="$1" slaves s
- bonding_check_installed || return 0
-
# return silently if this is not a bonding interface
[[ ! -f "/proc/net/bonding/${iface}" ]] && return 0
diff --git a/net-scripts/net.modules.d/bridge b/net-scripts/net.modules.d/bridge
index 59f25ee..a44aa9a 100644
--- a/net-scripts/net.modules.d/bridge
+++ b/net-scripts/net.modules.d/bridge
@@ -9,20 +9,14 @@
brctl() {
LC_ALL=C /sbin/brctl "$@"
}
-
-# char* bridge_provides(void)
-#
-# Returns a string to change module definition for starting up
-bridge_provides() {
- echo "bridge"
-}
-
# void bridge_depend(void)
#
# Sets up the dependancies for the module
bridge_depend() {
- after interface tuntap
- before dhcp arping
+ after interface macnet tuntap
+ before dhcp
+ functions interface_down interface_del_addresses interface_set_flag
+ variables bridge bridge_add brctl
}
# bool bridge_check_installed(void)
@@ -34,35 +28,12 @@ bridge_check_installed() {
return 1
}
-# bool bridge_check_depends(void)
-#
-# Checks to see if we have the needed functions
-bridge_check_depends() {
- local f
-
- for f in interface_down interface_del_addresses interface_set_flag; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "bridge: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* bridge_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-bridge_get_vars() {
- echo "bridge_$1 brctl_$1"
-}
-
# char* bridge_get_ports(char *interface)
#
# Returns the interfaces added to the given bridge
bridge_get_ports() {
brctl show 2>/dev/null \
- | sed -n -e '/^'"$1"'/,/^\S/ { /^\('"$1"'\|\t\)/s/^.*\t//p }'
+ | sed -n -e '/^'"$1"'/,/^\S/ { /^\('"$1"'\|\t\)/s/^.*\t//p }'
}
# char* bridge_get_bridge(char *interface)
@@ -192,8 +163,6 @@ bridge_pre_start() {
# Removes the device
# returns 0
bridge_stop() {
- bridge_check_installed || return 0
-
local iface="$1" ports i deletebridge=false extra=""
if bridge_exists "${iface}" ; then
diff --git a/net-scripts/net.modules.d/dhclient b/net-scripts/net.modules.d/dhclient
index 6d31321..72290b1 100644
--- a/net-scripts/net.modules.d/dhclient
+++ b/net-scripts/net.modules.d/dhclient
@@ -10,18 +10,14 @@ dhclient() {
LC_ALL=C /sbin/dhclient "$@"
}
-# char* dhclient_provides(void)
-#
-# Returns a string to change module definition for starting up
-dhclient_provides() {
- echo "dhcp"
-}
-
# void dhclient_depend(void)
#
# Sets up the dependancies for the module
dhclient_depend() {
after interface
+ provide dhcp
+ functions interface_exists interface_get_address
+ variables dhclient dhcp
}
# bool dhclient_check_installed(void)
@@ -33,29 +29,6 @@ dhclient_check_installed() {
return 1
}
-# bool dhclient_check_depends(void)
-#
-# Checks to see if we have the needed functions
-dhclient_check_depends() {
- local f
-
- for f in interface_exists interface_get_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "dhclient: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* dhclient_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-dhclient_get_vars() {
- echo "dhclient_$1 dhcp_$1"
-}
-
# bool dhclient_stop(char *iface)
#
# Stop dhclient on an interface
@@ -64,7 +37,6 @@ dhclient_stop() {
local iface="$1" d
local pidfile="/var/run/dhclient-${iface}.pid"
- dhclient_check_installed || return 0
[[ ! -f ${pidfile} ]] && return 0
# We check for a dhclient process first as if we attempt to release
@@ -148,13 +120,13 @@ dhclient_start() {
# Send our hostname by editing cffile
if ${edit} && [[ -e ${cffile} && ${d} != *" nosendhost "* ]] ; then
- local hostname=$( hostname )
- if [[ ${hostname} != "(none)" && ${hostname} != "localhost" ]]; then
+ local hname=$( hostname )
+ if [[ ${hname} != "(none)" && ${hname} != "localhost" ]]; then
sed -i '/^[ \t]*send[ \t]*host-name[ \t]*/d' "${cffile}"
if [[ -s ${cffile} ]]; then
- sed -i '1 isend host-name "'"${hostname}"'";' "${cffile}"
+ sed -i '1 isend host-name "'"${hname}"'";' "${cffile}"
else
- echo "send host-name \"${hostname}\";" > "${cffile}"
+ echo "send host-name \"${hname}\";" > "${cffile}"
fi
fi
fi
diff --git a/net-scripts/net.modules.d/dhcpcd b/net-scripts/net.modules.d/dhcpcd
index 25e3069..ea50e30 100644
--- a/net-scripts/net.modules.d/dhcpcd
+++ b/net-scripts/net.modules.d/dhcpcd
@@ -10,18 +10,14 @@ dhcpcd() {
LC_ALL=C /sbin/dhcpcd "$@"
}
-# char* dhcpcd_provides(void)
-#
-# Returns a string to change module definition for starting up
-dhcpcd_provides() {
- echo "dhcp"
-}
-
# void dhcpcd_depend(void)
#
# Sets up the dependancies for the module
dhcpcd_depend() {
after interface
+ provide dhcp
+ functions interface_exists interface_get_address
+ variables dhcpcd dhcp
}
# bool dhcpcd_check_installed(void)
@@ -41,21 +37,6 @@ dhcpcd_check_installed() {
return 1
}
-# bool dhcpcd_check_depends(void)
-#
-# Checks to see if we have the needed functions
-dhcpcd_check_depends() {
- local f
-
- for f in interface_exists interface_get_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "dhcpcd: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# char* dhcpcd_get_vars(char *interface)
#
# Returns a string spaced with possible user set
@@ -73,8 +54,6 @@ dhcpcd_get_vars() {
dhcpcd_stop() {
local iface=$1 count signal pidfile="/var/run/dhcpcd-$1.pid" d
- dhcpcd_check_installed || return 0
-
[[ ! -f ${pidfile} ]] && return 0
ebegin "Stopping dhcpcd on ${iface}"
@@ -102,7 +81,7 @@ dhcpcd_stop() {
#
# Returns 0 (true) when a DHCP address is obtained, otherwise 1
dhcpcd_start() {
- local iface="$1" opts hostname pidfile="/var/run/dhcpcd-$1.pid"
+ local iface="$1" opts pidfile="/var/run/dhcpcd-$1.pid"
local ifvar=$( bash_variable "${iface}" ) metric d
interface_exists "${iface}" true || return 1
@@ -120,10 +99,9 @@ dhcpcd_start() {
# We transmit the hostname by default
if [[ ${d} != *" nosendhost "* && ${opts} != *" -h "* ]]; then
- hostname=$( hostname )
- [[ -n ${hostname} && ${hostname} != "(none)" \
- && ${hostname} != "localhost" ]] \
- && opts="-h \"${hostname}\" ${opts}"
+ local hname=$( hostname )
+ [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
+ && opts="-h \"${hname}\" ${opts}"
fi
# Stop dhcpcd from bringing the interface down when we exit
diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet
index 967776b..32f0f3f 100644
--- a/net-scripts/net.modules.d/essidnet
+++ b/net-scripts/net.modules.d/essidnet
@@ -8,44 +8,17 @@
# Load our config if it exists
[[ -f $(add_suffix "/etc/conf.d/wireless" ) ]] \
-&& source $(add_suffix "/etc/conf.d/wireless" )
+ && source $(add_suffix "/etc/conf.d/wireless" )
# void essidnet_depend(void)
#
# Sets up the dependancies for the module
essidnet_depend() {
- before interface
+ before interface system
after wireless
installed wireless
-}
-
-# bool essidnet_check_installed(void)
-#
-# Always returns 0 as we are "installed" by wireless in the depend function
-essidnet_check_installed() {
- return 0
-}
-
-# char* essidnet_provides(void)
-#
-# Returns a string to change module definition for starting up
-essidnet_provides() {
- echo "essidnet"
-}
-
-# bool essidnet_check_depends(void)
-#
-# Checks to see if we have the needed functions
-essidnet_check_depends() {
- local f
-
- for f in wireless_check_extensions wireless_get_essid wireless_get_ap_mac_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "essidnet: missing required function ${f}\n"
- return 1
- done
-
- return 0
+ functions wireless_check_extensions wireless_get_essid \
+ wireless_get_ap_mac_address
}
# bool essidnet_start(char *iface)
diff --git a/net-scripts/net.modules.d/helpers.d/dhcp b/net-scripts/net.modules.d/helpers.d/dhcp
index 3996c1a..133ffae 100755
--- a/net-scripts/net.modules.d/helpers.d/dhcp
+++ b/net-scripts/net.modules.d/helpers.d/dhcp
@@ -102,12 +102,12 @@ fi
# Configure our hostname - but only if we need it
if [[ -n ${hostname} ]]; then
- x=$( /bin/hostname )
- [[ ${x} == "(none)" || ${x} == "localhost" ]] && /bin/hostname "${hostname}"
+ x=$( hostname )
+ [[ ${x} == "(none)" || ${x} == "localhost" ]] && hostname "${hostname}"
fi
[[ ! -d "${statedir}/${interface}" ]] \
-&& mkdir -m 0755 -p "${statedir}/${interface}"
+ && mkdir -m 0755 -p "${statedir}/${interface}"
# Only setup the information we're told to
# By default that's everything
diff --git a/net-scripts/net.modules.d/helpers.d/functions b/net-scripts/net.modules.d/helpers.d/functions
index 5f80d34..3931fb4 100644
--- a/net-scripts/net.modules.d/helpers.d/functions
+++ b/net-scripts/net.modules.d/helpers.d/functions
@@ -508,6 +508,14 @@ process_finished() {
return 1
}
+# bool is_function(char* name)
+#
+# Returns 0 if the given name is a shell function, otherwise 1
+is_function() {
+ [[ -z $1 ]] && return 1
+ [[ $(type -t "$1") == "function" ]]
+}
+
# void function_wrap(char* source, char* target)
#
# wraps function calls - for example function_wrap(this, that)
@@ -515,7 +523,7 @@ process_finished() {
function_wrap() {
local i
- [[ $( type -t "${2}_provides" ) == "function" ]] && return
+ is_function "${2}_depend" && return
for i in $( typeset -f | grep -o '^'"${1}"'_[^ ]*' ); do
eval "${2}${i#${1}}() { ${i} \"\$@\"; }"
@@ -557,21 +565,36 @@ configure_variables() {
local ifvar=$( bash_variable "${iface}" )
for mod in ${MODULES[@]}; do
- func="${mod}_get_vars"
- if [[ $( type -t ${func} ) == "function" ]]; then
- ivars=( $( "${func}" "${ifvar}" ) )
- ovars1=( $( "${func}" "${option1}" ) )
- [[ -n ${option2} ]] && ovars2=( $( "${func}" "${option2}" ) )
- for ((i = 0; i<${#ivars[@]}; i++)); do
- x=""
- [[ -n ${ovars2[i]} ]] && eval x=( \"\$\{${ovars2[i]}\[@\]\}\" )
- [[ -z ${x} ]] && eval x=( \"\$\{${ovars1[i]}\[@\]\}\" )
- [[ -n ${x} ]] && eval "${ivars[i]}=( "\"\$\{x\[@\]\}\"" )"
- done
- fi
+ is_function ${mod}_variables || continue
+ for v in $(${mod}_variables) ; do
+ x=""
+ [[ -n ${option2} ]] && eval x=( \"\$\{${v}_${option2}\[@\]\}\" )
+ [[ -z ${x} ]] && eval x=( \"\$\{${v}_${option1}\[@\]\}\" )
+ [[ -n ${x} ]] && eval "${v}_${ifvar}=( "\"\$\{x\[@\]\}\"" )"
+ done
done
return 0
}
+# Provide a wrapper for hostname if it's not available
+if [[ -z $(type -p hostname) ]]; then
+ hostname() {
+ # Linux and *BSD seem to differ
+ local kernel="kern" ctl="hostname"
+ [[ $(uname) == "Linux" ]] && kernel="kernel"
+
+ if [[ $1 == "-y" || $1 == "--yp" || $1 == "nis" ]]; then
+ ctl="domainname"
+ shift
+ fi
+
+ if [[ -n $1 ]]; then
+ sysctl -q -w "${kernel}.${ctl}=$1"
+ else
+ sysctl -n "${kernel}.${ctl}"
+ fi
+ }
+fi
+
# vim:ts=4
diff --git a/net-scripts/net.modules.d/helpers.d/module-loader b/net-scripts/net.modules.d/helpers.d/module-loader
index f4f5f95..1434bbb 100644
--- a/net-scripts/net.modules.d/helpers.d/module-loader
+++ b/net-scripts/net.modules.d/helpers.d/module-loader
@@ -11,6 +11,15 @@
conf=$(add_suffix "/etc/conf.d/net")
[[ -e ${conf} ]] && source "${conf}"
+# Create some dummy functions, so we can depend on a module
+after() { return; }
+before() { return; }
+need() { return; }
+provide() { return; }
+installed() { return; }
+functions() { return; }
+variables() { eval "${MODULE}_variables() { echo \"$*\"; }"; }
+
# Guess which interface module to load - we prefer iproute2
if [[ -x /sbin/ip ]]; then
interface_module="iproute2"
@@ -34,14 +43,29 @@ MODULES=( "system" )
# Load our modules
. "${MODULES_DIR}/${interface_module}"
+MODULE="interface"
+${interface_module}_depend
function_wrap "${interface_module}" interface
-. "${MODULES_DIR}/macnet"
+
+if [[ -e "${MODULES_DIR}/macnet" ]]; then
+ . "${MODULES_DIR}/macnet"
+ MODULE="macnet"
+ macnet_depend
+fi
+
. "${MODULES_DIR}/system"
+MODULE="system"
+system_depend
if [[ -n ${wireless_module} ]]; then
. "${MODULES_DIR}/${wireless_module}"
+ MODULE="${wireless_module}"
+ ${wireless_module}_depend
function_wrap "${wireless_module}" wireless
. "${MODULES_DIR}/essidnet"
fi
+# Dummy dhcp
+dhcp_variables() { echo "dhcp"; }
+
# vim:ts=4
diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig
index 48a65fb..2f96c29 100644
--- a/net-scripts/net.modules.d/ifconfig
+++ b/net-scripts/net.modules.d/ifconfig
@@ -22,7 +22,9 @@ route() {
#
# Sets up the dependancies for the module
ifconfig_depend() {
- after macnet wireless
+ provide interface
+ variables config routes fallback metric ifconfig \
+ ifconfig_fallback routes inet6 iface alias broadcast netmask
}
# bool ifconfig_check_installed(void)
@@ -34,29 +36,6 @@ ifconfig_check_installed() {
return 1
}
-# char* ifconfig_provides(void)
-#
-# Returns a string to change module definition for starting up
-ifconfig_provides() {
- echo "interface"
-}
-
-# char* ifconfig_module(void)
-#
-# Returns the module name
-# This is needed by dhclient as we run different scripts
-# based on the interface
-ifconfig_module() {
- echo "ifconfig"
-}
-
-# bool ifconfig_check_depends(void)
-#
-# Checks to see if we have the needed functions
-ifconfig_check_depends() {
- return 0
-}
-
# bool ifconfig_exists(char *interface, bool report)
#
# Returns 1 if the interface exists, otherwise 0
@@ -190,18 +169,6 @@ ifconfig_del_addresses() {
return 0
}
-# char* ifconfig_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-ifconfig_get_vars() {
- echo "config_$1 routes_$1 fallback_$1 metric_$1 ifconfig_$1 \
- ifconfig_fallback_$1 routes_$1 inet6_$1 iface_$1 alias_$1 \
- broadcast_$1 netmask_$1"
- # The depreciated gateway var has to be handled by
- # each module if needed
-}
-
# bool ifconfig_get_old_config(char *iface)
#
# Returns config and config_fallback for the given interface
@@ -352,9 +319,9 @@ ifconfig_post_start() {
#
# Adds the given address to the interface
ifconfig_add_address() {
- local iface="$1" i=0 r e
+ local iface="$1" i=0 r e real_iface=$(interface_device "$1")
- ifconfig_exists "${iface}" true || return 1
+ ifconfig_exists "${real_iface}" true || return 1
# Extract the config
local -a config=( "$@" )
@@ -390,18 +357,18 @@ ifconfig_add_address() {
fi
# Ensure that the interface is up so we can add IPv6 addresses
- interface_up "${iface}"
+ interface_up "${real_iface}"
# Some kernels like to apply lo with an address when they are brought up
if [[ ${iface} == "lo" && ${config[@]} == "127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255" ]]; then
ifconfig "${iface}" 0.0.0.0
fi
-
+
ifconfig "${iface}" ${config[@]}
r="$?"
[[ ${r} != "0" ]] && return ${r}
- local metric ifvar=$( bash_variable "${iface}" )
+ local metric ifvar=$(bash_variable "${real_iface}")
# Remove the newly added route and replace with our metric
eval metric=\"\$\{metric_${ifvar}\}\"
[[ ${metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r}
diff --git a/net-scripts/net.modules.d/ifplugd b/net-scripts/net.modules.d/ifplugd
index d7006ea..2d6024c 100644
--- a/net-scripts/net.modules.d/ifplugd
+++ b/net-scripts/net.modules.d/ifplugd
@@ -4,19 +4,14 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* ifplugd_provides(void)
-#
-# Returns a string to change module definition for starting up
-ifplugd_provides() {
- echo "plug"
-}
-
# void ifplugd_depend(void)
#
# Sets up the dependancies for the module
ifplugd_depend() {
- after macnet
+ after macnet rename
before interface
+ functions interface_exists interface_get_mac_address
+ provide plug
}
# bool ifplugd_check_installed(void)
@@ -30,21 +25,6 @@ ifplugd_check_installed() {
return 0
}
-# bool ifplugd_check_depends(void)
-#
-# Checks to see if we have the needed functions
-ifplugd_check_depends() {
- local f
-
- for f in interface_exists interface_get_mac_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "ifplugd: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool ifplugd_pre_start(char *interface)
#
# Start ifplugd on an interface
@@ -72,7 +52,7 @@ ifplugd_pre_start() {
fi
# We don't work on bridges
- if [[ $(type -t bridge_exists) == "function" ]]; then
+ if is_function bridge_exists ; then
if bridge_exists "${iface}"; then
veinfo "netplug does not work on bridges"
return 0
@@ -80,7 +60,7 @@ ifplugd_pre_start() {
fi
# We don't work on tun/tap interfaces
- if [[ $(type -t tuntap_exists) == "function" ]]; then
+ if is_function tuntap_exists ; then
if tuntap_exists "${iface}"; then
veinfo "netplug does not work on tun/tap interfaces"
return 0
@@ -94,7 +74,7 @@ ifplugd_pre_start() {
# Although ifplugd can, we prefer wpa_supplicant, unless explicitly told
# so via our options
if [[ ${opts} != *" -m wlan "* && ${opts} != *" --api-mode=wlan "* ]]; then
- if [[ $(type -t wireless_check_extensions) == "function" ]]; then
+ if is_function wireless_check_extensions ; then
if wireless_check_extensions "${iface}"; then
veinfo "ifplugd does not work on wireless interfaces"
return 0
@@ -144,11 +124,11 @@ ifplugd_pre_start() {
exit 0
}
-# bool ifplugd_post_stop(char *iface)
+# bool ifplugd_stop(char *iface)
#
# Stops ifplugd on an interface
# Returns 0 (true) when successful, non-zero otherwise
-ifplugd_post_stop() {
+ifplugd_stop() {
${IN_BACKGROUND} && return 0
local iface="$1"
local pidfile="/var/run/ifplugd.${iface}.pid"
@@ -157,7 +137,7 @@ ifplugd_post_stop() {
ebegin "Stopping ifplugd on ${iface}"
start-stop-daemon --stop --exec /usr/sbin/ifplugd \
- --pidfile "${pidfile}"
+ --pidfile "${pidfile}" --signal 3
eend $?
}
diff --git a/net-scripts/net.modules.d/ipppd b/net-scripts/net.modules.d/ipppd
index 8f5fc37..5688954 100644
--- a/net-scripts/net.modules.d/ipppd
+++ b/net-scripts/net.modules.d/ipppd
@@ -4,19 +4,15 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* ipppd_provides(void)
-#
-# Returns a string to change module definition for starting up
-ipppd_provides() {
- echo "isdn"
-}
-
# void ipppd_depend(void)
#
# Sets up the dependancies for the module
ipppd_depend() {
after macnet
before interface
+ provide isdn
+ functions interface_exists interface_type clean_pidfile
+ variables ipppd
}
# bool ipppd_check_installed(void)
@@ -28,21 +24,6 @@ ipppd_check_installed() {
return 1
}
-# bool ipppd_check_depends(void)
-#
-# Checks to see if we have the needed functions
-ipppd_check_depends() {
- local f
-
- for f in interface_exists interface_type clean_pidfile; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "ipppd: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool ipppd_start(char *iface)
#
# Start isdn on an interface
@@ -83,7 +64,6 @@ ipppd_pre_start() {
ipppd_stop() {
local iface="$1" pidfile="/var/run/ipppd-$1.pid"
- ipppd_check_installed || return 0
[[ ! -f ${pidfile} ]] && return 0
clean_pidfile "${pidfile}" && return 0
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2
index d069550..62dd92d 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2
@@ -18,7 +18,9 @@ iproute2_tunnel() {
#
# Sets up the dependancies for the module
iproute2_depend() {
- after macnet wireless
+ provide interface
+ functions interface_device
+ variables config routes fallback metric ipaddr ipaddr_fallback iproute inet6
}
# bool iproute2_check_installed(void)
@@ -37,37 +39,6 @@ iproute2_check_installed() {
return "${installed}"
}
-# char* iproute2_provides(void)
-#
-# Returns a string to change module definition for starting up
-iproute2_provides() {
- echo "interface"
-}
-
-# char* iproute2_module(void)
-#
-# Returns the module name
-# This is needed by dhclient as we run different scripts
-# based on the interface
-iproute2_module() {
- echo "iproute2"
-}
-
-# bool iproute2_check_depends(void)
-#
-# Checks to see if we have the needed functions
-iproute2_check_depends() {
- local f
-
- for f in interface_device; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "iproute2: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool iproute2_exists(char *interface, bool report)
#
# Returns 1 if the interface exists, otherwise 0
@@ -172,14 +143,6 @@ iproute2_del_addresses() {
return 0
}
-# char* iproute2_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-iproute2_get_vars() {
- echo "config_$1 routes_$1 fallback_$1 metric_$1 ipaddr_$1 ipaddr_fallback_$1 iproute_$1 inet6_$1"
-}
-
# bool iproute2_get_old_config(char *iface)
#
# Returns config and config_fallback for the given interface
@@ -198,8 +161,11 @@ iproute2_get_old_config() {
[[ -n ${inet6} ]] && config=( "${config[@]}" "${inet6[@]}" )
# Support old style iface_xxx syntax
- [[ -z ${config} && $(type -t ifconfig_get_old_config) == "function" ]] \
- && ifconfig_get_old_config "${iface}"
+ if [[ -z ${config} ]] ; then
+ if is_function ifconfig_get_old_config ; then
+ ifconfig_get_old_config "${iface}"
+ fi
+ fi
return 0
}
diff --git a/net-scripts/net.modules.d/iptunnel b/net-scripts/net.modules.d/iptunnel
index f547a99..572f369 100644
--- a/net-scripts/net.modules.d/iptunnel
+++ b/net-scripts/net.modules.d/iptunnel
@@ -4,49 +4,14 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* iptunnel_provides(void)
-#
-# Returns a string to change module definition for starting up
-iptunnel_provides() {
- echo "iptunnel"
-}
-
# void iptunnel_depend(void)
#
# Sets up the dependancies for the module
iptunnel_depend() {
after wireless
before interface
-}
-
-# bool iptunnel_check_installed(void)
-#
-# Tunnelling is provided by the interface
-iptunnel_check_installed() {
- return 0
-}
-
-# bool iptunnel_check_depends(void)
-#
-# Checks to see if we have the needed functions
-iptunnel_check_depends() {
- local f
-
- for f in interface_exists interface_tunnel; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "iptunnel: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* iptunnel_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-iptunnel_get_vars() {
- echo "iptunnel_$1"
+ functions interface_exists interface_tunnel
+ variables iptunnel
}
# bool iptunnel_pre_start(char *iface)
@@ -62,8 +27,6 @@ iptunnel_pre_start() {
ebegin "Creating tunnel ${iface}"
interface_tunnel add "${iface}" ${opts}
eend "$?"
- return "$?"
-
}
# bool iptunnel_stop(char *iface)
@@ -78,7 +41,6 @@ iptunnel_stop() {
ebegin "Destroying tunnel ${iface}"
interface_tunnel del "${iface}"
eend "$?"
- return "$?"
}
# vim:ts=4
diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig
index 04055eb..7c389b3 100644
--- a/net-scripts/net.modules.d/iwconfig
+++ b/net-scripts/net.modules.d/iwconfig
@@ -27,6 +27,8 @@ iwpriv() {
iwconfig_depend() {
after plug
before interface
+ provide wireless
+ functions interface_up interface_down interface_exists
}
# bool iwconfig_check_installed(void)
@@ -48,28 +50,6 @@ iwconfig_check_installed() {
return 1
}
-# char* iwconfig_provides(void)
-#
-# Returns a string to change module definition for starting up
-iwconfig_provides() {
- echo "wireless"
-}
-
-# bool iwconfig_check_depends(void)
-#
-# Checks to see if we have the needed functions
-iwconfig_check_depends() {
- local f
-
- for f in interface_up interface_down interface_exists; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "iwconfig: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool iwconfig_check_extensions(char *interface)
#
# Checks to see if wireless extensions are enabled on the interface
@@ -355,11 +335,11 @@ iwconfig_associate() {
else
ESSIDVAR=$( bash_variable "${ESSID}" )
key=$( iwconfig_get_wep_key "${mac}" )
- if [[ ${wep_required} == "yes" && ${key} == "off" ]]; then
+ if [[ ${wep_required} == "on" && ${key} == "off" ]]; then
vewarn "WEP key is not set for \"${dessid}\" - not connecting"
return 1
fi
- if [[ ${wep_required} == "no" && ${key} != "off" ]]; then
+ if [[ ${wep_required} == "off" && ${key} != "off" ]]; then
key="off"
vewarn "\"${dessid}\" is not WEP enabled - ignoring setting"
fi
@@ -383,7 +363,7 @@ iwconfig_associate() {
vebegin "Connecting to \"${dessid}\" ${w}"
- if [[ ${ESSID} != "any" && $( type -t preassociate ) == "function" ]]; then
+ if [[ ${ESSID} != "any" ]] && is_function preassociate ; then
veinfo "Running preassociate function"
eindent
( preassociate "${iface}" )
@@ -410,7 +390,7 @@ iwconfig_associate() {
iwconfig_user_config "${iface}"
iwconfig_report "${iface}"
- if [[ $( type -t postassociate ) == "function" ]]; then
+ if is_function postassociate ; then
veinfo "Running postassociate function"
eindent
( postassociate "${iface}" )
@@ -457,7 +437,7 @@ iwconfig_scan() {
veinfo "Scanning for access points"
# Sleep if required
- eval x=\"\$\{sleep_scan_${ifvar}\}\"
+ eval x=\"\$\{sleep_scan_${ifvar}\:-1}\"
[[ -n ${x} ]] && sleep "${x}"
local error=true i=-1 line
diff --git a/net-scripts/net.modules.d/macchanger b/net-scripts/net.modules.d/macchanger
index 7cc2c5b..7096a2a 100644
--- a/net-scripts/net.modules.d/macchanger
+++ b/net-scripts/net.modules.d/macchanger
@@ -4,41 +4,13 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* macchanger_provides(void)
-#
-# Returns a string to change module definition for starting up
-macchanger_provides() {
- echo "macchanger"
-}
-
# void macchanger_depend(void)
#
# Sets up the dependancies for the module
macchanger_depend() {
before macnet
-}
-
-# bool macchanger_check_installed(void)
-#
-# macchanger is always installed as an interface can change to a specific
-# mac address, and an interface is always installed
-macchanger_check_installed() {
- return 0
-}
-
-# bool macchanger_check_depends(void)
-#
-# Checks to see if we have the needed functions
-macchanger_check_depends() {
- local f
-
- for f in interface_get_mac_address interface_set_mac_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "macchanger: missing required function ${f}\n"
- return 1
- done
-
- return 0
+ functions interface_get_mac_address interface_set_mac_address
+ variables mac
}
# bool macchanger_pre_start(char *iface)
diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet
index 3ab8cd1..5ef8f30 100644
--- a/net-scripts/net.modules.d/macnet
+++ b/net-scripts/net.modules.d/macnet
@@ -10,37 +10,10 @@
#
# Sets up the dependancies for the module
macnet_depend() {
- before interface wireless
- after macchanger
-}
-
-# bool macnet_check_installed(void)
-#
-# Always returns 0 as we are "installed" by wireless in the depend function
-macnet_check_installed() {
- return 0
-}
-
-# char* macnet_provides(void)
-#
-# Returns a string to change module definition for starting up
-macnet_provides() {
- echo "macnet"
-}
-
-# bool macnet_check_depends(void)
-#
-# Checks to see if we have the needed functions
-macnet_check_depends() {
- local f
-
- for f in interface_get_mac_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "macnet: missing required function ${f}\n"
- return 1
- done
-
- return 0
+ before rename interface wireless
+ after macchanger
+ installed macchanger
+ functions interface_get_mac_address
}
# bool macnet_start(char *iface)
diff --git a/net-scripts/net.modules.d/netplugd b/net-scripts/net.modules.d/netplugd
index 2307a17..966b5da 100644
--- a/net-scripts/net.modules.d/netplugd
+++ b/net-scripts/net.modules.d/netplugd
@@ -4,19 +4,14 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* netplugd_provides(void)
-#
-# Returns a string to change module definition for starting up
-netplugd_provides() {
- echo "plug"
-}
-
# void netplugd_depend(void)
#
# Sets up the dependancies for the module
netplugd_depend() {
- after macnet
+ after macnet rename
before interface
+ provide plug
+ functions interface_exists interface_get_mac_address
}
# bool netplugd_check_installed(void)
@@ -30,21 +25,6 @@ netplugd_check_installed() {
return 0
}
-# bool netplugd_check_depends(void)
-#
-# Checks to see if we have the needed functions
-netplugd_check_depends() {
- local f
-
- for f in interface_exists interface_get_mac_address ; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "netplugd: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool netplugd_pre_start(char *interface)
#
# Start netplug on an interface
@@ -66,7 +46,7 @@ netplugd_pre_start() {
fi
# We don't work on bridges
- if [[ $(type -t bridge_exists) == "function" ]]; then
+ if is_function bridge_exists ; then
if bridge_exists "${iface}"; then
veinfo "netplug does not work on bridges"
return 0
@@ -74,7 +54,7 @@ netplugd_pre_start() {
fi
# We don't work on tun/tap interfaces
- if [[ $(type -t tuntap_exists) == "function" ]]; then
+ if is_function tuntap_exists ; then
if tuntap_exists "${iface}"; then
veinfo "netplug does not work on tun/tap interfaces"
return 0
@@ -82,7 +62,7 @@ netplugd_pre_start() {
fi
# We don't work on wirelesss interfaces
- if [[ $(type -t wireless_check_extensions) == "function" ]]; then
+ if is_function wireless_check_extensions ; then
if wireless_check_extensions "${iface}"; then
veinfo "netplug does not work on wireless interfaces"
return 0
@@ -131,11 +111,11 @@ netplugd_pre_start() {
exit 0
}
-# bool netplugd_post_stop(char *iface)
+# bool netplugd_stop(char *iface)
#
# Stops netplug on an interface
# Returns 0 (true) when successful, non-zero otherwise
-netplugd_post_stop() {
+netplugd_stop() {
${IN_BACKGROUND} && return 0
local iface="$1"
local pidfile="/var/run/netplugd.${iface}.pid"
diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd
index a9017a4..fb0e15e 100644
--- a/net-scripts/net.modules.d/pppd
+++ b/net-scripts/net.modules.d/pppd
@@ -2,19 +2,13 @@
# Copyright (c) 2004-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# char* pppd_provides(void)
-#
-# Returns a string to change module definition for starting up
-pppd_provides() {
- echo "ppp"
-}
-
# void pppd_depend(void)
#
# Sets up the dependancies for the module
pppd_depend() {
after interface
before dhcp
+ provide ppp
}
# bool pppd_check_installed(void)
@@ -28,13 +22,6 @@ pppd_check_installed() {
return 0
}
-# bool pppd_check_depends(void)
-#
-# Checks to see if we have the needed functions
-pppd_check_depends() {
- return 0
-}
-
# char *pppd_regex_escape(char *string)
#
# Returns the supplied string with any special regex
diff --git a/net-scripts/net.modules.d/pump b/net-scripts/net.modules.d/pump
index 95eb61a..69eb675 100644
--- a/net-scripts/net.modules.d/pump
+++ b/net-scripts/net.modules.d/pump
@@ -10,18 +10,14 @@ pump() {
LC_ALL=C /sbin/pump "$@"
}
-# char* pump_provides(void)
-#
-# Returns a string to change module definition for starting up
-pump_provides() {
- echo "dhcp"
-}
-
# void pump_depend(void)
#
# Sets up the dependancies for the module
pump_depend() {
after interface
+ provide dhcp
+ functions interface_exists interface_get_address
+ variables pump dhcp
}
# bool pump_check_installed(void)
@@ -33,29 +29,6 @@ pump_check_installed() {
return 1
}
-# bool pump_check_depends(void)
-#
-# Checks to see if we have the needed functions
-pump_check_depends() {
- local f
-
- for f in interface_exists interface_get_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "pump: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* pump_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-pump_get_vars() {
- echo "pump_$1 dhcp_$1"
-}
-
# bool pump_stop(char *iface)
#
# Stop pump on an interface
@@ -64,8 +37,6 @@ pump_get_vars() {
pump_stop() {
local iface="$1" count e
- pump_check_installed || return 0
-
# We check for a pump process first as querying for status
# causes pump to spawn a process
pidof /sbin/pump &>/dev/null || return 0
diff --git a/net-scripts/net.modules.d/rename b/net-scripts/net.modules.d/rename
index ddab8b0..2e531b1 100644
--- a/net-scripts/net.modules.d/rename
+++ b/net-scripts/net.modules.d/rename
@@ -4,41 +4,14 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* rename_provides(void)
-#
-# Returns a string to change module definition for starting up
-rename_provides() {
- echo "rename"
-}
-
# void rename_depend(void)
#
# Sets up the dependancies for the module
rename_depend() {
- after macchanger macnet
+ after macchanger
before wireless interface
-}
-
-# bool rename_check_installed(void)
-#
-# We are always installed
-rename_check_installed() {
- return 0
-}
-
-# bool rename_check_depends(void)
-#
-# Checks to see if we have the needed functions
-rename_check_depends() {
- return 0
-}
-
-# char* rename_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-rename_get_vars() {
- echo "rename_$1"
+ functions interface_exists interface_down interface_del_addresses
+ variables rename
}
# bool rename_pre_start(char *iface)
diff --git a/net-scripts/net.modules.d/system b/net-scripts/net.modules.d/system
index c8bd0ff..ec5f028 100644
--- a/net-scripts/net.modules.d/system
+++ b/net-scripts/net.modules.d/system
@@ -6,36 +6,9 @@
#
# Sets up the dependancies for the module
system_depend() {
- after interface essidnet
- before dhcp
-}
-
-# bool system_check_installed(void)
-#
-# Always returns 0 as we are writing to files
-system_check_installed() {
- return 0
-}
-
-# char* system_provides(void)
-#
-# Returns a string to change module definition for starting up
-system_provides() {
- echo "system"
-}
-
-# bool system_check_depends(void)
-#
-# Checks to see if we have the needed functions
-system_check_depends() {
- return 0
-}
-
-# char* ifconfig_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set configuration variables
-system_get_vars() {
- echo "dns_servers_$1 dns_domain_$1 dns_options_$1 dns_search_$1 dns_sortlist_$1 ntp_servers_$1 nis_domain_$1 nis_servers_$1"
+ after interface dhcp
+ variables dns_servers dns_domain dns_options dns_search dns_sortlist \
+ ntp_servers nis_domain nis_servers
}
system_dns_extra() {
@@ -128,7 +101,7 @@ system_nis() {
chmod 644 "${tmpfile}"
if [[ -n ${domain} ]]; then
- /bin/hostname -y "${domain}"
+ hostname -y "${domain}"
if [[ -n ${servers} ]]; then
for x in ${servers}; do
echo "domain ${domain} server ${x}" >> "${tmpfile}"
@@ -149,7 +122,7 @@ system_nis() {
#
# Configures the host system for dns, ntp and nis information
# Always returns 0
-system_pre_start() {
+system_post_start() {
local iface="$1"
system_dns "${iface}"
diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap
index eea33db..1cbc621 100644
--- a/net-scripts/net.modules.d/tuntap
+++ b/net-scripts/net.modules.d/tuntap
@@ -10,19 +10,14 @@ tunctl() {
LC_ALL=C /usr/bin/tunctl "$@"
}
-# char* tuntap_provides(void)
-#
-# Returns a string to change module definition for starting up
-tuntap_provides() {
- echo "tuntap"
-}
-
# void tuntap_depend(void)
#
# Sets up the dependancies for the module
tuntap_depend() {
- after interface
+ after interface macnet
before dhcp
+ functions interface_exists interface_type
+ variables tunctl
}
# bool tuntap_check_installed(void)
@@ -34,21 +29,6 @@ tuntap_check_installed() {
return 1
}
-# bool tuntap_check_depends(void)
-#
-# Checks to see if we have the needed functions
-tuntap_check_depends() {
- local f
-
- for f in interface_exists interface_type; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "tuntap: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool tuntap_check_kernel(void)
#
# Checks to see if the tun is present - if not try and load it
@@ -61,14 +41,6 @@ tuntap_check_kernel() {
return 1
}
-# char* tuntap_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-tuntap_get_vars() {
- echo "tunctl_$1"
-}
-
# bool tuntap_exists(char *interface)
#
# Returns 0 if the tun/tap interface exists, otherwise 1
diff --git a/net-scripts/net.modules.d/udhcpc b/net-scripts/net.modules.d/udhcpc
index 25596c5..131231e 100644
--- a/net-scripts/net.modules.d/udhcpc
+++ b/net-scripts/net.modules.d/udhcpc
@@ -10,18 +10,14 @@ udhcpc() {
LC_ALL=C /sbin/udhcpc "$@"
}
-# char* udhcpc_provides(void)
-#
-# Returns a string to change module definition for starting up
-udhcpc_provides() {
- echo "dhcp"
-}
-
# void udhcpc_depend(void)
#
# Sets up the dependancies for the module
udhcpc_depend() {
after interface
+ provide dhcp
+ functions interface_exists interface_get_address
+ variables udhcpc dhcp
}
# bool udhcpc_check_installed(void)
@@ -33,29 +29,6 @@ udhcpc_check_installed() {
return 1
}
-# bool udhcpc_check_depends(void)
-#
-# Checks to see if we have the needed functions
-udhcpc_check_depends() {
- local f
-
- for f in interface_exists interface_get_address; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "udhcpc: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* udhcpc_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-udhcpc_get_vars() {
- echo "udhcpc_$1 dhcp_$1"
-}
-
# bool udhcpc_stop(char *iface)
#
# Stops udhcpc running on an interface
@@ -63,7 +36,6 @@ udhcpc_get_vars() {
udhcpc_stop() {
local iface="$1" pidfile="/var/run/udhcpc-$1.pid" d
- udhcpc_check_installed || return 0
[[ ! -f ${pidfile} ]] && return 0
ebegin "Stopping udhcpc on ${iface}"
@@ -99,7 +71,7 @@ udhcpc_start() {
interface_exists "${iface}" true || return 1
- local ifvar=$( bash_variable "${iface}" ) opts hostname
+ local ifvar=$( bash_variable "${iface}" ) opts
eval opts=\"\$\{udhcpc_${ifvar}\}\"
eval d=\" \$\{dhcp_${ifvar}\} \"
@@ -107,10 +79,9 @@ udhcpc_start() {
if [[ ${d} != *" nosendhost "* ]]; then
if [[ ! " ${opts}" =~ " -([hH] |-hostname=)" ]]; then
- local hostname=$( hostname )
- [[ -n ${hostname} && ${hostname} != "(none)" \
- && ${hostname} != "localhost" ]] \
- && opts="${opts} --hostname=${hostname}"
+ local hname=$( hostname )
+ [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
+ && opts="${opts} --hostname=${hname}"
fi
fi
@@ -124,7 +95,8 @@ udhcpc_start() {
if [[ -f ${cachefile} ]]; then
if [[ " ${opts}" != *" --request="* && " ${opts} " != *" -r "* ]]; then
local x=$( < "${cachefile}" )
- [[ -n ${x} ]] && opts="${opts} --request=${x}"
+ # Check for a valid ip
+ [[ ${x} == *.*.*.* ]] && opts="${opts} --request=${x}"
fi
fi
@@ -136,9 +108,9 @@ udhcpc_start() {
fi
x=$( eval udhcpc ${opts} --now --pidfile="${pidfile}" \
- --interface="${iface}" \
- --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" 2>&1 \
- | egrep -v '^info,' )
+ --interface="${iface}" \
+ --script="${MODULES_DIR}/helpers.d/udhcpc-wrapper" 2>&1 \
+ | egrep -v '^info,' )
# We just check the last 5 letters
[[ ${x:((${#x} - 5)):5} == "bound" ]]
eend "$?" "${x}" || return 1
diff --git a/net-scripts/net.modules.d/vlan b/net-scripts/net.modules.d/vlan
index a1966d5..859e6dd 100644
--- a/net-scripts/net.modules.d/vlan
+++ b/net-scripts/net.modules.d/vlan
@@ -10,19 +10,14 @@ vconfig() {
LC_ALL=C /sbin/vconfig "$@"
}
-# char* vlan_provides(void)
-#
-# Returns a string to change module definition for starting up
-vlan_provides() {
- echo "vlan"
-}
-
# void vlan_depend(void)
#
# Sets up the dependancies for the module
vlan_depend() {
after interface
- before dhcp arping
+ before dhcp
+ functions iface_start iface_stop
+ variables vlans
}
# bool vlan_check_installed(void)
@@ -34,36 +29,13 @@ vlan_check_installed() {
return 1
}
-# bool vlan_check_depends(void)
-#
-# Checks to see if we have the needed functions
-vlan_check_depends() {
- local f
-
- for f in iface_start iface_stop; do
- [[ $( type -t "${f}" ) == function ]] && continue
- eerror "vlan: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
-# char* vlan_get_vars(char *interface)
-#
-# Returns a string spaced with possible user set
-# configuration variables
-vlan_get_vars() {
- echo "vlans_$1 iface_$1_vlans"
-}
-
# char* vlan_get_vlans(char *interface)
#
# Fetch the configured vlans for an interface. Outputs a space
# separated list on stdout. For example "eth0.1 eth0.2 eth0.3"
vlan_get_vlans() {
sed -n -e 's/^\(.*[0-9]\) \(.* \) .*'"$1"'$/\1/p' \
- /proc/net/vlan/config 2>/dev/null
+ /proc/net/vlan/config 2>/dev/null
}
# bool vlan_check_kernel(void)
@@ -147,12 +119,12 @@ vlan_post_start() {
return 0
}
-# bool vlan_pre_stop(char *iface)
+# bool vlan_stop(char *iface)
#
# Stops VLANs for a given interface
#
# Always returns 0 (true)
-vlan_pre_stop() {
+vlan_stop() {
local iface="$1" vlan
vlan_check_installed || return 0
diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant
index c03774d..24e432a 100644
--- a/net-scripts/net.modules.d/wpa_supplicant
+++ b/net-scripts/net.modules.d/wpa_supplicant
@@ -14,19 +14,14 @@ wpa_cli() {
LC_ALL=C /bin/wpa_cli "$@"
}
-# char* wpa_supplicant_provides(void)
-#
-# Returns a string to change module definition for starting up
-wpa_supplicant_provides() {
- echo "wireless"
-}
-
# void wpa_supplicant_depend(void)
#
# Sets up the dependancies for the module
wpa_supplicant_depend() {
after macnet plug
before interface
+ provide wireless
+ functions interface_exists
}
# bool wpa_supplicant_check_installed(void)
@@ -48,21 +43,6 @@ wpa_supplicant_check_installed() {
return "${installed}"
}
-# bool wpa_supplicant_check_depends(void)
-#
-# Checks to see if we have the needed functions
-wpa_supplicant_check_depends() {
- local f
-
- for f in interface_exists; do
- [[ $( type -t "${f}" ) == "function" ]] && continue
- eerror "wpa_supplicant: missing required function ${f}\n"
- return 1
- done
-
- return 0
-}
-
# bool wpa_supplicant_check_extensions(char *interface)
#
# Checks to see if wireless extensions are enabled on the interface
@@ -126,7 +106,8 @@ wpa_supplicant_kill() {
pidfile="/var/run/wpa_cli-${iface}.pid"
if ! clean_pidfile "${pidfile}" ; then
${report} && ebegin "Stopping wpa_cli on ${iface}"
- start-stop-daemon --stop --exec /bin/wpa_cli --pidfile "${pidfile}"
+ start-stop-daemon --stop --exec /bin/wpa_cli \
+ --pidfile "${pidfile}"
${report} && eend "$?"
fi
@@ -135,7 +116,7 @@ wpa_supplicant_kill() {
if ! clean_pidfile "${pidfile}" ; then
${report} && ebegin "Stopping wpa_supplicant on ${iface}"
start-stop-daemon --stop --exec /sbin/wpa_supplicant \
- --pidfile "${pidfile}"
+ --pidfile "${pidfile}"
${report} && eend "$?"
else
# Support wpa_supplicant-0.3.x
@@ -149,7 +130,7 @@ wpa_supplicant_kill() {
# If wpa_supplicant exits uncleanly, we need to remove the stale dir
[[ -S "/var/run/wpa_supplicant/${iface}" ]] \
- && rm -f "/var/run/wpa_supplicant/${iface}"
+ && rm -f "/var/run/wpa_supplicant/${iface}"
}
# bool wpa_supplicant_associate(char *interface)
@@ -206,7 +187,8 @@ 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 iface="$1" opts timeout action=false
+ local cfgfile="/etc/wpa_supplicant.conf"
local actfile="/sbin/wpa_cli.action"
# We don't configure wireless if we're being called from
@@ -226,6 +208,8 @@ wpa_supplicant_pre_start() {
local ifvar=$( bash_variable "${iface}" )
eval opts=\" \$\{wpa_supplicant_${ifvar}\} \"
+ [[ ${opts} != *" -D"* ]] \
+ && ewarn "wpa_supplicant_${ifvar} does not define a driver"
# We only work on wirelesss interfaces unless a driver for wired
# has been defined
@@ -237,9 +221,6 @@ wpa_supplicant_pre_start() {
fi
fi
- [[ ${opts} != *" -D"* ]] \
- && ewarn "wpa_supplicant_${ifvar} does not define a driver"
-
# 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
@@ -252,7 +233,7 @@ wpa_supplicant_pre_start() {
# If wireless-tools is installed, try and apply our user config
# This is needed for some drivers - such as hostap because they start
# the card in Master mode which causes problems with wpa_supplicant.
- if [[ $( type -t iwconfig_defaults ) == "function" ]]; then
+ if is_function iwconfig_defaults ; then
if wpa_supplicant_check_extensions "${iface}" ; then
iwconfig_defaults "${iface}"
iwconfig_user_config "${iface}"
@@ -261,15 +242,6 @@ wpa_supplicant_pre_start() {
ebegin "Starting wpa_supplicant on ${iface}"
- cfgfile="${opts##* -c}"
- if [[ -n ${cfgfile} && ${cfgfile} != "${opts}" ]]; then
- [[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}"
- cfgfile="${cfgfile%% *}"
- else
- cfgfile="/etc/wpa_supplicant.conf"
- opts="${opts} -c/etc/wpa_supplicant.conf"
- fi
-
if [[ ! -f ${cfgfile} ]]; then
eend 1 "configuration file ${cfgfile} not found!"
return 1
@@ -303,8 +275,7 @@ wpa_supplicant_pre_start() {
fi
start-stop-daemon --start --exec /sbin/wpa_supplicant \
- --pidfile "/var/run/wpa_supplicant-${iface}.pid" \
- -- ${opts} -B -i"${iface}"
+ -- ${opts} -B -c/etc/wpa_supplicant.conf -i"${iface}"
eend "$?" || return 1
# Starting wpa_supplication-0.4.0, we can get wpa_cli to
@@ -313,7 +284,6 @@ wpa_supplicant_pre_start() {
mark_service_inactive "net.${iface}"
ebegin "Starting wpa_cli on ${iface}"
start-stop-daemon --start --exec /bin/wpa_cli \
- --pidfile "/var/run/wpa_cli-${iface}.pid" \
-- -a"${actfile}" -i"${iface}" \
-P"/var/run/wpa_cli-${iface}.pid" -B
eend "$?" || return 1