summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-04-08 15:00:41 +0000
committerChristian Heim <phreak@gentoo.org>2006-04-08 15:00:41 +0000
commit05cacd0f8d0be34f24e55fd9bf80ade251f8aaec (patch)
tree545d503657e435e1abe59af5729a101d14c7340b
parentMerging net-scripts changes; fixing ChangeLog's (diff)
downloadbaselayout-vserver-05cacd0f8d0be34f24e55fd9bf80ade251f8aaec.tar.gz
baselayout-vserver-05cacd0f8d0be34f24e55fd9bf80ade251f8aaec.tar.bz2
baselayout-vserver-05cacd0f8d0be34f24e55fd9bf80ade251f8aaec.zip
Merging r1965
svn path=/baselayout-vserver/branches/baselayout-1_12/; revision=315
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.vserver19
-rw-r--r--net-scripts/conf.d/net.example9
-rwxr-xr-xnet-scripts/init.d/net.lo92
-rw-r--r--net-scripts/net.modules.d/bridge.sh2
-rw-r--r--net-scripts/net.modules.d/iptunnel.sh3
-rw-r--r--net-scripts/net.modules.d/iwconfig.sh3
-rw-r--r--net-scripts/net.modules.d/tuntap.sh4
-rw-r--r--net-scripts/net.modules.d/udhcpc.sh5
-rw-r--r--net-scripts/net.modules.d/wpa_supplicant.sh2
-rwxr-xr-xsbin/rc8
-rwxr-xr-xsbin/runscript.sh11
-rwxr-xr-xtarball.sh2
13 files changed, 89 insertions, 82 deletions
diff --git a/ChangeLog b/ChangeLog
index 22b9a76..c02fe88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,18 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+* baselayout-1.12.0_pre17 (08 Apr 2006)
+
+ 07 Apr 2006; Roy Marples <uberlord@gentoo.org>:
+
+ net modules now apply their own metric if they are activated, which makes
+ for a much easier and less mesy calculation.
+
05 Apr 2006; Roy Marples <uberlord@gentoo.org>:
runscript.sh now stores the fact that it failed to to /dev/.rcsysinit
- existing in the directory /dev/.rcafterinit. rc adds services in
- /dev/.rcafterinit to the boot list and then rm -f's that directory. This
+ existing in the directory /dev/.rcboot. rc adds services in
+ /dev/.rcboot to the boot list and then rm -f's that directory. This
solves the issue of udev-089 forcing coldplug removal.
03 Apr 2006; Roy Marples <uberlord@gentoo.org>:
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index f4854f4..79e915b 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,25 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 08 Apr 2006; Christian Heim <phreak@gentoo.org>:
+ Merging latest changes to the baselayout-1_12 branch. This merge is based
+ upon revision 1965. Preparing baselayout-vserver-1.12.0_pre17!
+
+ ChangeLog | 11 +-
+ ChangeLog.vserver | 19 +++
+ net-scripts/conf.d/net.example | 9 -
+ net-scripts/init.d/net.lo | 88 ++++++------------
+ net-scripts/net.modules.d/bridge.sh | 2
+ net-scripts/net.modules.d/iptunnel.sh | 3
+ net-scripts/net.modules.d/iwconfig.sh | 3
+ net-scripts/net.modules.d/tuntap.sh | 4
+ net-scripts/net.modules.d/udhcpc.sh | 5 -
+ net-scripts/net.modules.d/wpa_supplicant.sh | 2
+ sbin/rc | 8 -
+ sbin/runscript.sh | 11 +-
+ tarball.sh | 2
+ 13 files changed, 87 insertions(+), 80 deletions(-)
+
07 Apr 2006; Christian Heim <phreak@gentoo.org>:
Merging latest changes to the baselayout-1_12 branch. This merge is based
upon revision 1959.
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index 5f6feaa..9521449 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -21,15 +21,6 @@
# read through the rest of this file.
##############################################################################
-# DEFAULTS
-#
-# hotplug_eth0="yes"
-# Do we allow hotplug to bring up interfaces or not? The default is we do,
-# otherwise put no in the above value.
-# NOTE: hotplug just has to be installed for hotplugging to work - it does
-# not matter if it's in any runlevel or not.
-
-##############################################################################
# MODULES
#
# We now support modular networking scripts which means we can easily
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index 4734a59..da12257 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -75,13 +75,12 @@ interface_type() {
echo "${1%%[0-9]*}"
}
-# int calculate_metric(char *interface)
+# int calculate_metric(char *interface, int base)
#
# Calculates the best metric for the interface
-# The Linux kernel does not use this at the moment, but we use it so that
-# default routes remain and we can work out the "best" interface
+# We use this when we add routes so we can prefer interfaces over each other
calculate_metric() {
- local iface="$1" exclude='$1!="Iface" && $1!="lo"'
+ local iface="$1" metric="$2"
# Have we already got a metric?
local m="$( awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \
@@ -91,43 +90,27 @@ calculate_metric() {
return 0
fi
- local itype="$(interface_type "${iface}")" x i
-
- # If we're not a wireless device then exclude wireless from the
- # routing table so we stay < 1000
- if [[ -e /proc/net/wireless ]] ; then
- if ! grep -q "^[ \t]*${iface}:[ \t]" /proc/net/wireless ; then
- local i="$(sed -n -e 's/^[ \t]*\(.*\):.*/\1/p' /proc/net/wireless)"
- for x in ${i} ; do
- exclude="${exclude} && "'$1'"!=\"${x}\""
- done
- fi
- fi
-
- # Exclude ppp and ippp as well
- local ix="ppp|ippp"
- [[ ${itype} == "ppp" ]] && ix="ippp"
- [[ ${itype} == "ippp" ]] && ix="ppp"
- i="$( sed -n -e 's/^[ ]*\('"${ix}"'[0-9]*\):.*$/\1/p' /proc/net/dev )"
- for x in ${i} ; do
- exclude="${exclude} && "'$1'"!=\"${x}\""
+ local i= dest= gw= flags= ref= u= m= mtu= metrics=
+ while read i dest gw flags ref u m mtu ; do
+ # Ignore lo
+ is_loopback "${i}" && continue
+ # We work out metrics from default routes only
+ [[ ${dest} != "00000000" || ${gw} == "00000000" ]] && continue
+ metrics="${metrics}\n${m}"
+ done < /proc/net/route
+
+ # Now, sort our metrics
+ metrics="$(echo -e "${metrics}" | sort -n)"
+
+ # Now, find the lowest we can use
+ local gotbase=false
+ for m in ${metrics} ; do
+ [[ ${m} -lt ${metric} ]] && continue
+ [[ ${m} == ${metric} ]] && ((metric++))
+ [[ ${m} -gt ${metric} ]] && break
done
-
- local m="$( awk "${exclude} { print "'$7'" }" /proc/net/route \
- | sort -rn | head -n 1 | cut -d' ' -f2 )"
- m="${m:--1}"
- (( m ++ ))
-
- # If we're a wireless device then add 1000 so that wired interfaces take preference
- if [[ -e /proc/net/wireless ]] ; then
- grep -q "^[ \t]*${iface}:[ \t]" /proc/net/wireless && (( m+= 1000 ))
- fi
-
- # If we're a ppp device then we add 2000 for ISDN, otherwise 3000
- [[ ${itype} == "ippp" ]] && (( m+= 2000 ))
- [[ ${itype} == "ppp" ]] && (( m+= 3000 ))
-
- echo "${m}"
+
+ echo "${metric}"
}
# int netmask2cidr(char *netmask)
@@ -672,13 +655,7 @@ iface_start() {
local iface="$1" mod config_counter="-1" x config_worked=false
local RC_INDENTATION="${RC_INDENTATION}"
local -a config fallback fallback_route conf a b
- local ifvar="$(bash_variable "$1")" i j
-
- # Try and work out a metric for the interface
- x="metric_${ifvar}"
- if [[ -z ${!x} ]] ; then
- eval "metric_${ifvar}=\"$(calculate_metric ${iface})\""
- fi
+ local ifvar="$(bash_variable "$1")" i j metric=0
# pre Start any modules with
for mod in ${MODULES[@]}; do
@@ -687,6 +664,14 @@ iface_start() {
fi
done
+ x="metric_${ifvar}"
+ # If we don't have a metric then calculate one
+ # Our modules will set the metric variable to a suitable base
+ # in their pre starts.
+ if [[ -z ${!x} ]] ; then
+ eval "metric_${ifvar}=\"$(calculate_metric "${iface}" "${metric}")\""
+ fi
+
# We now expand the configuration parameters and pray that the
# fallbacks expand to the same number as config or there will be
# trouble!
@@ -1101,19 +1086,6 @@ run() {
# which localises variables and unsets functions
start() {
declare -r IFACE="${SVCNAME#*.}"
- 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}")"
- x="hotplug_${ifvar}"
- if [[ ${!x} == "no" || ${!x} == "false" ]] ; then
- eerror "Not starting interface ${IFACE} due to hotplug policy"
- unset -f exit
- mark_service_stopped "net.${IFACE}"
- exit 1
- fi
- fi
-
einfo "Starting ${IFACE}"
run "${IFACE}" start
}
diff --git a/net-scripts/net.modules.d/bridge.sh b/net-scripts/net.modules.d/bridge.sh
index cf6e605..67af002 100644
--- a/net-scripts/net.modules.d/bridge.sh
+++ b/net-scripts/net.modules.d/bridge.sh
@@ -136,6 +136,8 @@ bridge_pre_start() {
iface="${!briface}"
else
ports="${!ports}"
+ # We are the bridge, so set our base metric to 1000.
+ metric=1000
fi
# Create the bridge if needed
diff --git a/net-scripts/net.modules.d/iptunnel.sh b/net-scripts/net.modules.d/iptunnel.sh
index 860f9aa..3a3568d 100644
--- a/net-scripts/net.modules.d/iptunnel.sh
+++ b/net-scripts/net.modules.d/iptunnel.sh
@@ -27,6 +27,9 @@ iptunnel_pre_start() {
eval opts="iptunnel_${ifvar}"
[[ -z ${!opts} ]] && return 0
+ # Set our base metric to 1000
+ metric=1000
+
ebegin "Creating tunnel ${iface}"
interface_tunnel add "${iface}" ${!opts}
eend "$?"
diff --git a/net-scripts/net.modules.d/iwconfig.sh b/net-scripts/net.modules.d/iwconfig.sh
index f19afb2..6cca973 100644
--- a/net-scripts/net.modules.d/iwconfig.sh
+++ b/net-scripts/net.modules.d/iwconfig.sh
@@ -898,6 +898,9 @@ iwconfig_pre_start() {
return 0
fi
+ # Set the base metric to be 2000
+ metric=2000
+
# 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
diff --git a/net-scripts/net.modules.d/tuntap.sh b/net-scripts/net.modules.d/tuntap.sh
index dc40523..597cb12 100644
--- a/net-scripts/net.modules.d/tuntap.sh
+++ b/net-scripts/net.modules.d/tuntap.sh
@@ -62,6 +62,10 @@ tuntap_pre_start() {
tuntap_check_kernel || return 1
ebegin "Creating Tun/Tap interface ${iface}"
+
+ # Set the base metric to 1000
+ metric=1000
+
if [[ -x /usr/sbin/openvpn ]] ; then
openvpn --mktun --dev-type "${!tuntap}" --dev "${iface}" \
> /dev/null
diff --git a/net-scripts/net.modules.d/udhcpc.sh b/net-scripts/net.modules.d/udhcpc.sh
index 3c646fe..07ab6cf 100644
--- a/net-scripts/net.modules.d/udhcpc.sh
+++ b/net-scripts/net.modules.d/udhcpc.sh
@@ -128,8 +128,9 @@ udhcpc_start() {
eval start-stop-daemon --start --exec /sbin/udhcpc \
--pidfile "${pidfile}" \
- -- "${opts}" --interface="${iface}" --now --quiet \
- --pidfile="${pidfile}"
+ -- "${opts}" --interface="${iface}" --now \
+ --script=/lib/rcscripts/sh/udhcpc.sh \
+ --pidfile="${pidfile}" >/dev/null
eend $? || return 1
# DHCP succeeded, show address retrieved
diff --git a/net-scripts/net.modules.d/wpa_supplicant.sh b/net-scripts/net.modules.d/wpa_supplicant.sh
index f2357bd..a9e99c0 100644
--- a/net-scripts/net.modules.d/wpa_supplicant.sh
+++ b/net-scripts/net.modules.d/wpa_supplicant.sh
@@ -203,6 +203,7 @@ wpa_supplicant_pre_start() {
ESSID="$( wpa_supplicant_get_essid "${iface}" )"
ESSIDVAR="$( bash_variable "${ESSID}" )"
save_options "ESSID" "${ESSID}"
+ metric=2000
fi
return 0
fi
@@ -349,6 +350,7 @@ wpa_supplicant_pre_start() {
exit 0
fi
+ metric=2000
return 0
}
diff --git a/sbin/rc b/sbin/rc
index 1aa07ef..e4a828d 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -170,7 +170,7 @@ then
(
# Needed for mark_service_started()
source "${svclib}/sh/rc-services.sh"
-
+
for x in ${CRITICAL_SERVICES}
do
mark_service_started "${x}"
@@ -268,12 +268,12 @@ else
# As we're in the bootlevel, add any services that failed due
# to /dev/.rcsysinit existing to the list
- if [[ -d /dev/.rcafterinit ]] ; then
- for x in $(dolisting /dev/.rcafterinit/) ; do
+ if [[ -d /dev/.rcboot ]] ; then
+ for x in $(dolisting /dev/.rcboot/) ; do
[[ -L ${x} ]] && myscripts="${myscripts} ${x##*/}"
done
einfo "Device initiated services:${HILITE}${myscripts}${NORMAL}"
- rm -rf /dev/.rcafterinit
+ rm -rf /dev/.rcboot
fi
fi
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 8317365..a4367f0 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -23,12 +23,15 @@ export SVCNAME
# Support deprecated myservice variable
myservice="${SVCNAME}"
-# Stop init scripts from working until sysinit completes
+# coldplug events can trigger init scripts, but we don't want to run them
+# until after rc sysinit has completed so we punt them to the boot runlevel
if [[ -e /dev/.rcsysinit ]] ; then
eerror "ERROR: cannot run ${SVCNAME} until sysinit completes"
- # Try to add this service to a queue when sysinit has completed
- [[ ! -d /dev/.rcafterinit ]] && mkdir /dev/.rcafterinit
- ln -snf "$1" /dev/.rcafterinit/"${SVCNAME}"
+ eerror "${SVCNAME} will be started in the ${BOOTLEVEL} runlevel"
+ if [[ ! -L /dev/.rcboot/"${SVCNAME}" ]] ; then
+ [[ ! -d /dev/.rcboot ]] && mkdir /dev/.rcboot
+ ln -snf "$1" /dev/.rcboot/"${SVCNAME}"
+ fi
exit 1
fi
diff --git a/tarball.sh b/tarball.sh
index 97b165b..a76ff87 100755
--- a/tarball.sh
+++ b/tarball.sh
@@ -1,6 +1,6 @@
#!/bin/bash
export TMP="${TMP:-/tmp}"
-export V="1.12.0_pre16"
+export V="1.12.0_pre17"
export NAME="baselayout-vserver"
export DEST="${TMP}/${NAME}-${V}"