summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-04-07 11:56:04 +0000
committerChristian Heim <phreak@gentoo.org>2006-04-07 11:56:04 +0000
commit7978075fa644e5de43d6ea3433b40549a31fe342 (patch)
treedec7584dbf162325a6a0b0f6903bad30a1dc0753
parentMerging r1948 (diff)
downloadbaselayout-vserver-7978075fa644e5de43d6ea3433b40549a31fe342.tar.gz
baselayout-vserver-7978075fa644e5de43d6ea3433b40549a31fe342.tar.bz2
baselayout-vserver-7978075fa644e5de43d6ea3433b40549a31fe342.zip
Merging r1959
svn path=/baselayout-vserver/trunk/; revision=313
-rw-r--r--ChangeLog50
-rw-r--r--ChangeLog.vserver46
-rwxr-xr-xbin/rc-status7
-rw-r--r--etc/conf.d/domainname20
-rwxr-xr-xinit.d/bootmisc6
-rwxr-xr-xinit.d/domainname63
-rwxr-xr-xinit.d/hostname34
-rw-r--r--net-scripts/conf.d/net.example8
-rwxr-xr-xnet-scripts/init.d/net.lo287
-rw-r--r--net-scripts/net.modules.d/adsl.sh (renamed from net-scripts/net.modules.d/adsl)0
-rw-r--r--net-scripts/net.modules.d/apipa.sh (renamed from net-scripts/net.modules.d/apipa)0
-rw-r--r--net-scripts/net.modules.d/arping.sh (renamed from net-scripts/net.modules.d/arping)0
-rw-r--r--net-scripts/net.modules.d/bonding.sh (renamed from net-scripts/net.modules.d/bonding)0
-rw-r--r--net-scripts/net.modules.d/bridge.sh (renamed from net-scripts/net.modules.d/bridge)0
-rw-r--r--net-scripts/net.modules.d/dhclient.sh (renamed from net-scripts/net.modules.d/dhclient)0
-rw-r--r--net-scripts/net.modules.d/dhcpcd.sh (renamed from net-scripts/net.modules.d/dhcpcd)0
-rw-r--r--net-scripts/net.modules.d/essidnet.sh (renamed from net-scripts/net.modules.d/essidnet)0
-rw-r--r--net-scripts/net.modules.d/ifconfig.sh (renamed from net-scripts/net.modules.d/ifconfig)0
-rw-r--r--net-scripts/net.modules.d/ifplugd.sh (renamed from net-scripts/net.modules.d/ifplugd)0
-rw-r--r--net-scripts/net.modules.d/ip6to4.sh (renamed from net-scripts/net.modules.d/ip6to4)0
-rw-r--r--net-scripts/net.modules.d/ipppd.sh (renamed from net-scripts/net.modules.d/ipppd)0
-rw-r--r--net-scripts/net.modules.d/iproute2.sh (renamed from net-scripts/net.modules.d/iproute2)0
-rw-r--r--net-scripts/net.modules.d/iptunnel.sh (renamed from net-scripts/net.modules.d/iptunnel)0
-rw-r--r--net-scripts/net.modules.d/iwconfig.sh (renamed from net-scripts/net.modules.d/iwconfig)0
-rw-r--r--net-scripts/net.modules.d/macchanger.sh (renamed from net-scripts/net.modules.d/macchanger)0
-rw-r--r--net-scripts/net.modules.d/macnet.sh (renamed from net-scripts/net.modules.d/macnet)0
-rw-r--r--net-scripts/net.modules.d/netplugd.sh (renamed from net-scripts/net.modules.d/netplugd)0
-rw-r--r--net-scripts/net.modules.d/pppd.sh (renamed from net-scripts/net.modules.d/pppd)0
-rw-r--r--net-scripts/net.modules.d/pump.sh (renamed from net-scripts/net.modules.d/pump)0
-rw-r--r--net-scripts/net.modules.d/rename.sh (renamed from net-scripts/net.modules.d/rename)0
-rw-r--r--net-scripts/net.modules.d/system.sh (renamed from net-scripts/net.modules.d/system)0
-rw-r--r--net-scripts/net.modules.d/tuntap.sh (renamed from net-scripts/net.modules.d/tuntap)0
-rw-r--r--net-scripts/net.modules.d/udhcpc.sh (renamed from net-scripts/net.modules.d/udhcpc)0
-rw-r--r--net-scripts/net.modules.d/vlan.sh (renamed from net-scripts/net.modules.d/vlan)0
-rw-r--r--net-scripts/net.modules.d/wpa_supplicant.sh (renamed from net-scripts/net.modules.d/wpa_supplicant)0
-rwxr-xr-xsbin/functions.sh48
-rwxr-xr-xsbin/rc12
-rwxr-xr-xsbin/rc-daemon.sh2
-rwxr-xr-xsbin/rc-services.sh31
-rwxr-xr-xsbin/runscript.sh163
40 files changed, 469 insertions, 308 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c6a153..261af73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,56 @@
Give a better error message when no valid DHCP client is installed.
+ 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
+ solves the issue of udev-089 forcing coldplug removal.
+
+ 03 Apr 2006; Roy Marples <uberlord@gentoo.org>:
+
+ rc-status doesn't report broken symlinks when querying all levels,
+ #113755 again.
+
+ All net modules how have a .sh suffix to indicate that they are shell
+ scripts as not everyone uses vim.
+
+ runscript.sh now has a --nodeps option so that no depends are checked
+ when starting and stopping a service.
+
+ net.lo and system modules now support resolvconf instead of using our
+ own internal system.
+
+ DHCP and PPP clients no longer have helper scripts. As such they don't
+ change service status at all. Moved helpers.d/functions back into net.lo
+
+ Moved {get,save}_options from functions.sh to rc-services.sh
+
+ Removed whole load of crud from hostname init script, fixes #38172 again
+ and #122794. Also, it's no longer a critical service as defined by rc.
+
+ Added net modules for ccwgroup (s390 qeth ethernet) and br2684ctl
+ (speedtouch usb).
+
+ Removed xargs and find from all net scripts as /usr maybe net mounted,
+ #107260.
+
+ Punted the domainname script. Functionality has been in conf.d/net so you
+ can do this.
+ dns_domain_lo="foo"
+ nis_domain_lo="bar"
+
+ ppd module now checks to see if link exists if prefixed with /, #126916.
+
+ 28 Mar 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Make sure rc-status exit status is 0 #127733 by Timo Boettcher.
+
+ 23 Mar 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Disable hwclock script on s390 hosts.
+
14 Mar 2006; Roy Marples <uberlord@gentoo.org>:
Allow services that depend on net to be stopped/started in post
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index 3e65375..439b064 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,52 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 06 Apr 2006; Christian Heim <phreak@gentoo.org>:
+ Merging latest changes to the baselayout/trunk changes. This merge is based
+ upon revision 1959.
+
+ ChangeLog | 50
+ ChangeLog.vserver | 46
+ bin/rc-status | 7
+ etc/conf.d/domainname | 20
+ init.d/bootmisc | 6
+ init.d/domainname | 63 -
+ init.d/hostname | 34
+ net-scripts/conf.d/net.example | 8
+ net-scripts/init.d/net.lo | 287 +++--
+ net-scripts/net.modules.d/adsl | 93 -
+ net-scripts/net.modules.d/apipa | 46
+ net-scripts/net.modules.d/arping | 109 --
+ net-scripts/net.modules.d/bonding | 120 --
+ net-scripts/net.modules.d/bridge | 198 ---
+ net-scripts/net.modules.d/dhclient | 150 --
+ net-scripts/net.modules.d/dhcpcd | 123 --
+ net-scripts/net.modules.d/essidnet | 49
+ net-scripts/net.modules.d/ifconfig | 453 --------
+ net-scripts/net.modules.d/ifplugd | 146 --
+ net-scripts/net.modules.d/ip6to4 | 97 -
+ net-scripts/net.modules.d/ipppd | 72 -
+ net-scripts/net.modules.d/iproute2 | 392 -------
+ net-scripts/net.modules.d/iptunnel | 52
+ net-scripts/net.modules.d/iwconfig | 943 ------------------
+ net-scripts/net.modules.d/macchanger | 102 -
+ net-scripts/net.modules.d/macnet | 43
+ net-scripts/net.modules.d/netplugd | 124 --
+ net-scripts/net.modules.d/pppd | 279 -----
+ net-scripts/net.modules.d/pump | 105 --
+ net-scripts/net.modules.d/rename | 63 -
+ net-scripts/net.modules.d/system | 155 --
+ net-scripts/net.modules.d/tuntap | 103 -
+ net-scripts/net.modules.d/udhcpc | 117 --
+ net-scripts/net.modules.d/vlan | 154 --
+ net-scripts/net.modules.d/wpa_supplicant | 368 -------
+ sbin/functions.sh | 48
+ sbin/rc | 12
+ sbin/rc-daemon.sh | 2
+ sbin/rc-services.sh | 31
+ sbin/runscript.sh | 163 +--
+ 40 files changed, 469 insertions(+), 4964 deletions(-)
+
17 Mar 2006; Christian Heim <phreak@gentoo.org>:
Merging latest changes to the baselayout/trunk changes. This merge is based
upon revision 1948.
diff --git a/bin/rc-status b/bin/rc-status
index 4f6a29a..64b7807 100755
--- a/bin/rc-status
+++ b/bin/rc-status
@@ -208,7 +208,7 @@ for level in ${runlevelidxs} ; do
echo "Runlevel: ${HILITE}${level}${NORMAL}"
for service in ${runlevels[${arridx}]} ; do
if [[ ! -e "${runleveldir}/${level}/${service}" \
- && ${level} != "UNASSIGNED" \
+ && ${level} != "UNASSIGNED" && ${level} != "all" \
]] && [[ ${level} != "${BOOTLEVEL}" \
|| " ${boot_crit} " != *" ${service} "* ]]; then
print_msg "${service}" "${BAD}" 'broken '
@@ -226,11 +226,14 @@ for level in ${runlevelidxs} ; do
fi
done
let "arridx += 1"
- [ -n "${UNUSED}" ] && exit 0
+ [ -n "${UNUSED}" ] && break
done
if [[ -n ${broken} ]]; then
eerror "You have some broken symbolic links as reported by the broken"
eerror "status above. This can be fixed by removing the broken service"
eerror "from its runlevel and re-adding it back using rc-update."
+ exit 1
+else
+ exit 0
fi
diff --git a/etc/conf.d/domainname b/etc/conf.d/domainname
deleted file mode 100644
index 3a32173..0000000
--- a/etc/conf.d/domainname
+++ /dev/null
@@ -1,20 +0,0 @@
-# /etc/conf.d/domainname
-
-# When setting up resolv.conf, what should take precedence?
-# 0 = let dhcp/whatever override DNSDOMAIN
-# 1 = override dhcp/whatever with DNSDOMAIN
-
-OVERRIDE=1
-
-# To have a proper FQDN, you need to setup /etc/hosts and /etc/resolv.conf
-# (domain entry in /etc/resolv.conf and FQDN in /etc/hosts).
-#
-# DNSDOMAIN merely sets the domain entry in /etc/resolv.conf, see
-# the resolv.conf(5) manpage for more info.
-
-DNSDOMAIN=""
-
-# For information on setting up NIS, please see:
-# http://www.linux-nis.org/nis-howto/HOWTO/
-
-NISDOMAIN=""
diff --git a/init.d/bootmisc b/init.d/bootmisc
index 2350b0c..610a4af 100755
--- a/init.d/bootmisc
+++ b/init.d/bootmisc
@@ -34,12 +34,6 @@ start() {
# Take care of random stuff [ /var/lock | /var/run | pam ]
#
- if [[ -d /var/lib/net-scripts/state ]] ; then
- ebegin $"Cleaning" /var/lib/net-scripts/state
- rm -rf /var/lib/net-scripts/state/*
- eend 0
- fi
-
ebegin $"Cleaning" /var/lock, /var/run
rm -rf /var/run/console.lock /var/run/console/*
diff --git a/init.d/domainname b/init.d/domainname
deleted file mode 100755
index f7ed8f9..0000000
--- a/init.d/domainname
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/sbin/runscript
-# Copyright 1999-2006 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-depend() {
- need hostname
- before bootmisc
-}
-
-checkconfig_nis() {
- if [[ -f /etc/nisdomainname ]] ; then
- ewarn $"You should stop using /etc/nisdomainname and use /etc/conf.d/domainname"
- export NISDOMAIN=$(</etc/nisdomainname)
- return 0
- fi
- [[ -n ${NISDOMAIN} ]]
-}
-
-checkconfig_dns() {
- if [[ -f /etc/dnsdomainname ]] ; then
- ewarn $"You should stop using /etc/dnsdomainname and use /etc/conf.d/domainname"
- export DNSDOMAIN=$(</etc/dnsdomainname)
- fi
- [[ -z ${DNSDOMAIN} ]] && return 1
-
- if ! touch /etc/resolv.conf 2> /dev/null ; then
- ewarn $"Unable to set domain in resolv.conf (ro root?)"
- return 1
- else
- return 0
- fi
-}
-
-start() {
- # Ensure that we have a hostname binary or function
- source /lib/rcscripts/net.modules.d/helpers.d/functions
-
- local retval=0
- local retval2=0
-
- if checkconfig_nis ; then
- ebegin $"Setting NIS domainname to" ${NISDOMAIN}
- hostname -y "${NISDOMAIN}"
- retval=$?
- eend ${retval} $"Failed to set the NIS domainname"
- fi
-
- if checkconfig_dns ; then
- ebegin $"Setting DNS domainname to" ${DNSDOMAIN}
- resolv=$(grep -v '^[[:space:]]*domain' /etc/resolv.conf)
- [[ ${OVERRIDE} == "1" ]] \
- && resolv="${resolv}"$'\n'"domain ${DNSDOMAIN}" \
- || resolv="domain ${DNSDOMAIN}"$'\n'"${resolv}"
- echo "${resolv}" > /etc/resolv.conf
- retval2=$?
- eend ${retval2} $"Failed to set the DNS domainname"
- fi
-
- return $((retval + retval2))
-}
-
-
-# vim:ts=4
diff --git a/init.d/hostname b/init.d/hostname
index c890b89..0a9ec3a 100755
--- a/init.d/hostname
+++ b/init.d/hostname
@@ -3,36 +3,14 @@
# Distributed under the terms of the GNU General Public License v2
start() {
- # Ensure that we have a hostname binary or function
- source /lib/rcscripts/net.modules.d/helpers.d/functions
-
- local myhost=$(hostname 2>/dev/null)
- local retval=0
-
- # If the hostname is already set via the kernel, and /etc/hostname
- # isn't setup, then we shouldn't go reseting the configuration #38172.
- if [[ -z ${myhost} ]] || [[ ${myhost} == "(none)" ]] ; then
- myhost="localhost"
- fi
-
if [[ -f /etc/hostname ]] ; then
- ewarn $"You should stop using /etc/hostname and use /etc/conf.d/hostname"
- myhost=$(</etc/hostname)
- else
- myhost=${HOSTNAME}
- fi
-
- ebegin $"Setting hostname to" ${myhost}
- hostname "${myhost}"
- retval=$?
- eend ${retval} $"Failed to set the hostname"
-
- if [[ ${retval} -eq 0 ]] ; then
- # setup $HOSTNAME, ignore errors in case /etc is readonly.
- echo "HOSTNAME=\"${myhost}\"" 2>/dev/null > /etc/env.d/01hostname
+ ewarn "You should stop using /etc/hostname and use /etc/conf.d/hostname"
+ HOSTNAME="$(< /etc/hostname)"
fi
- return ${retval}
+ ebegin "Setting hostname to ${HOSTNAME}"
+ hostname "${HOSTNAME}"
+ eend $? "Failed to set the hostname"
}
-# vim:ts=4
+# vim: ts=4 :
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index f77c38f..5f6feaa 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -494,9 +494,15 @@
# TUN/TAP
# For TUN/TAP support emerge net-misc/openvpn or sys-apps/usermode-utilities
#
-# NOTE: The interface name must be either tun or tap followed by a number
+# You must specify if we're a tun or tap device. Then you can give it any
+# name you like - such as vpn
+#tuntap_vpn="tun"
#config_tun1=( "192.168.0.1/24")
+# Or stick wit the generic names - like tap0
+#tuntap_tap0="tap"
+#config_tap0=( "192.168.0.1/24")
+
# For passing custom options to tunctl use something like the following. This
# example sets the owner to adm
#tunctl_tun1="-u adm"
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index f73dfac..4734a59 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -12,6 +12,7 @@
# runlevel as the net.* script that needs it.
depend() {
need localmount
+ after hostname
use isapnp isdn pcmcia usb wlan
# Load any custom depend functions for the given interface
@@ -25,9 +26,6 @@ depend() {
# Define where our modules are
MODULES_DIR="${svclib}/net.modules.d"
-# Load some functions shared between ourselves and our DHCP helpers
-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() {
@@ -54,11 +52,176 @@ variables() {
eval "${MODULE}_variables() { echo \"$*\"; }"
}
+is_loopback() {
+ [[ $1 == "lo" || $1 == "lo"[0-9]* ]]
+}
+
+# char* interface_device(char *iface)
+#
+# Gets the base device of the interface
+# Can handle eth0:1 and eth0.1
+# Which returns eth0 in this case
+interface_device() {
+ local dev="${1%%.*}"
+ [[ ${dev} == "$1" ]] && dev="${1%%:*}"
+ echo "${dev}"
+}
+
+# char* interface_type(char* iface)
+#
+# Returns the base type of the interface
+# eth, ippp, etc
+interface_type() {
+ echo "${1%%[0-9]*}"
+}
+
+# int calculate_metric(char *interface)
+#
+# 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
+calculate_metric() {
+ local iface="$1" exclude='$1!="Iface" && $1!="lo"'
+
+ # Have we already got a metric?
+ local m="$( awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \
+ /proc/net/route )"
+ if [[ -n ${m} ]] ; then
+ echo "${m}"
+ 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}\""
+ 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}"
+}
+
+# int netmask2cidr(char *netmask)
+#
+# Returns the CIDR of a given netmask
+netmask2cidr() {
+ local binary="" i bin
+
+ for i in ${1//./ }; do
+ bin=""
+ while [[ ${i} != "0" ]] ; do
+ bin=$[${i}%2]${bin}
+ (( i=i>>1 ))
+ done
+ binary="${binary}${bin}"
+ done
+ binary="${binary%%0*}"
+ echo "${#binary}"
+}
+
+
+# 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)
+# maps function names this_* to that_*
+function_wrap() {
+ local i
+
+ is_function "${2}_depend" && return
+
+ for i in $( typeset -f | grep -o '^'"${1}"'_[^ ]*' ); do
+ eval "${2}${i#${1}}() { ${i} \"\$@\"; }"
+ done
+}
+
+# char[] * expand_parameters(char *cmd)
+#
+# Returns an array after expanding parameters. For example
+# "192.168.{1..3}.{1..3}/24 brd +"
+# will return
+# "192.168.1.1/24 brd +"
+# "192.168.1.2/24 brd +"
+# "192.168.1.3/24 brd +"
+# "192.168.2.1/24 brd +"
+# "192.168.2.2/24 brd +"
+# "192.168.2.3/24 brd +"
+# "192.168.3.1/24 brd +"
+# "192.168.3.2/24 brd +"
+# "192.168.3.3/24 brd +"
+expand_parameters() {
+ local x="$( eval echo ${@// /_} )"
+ local -a a=( ${x} )
+
+ a=( "${a[@]/#/\"}" )
+ a=( "${a[@]/%/\"}" )
+ echo "${a[*]//_/ }"
+}
+
+# void configure_variables(char *interface, char *option1, [char *option2])
+#
+# Maps configuration options from <variable>_<option> to <variable>_<iface>
+# option2 takes precedence over option1
+configure_variables() {
+ local iface="$1" option1="$2" option2="$3"
+
+ local mod func x i
+ local -a ivars ovars1 ovars2
+ local ifvar="$(bash_variable "${iface}")"
+
+ for mod in ${MODULES[@]}; do
+ is_function ${mod}_variables || continue
+ for v in $(${mod}_variables) ; do
+ x=""
+ [[ -n ${option2} ]] && x="${v}_${option2}[@]"
+ [[ -z ${!x} ]] && x="${v}_${option1}[@]"
+ [[ -n ${!x} ]] && eval "${v}_${ifvar}=( \"\${!x}\" )"
+ done
+ done
+
+ return 0
+}
# bool module_load_minimum(char *module)
#
# Does the minimum checking on a module - even when forcing
module_load_minimum() {
- local f="$1" MODULE="${1##*/}"
+ local f="$1.sh" MODULE="${1##*/}"
if [[ ! -f ${f} ]] ; then
eerror "${f} does not exist"
@@ -72,7 +235,7 @@ module_load_minimum() {
for f in depend; do
is_function "${MODULE}_${f}" && continue
- eerror "${MODULE} does not support the required function ${f}"
+ eerror "${MODULE}.sh does not support the required function ${f}"
return 1
done
@@ -88,7 +251,7 @@ modules_load_auto() {
# Populate the MODULES array
# Basically we treat evey file in ${MODULES_DIR} as a module
- MODULES=( $( cd "${MODULES_DIR}" ; ls ) )
+ MODULES=( $( cd "${MODULES_DIR}" ; ls *.sh ) )
j="${#MODULES[@]}"
for (( i=0; i<j; i++ )); do
MODULES[i]="${MODULES_DIR}/${MODULES[i]}"
@@ -103,6 +266,7 @@ modules_load_auto() {
j="${#MODULES[@]}"
loaded_interface=false
for (( i=0; i<j; i++ )); do
+ MODULES[i]="${MODULES[i]%.sh*}"
if [[ ${MODULES[i]##*/} == "interface" ]] ; then
eerror "interface is a reserved name - cannot load a module called interface"
return 1
@@ -121,7 +285,7 @@ modules_load_auto() {
)
if [[ $? == 0 ]] ; then
- source "${MODULES[i]}"
+ source "${MODULES[i]}.sh"
MODULES[i]="${MODULES[i]##*/}"
else
unset MODULES[i]
@@ -217,8 +381,8 @@ 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
- source "${MODULES_DIR}/${umods[i]}"
+ if [[ -e "${MODULES_DIR}/${umods[i]}.sh" ]] ; then
+ source "${MODULES_DIR}/${umods[i]}.sh"
is_function "${umods[i]}_check_installed" \
&& ${umods[i]}_check_installed true
else
@@ -404,7 +568,7 @@ modules_load() {
local RC_INDENTATION="${RC_INDENTATION}"
local -a PROVIDES WRAP_MODULES
- if [[ ${iface} != "lo" ]] ; then
+ if ! is_loopback "${iface}" ; then
x="modules_force_${iface}[@]"
[[ -n ${!x} ]] && modules_force=( "${!x}" )
if [[ -n ${modules_force} ]] ; then
@@ -510,14 +674,10 @@ iface_start() {
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 if we're on auto
+ # Try and work out a metric for the interface
x="metric_${ifvar}"
if [[ -z ${!x} ]] ; then
- if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
- eval "metric_${ifvar}=\"$(calculate_metric ${iface})\""
- else
- eval "metric_${ifvar}=0"
- fi
+ eval "metric_${ifvar}=\"$(calculate_metric ${iface})\""
fi
# pre Start any modules with
@@ -572,18 +732,13 @@ 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
- ewarn "Configuration not set for ${iface} - assuming DHCP"
- if is_function "dhcp_start" ; then
- config=( "dhcp" )
- else
- eerror "No DHCP client installed"
- return 1
- fi
-# else
-# config=( "null" )
-# ewarn "Configuration not set for ${iface} - assuming null"
-# fi
+ ewarn "Configuration not set for ${iface} - assuming DHCP"
+ if is_function "dhcp_start" ; then
+ config=( "dhcp" )
+ else
+ eerror "No DHCP client installed"
+ return 1
+ fi
fi
einfo "Bringing up ${iface}"
@@ -612,11 +767,12 @@ 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" ]] \
- && is_function arping_address_exists ; then
- if arping_address_exists "${iface}" "${conf[0]}" ; then
- eerror "${conf[0]%%/*} already taken on ${iface}"
- x="1"
+ if ! is_loopback "${iface}" ; then
+ if is_function arping_address_exists ; then
+ if arping_address_exists "${iface}" "${conf[0]}" ; then
+ eerror "${conf[0]%%/*} already taken on ${iface}"
+ x="1"
+ fi
fi
fi
[[ ${x} == "0" ]] && interface_add_address "${iface}" ${conf[@]}; x="$?"
@@ -672,7 +828,9 @@ iface_stop() {
# pre Stop any modules
for mod in ${MODULES[@]}; do
- is_function "${mod}_pre_stop" && ${mod}_pre_stop "${iface}"
+ if is_function "${mod}_pre_stop" ; then
+ ${mod}_pre_stop "${iface}" || return 1
+ fi
done
einfo "Bringing down ${iface}"
@@ -691,7 +849,9 @@ iface_stop() {
for i in ${aliases} ${iface}; do
# Stop all our modules
for mod in ${MODULES[@]}; do
- is_function "${mod}_stop" && ${mod}_stop "${i}"
+ if is_function "${mod}_stop" ; then
+ ${mod}_stop "${i}" || return 1
+ fi
done
# A module may have removed the interface
@@ -738,6 +898,10 @@ run_start() {
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[@]}" )
+ elif [[ ${iface} == "lo0" ]] ; then
+ metric_lo0="0"
+ config_lo0=( "127.0.0.1/8 brd 127.255.255.255" "${config_lo[@]}" )
+ routes_lo0=( "127.0.0.0/8" "${routes_lo[@]}" )
fi
# We may not have a loaded module for ${iface}
@@ -833,6 +997,9 @@ run_stop() {
iface_stop "${iface}" || return 1 # always succeeds, btw
+ # Release resolv.conf information.
+ [[ -x /sbin/resolvconf ]] && resolvconf -d "${iface}"
+
# Mark us as inactive if called from the background
[[ ${IN_BACKGROUND} == "true" ]] && mark_service_inactive "net.${iface}"
@@ -848,6 +1015,7 @@ run_stop() {
eoutdent
fi
+
return 0
}
@@ -876,7 +1044,9 @@ run() {
[[ ${cmd} == "stop" ]] && starting=false
# We force lo to only use these modules for a major speed boost
- [[ ${iface} == "lo" ]] && modules_force=( "iproute2" "ifconfig" "system" )
+ if is_loopback "${iface}" ; then
+ modules_force=( "iproute2" "ifconfig" "system" )
+ fi
if modules_load "${iface}" "${starting}" ; then
if [[ ${cmd} == "stop" ]] ; then
@@ -887,7 +1057,6 @@ run() {
done
run_stop "${iface}" && r=0
- remove_state "${iface}"
else
# Only hotplug on ethernet interfaces
if [[ ${IN_HOTPLUG} == 1 ]] ; then
@@ -901,19 +1070,7 @@ run() {
fi
fi
- # Only apply best state if we're on auto
- if [[ ${r} == "0" ]] ; then
- local siface=""
- if [[ ${RC_AUTO_INTERFACE} == "yes" ]] ; then
- siface="$(select_best_interface)"
- if [[ -n ${siface} ]] ; then
- einfo "Selecting best interface: ${siface}"
- fi
- elif [[ ${cmd} == "start" ]] ; then
- siface="${iface}"
- fi
- [[ -n ${siface} ]] && apply_state "${siface}"
- else
+ if [[ ${r} != "0" ]] ; then
if [[ ${cmd} == "start" ]] ; then
# Call user-defined failup if it exists
if is_function failup ; then
@@ -938,23 +1095,6 @@ run() {
return "${r}"
}
-# void link_file(char *file)
-#
-# Move a config file from /etc to ${netdir} and creates a link if needed.
-# This enables net-scripts to control the config file for interface management
-# 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
- vewarn "Moving /etc/${file} to ${netdir}/${file} and creating link"
- mv "/etc/${file}" "${netdir}"
- ln -snf "${netdir}/${file}" "/etc/${file}"
- fi
- fi
-}
-
# bool start(void)
#
# Start entry point so that we only have one function
@@ -974,19 +1114,6 @@ start() {
fi
fi
- 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
- link_file "resolv.conf"
- link_file "ntp.conf"
- link_file "yp.conf"
- fi
-
einfo "Starting ${IFACE}"
run "${IFACE}" start
}
diff --git a/net-scripts/net.modules.d/adsl b/net-scripts/net.modules.d/adsl.sh
index 0dcc677..0dcc677 100644
--- a/net-scripts/net.modules.d/adsl
+++ b/net-scripts/net.modules.d/adsl.sh
diff --git a/net-scripts/net.modules.d/apipa b/net-scripts/net.modules.d/apipa.sh
index 4ebd469..4ebd469 100644
--- a/net-scripts/net.modules.d/apipa
+++ b/net-scripts/net.modules.d/apipa.sh
diff --git a/net-scripts/net.modules.d/arping b/net-scripts/net.modules.d/arping.sh
index 1a476e7..1a476e7 100644
--- a/net-scripts/net.modules.d/arping
+++ b/net-scripts/net.modules.d/arping.sh
diff --git a/net-scripts/net.modules.d/bonding b/net-scripts/net.modules.d/bonding.sh
index 6095c74..6095c74 100644
--- a/net-scripts/net.modules.d/bonding
+++ b/net-scripts/net.modules.d/bonding.sh
diff --git a/net-scripts/net.modules.d/bridge b/net-scripts/net.modules.d/bridge.sh
index ec1e2ff..ec1e2ff 100644
--- a/net-scripts/net.modules.d/bridge
+++ b/net-scripts/net.modules.d/bridge.sh
diff --git a/net-scripts/net.modules.d/dhclient b/net-scripts/net.modules.d/dhclient.sh
index b8d3312..b8d3312 100644
--- a/net-scripts/net.modules.d/dhclient
+++ b/net-scripts/net.modules.d/dhclient.sh
diff --git a/net-scripts/net.modules.d/dhcpcd b/net-scripts/net.modules.d/dhcpcd.sh
index 516f7e3..516f7e3 100644
--- a/net-scripts/net.modules.d/dhcpcd
+++ b/net-scripts/net.modules.d/dhcpcd.sh
diff --git a/net-scripts/net.modules.d/essidnet b/net-scripts/net.modules.d/essidnet.sh
index 69e2db5..69e2db5 100644
--- a/net-scripts/net.modules.d/essidnet
+++ b/net-scripts/net.modules.d/essidnet.sh
diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig.sh
index bec988e..bec988e 100644
--- a/net-scripts/net.modules.d/ifconfig
+++ b/net-scripts/net.modules.d/ifconfig.sh
diff --git a/net-scripts/net.modules.d/ifplugd b/net-scripts/net.modules.d/ifplugd.sh
index 8fa1cc1..8fa1cc1 100644
--- a/net-scripts/net.modules.d/ifplugd
+++ b/net-scripts/net.modules.d/ifplugd.sh
diff --git a/net-scripts/net.modules.d/ip6to4 b/net-scripts/net.modules.d/ip6to4.sh
index 4dde13f..4dde13f 100644
--- a/net-scripts/net.modules.d/ip6to4
+++ b/net-scripts/net.modules.d/ip6to4.sh
diff --git a/net-scripts/net.modules.d/ipppd b/net-scripts/net.modules.d/ipppd.sh
index 0280ea6..0280ea6 100644
--- a/net-scripts/net.modules.d/ipppd
+++ b/net-scripts/net.modules.d/ipppd.sh
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2.sh
index 498eea6..498eea6 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2.sh
diff --git a/net-scripts/net.modules.d/iptunnel b/net-scripts/net.modules.d/iptunnel.sh
index ff62bb9..ff62bb9 100644
--- a/net-scripts/net.modules.d/iptunnel
+++ b/net-scripts/net.modules.d/iptunnel.sh
diff --git a/net-scripts/net.modules.d/iwconfig b/net-scripts/net.modules.d/iwconfig.sh
index 0711043..0711043 100644
--- a/net-scripts/net.modules.d/iwconfig
+++ b/net-scripts/net.modules.d/iwconfig.sh
diff --git a/net-scripts/net.modules.d/macchanger b/net-scripts/net.modules.d/macchanger.sh
index 76720b6..76720b6 100644
--- a/net-scripts/net.modules.d/macchanger
+++ b/net-scripts/net.modules.d/macchanger.sh
diff --git a/net-scripts/net.modules.d/macnet b/net-scripts/net.modules.d/macnet.sh
index 6be0a4b..6be0a4b 100644
--- a/net-scripts/net.modules.d/macnet
+++ b/net-scripts/net.modules.d/macnet.sh
diff --git a/net-scripts/net.modules.d/netplugd b/net-scripts/net.modules.d/netplugd.sh
index cd8ebe2..cd8ebe2 100644
--- a/net-scripts/net.modules.d/netplugd
+++ b/net-scripts/net.modules.d/netplugd.sh
diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd.sh
index 97caf6b..97caf6b 100644
--- a/net-scripts/net.modules.d/pppd
+++ b/net-scripts/net.modules.d/pppd.sh
diff --git a/net-scripts/net.modules.d/pump b/net-scripts/net.modules.d/pump.sh
index a2dacfc..a2dacfc 100644
--- a/net-scripts/net.modules.d/pump
+++ b/net-scripts/net.modules.d/pump.sh
diff --git a/net-scripts/net.modules.d/rename b/net-scripts/net.modules.d/rename.sh
index 43a6da1..43a6da1 100644
--- a/net-scripts/net.modules.d/rename
+++ b/net-scripts/net.modules.d/rename.sh
diff --git a/net-scripts/net.modules.d/system b/net-scripts/net.modules.d/system.sh
index 5d841d3..5d841d3 100644
--- a/net-scripts/net.modules.d/system
+++ b/net-scripts/net.modules.d/system.sh
diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap.sh
index e0d1865..e0d1865 100644
--- a/net-scripts/net.modules.d/tuntap
+++ b/net-scripts/net.modules.d/tuntap.sh
diff --git a/net-scripts/net.modules.d/udhcpc b/net-scripts/net.modules.d/udhcpc.sh
index 041afb2..041afb2 100644
--- a/net-scripts/net.modules.d/udhcpc
+++ b/net-scripts/net.modules.d/udhcpc.sh
diff --git a/net-scripts/net.modules.d/vlan b/net-scripts/net.modules.d/vlan.sh
index 393bc72..393bc72 100644
--- a/net-scripts/net.modules.d/vlan
+++ b/net-scripts/net.modules.d/vlan.sh
diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant.sh
index 22343a7..22343a7 100644
--- a/net-scripts/net.modules.d/wpa_supplicant
+++ b/net-scripts/net.modules.d/wpa_supplicant.sh
diff --git a/sbin/functions.sh b/sbin/functions.sh
index 1911236..e8d2d4e 100755
--- a/sbin/functions.sh
+++ b/sbin/functions.sh
@@ -214,8 +214,10 @@ ewarn() {
echo -e " ${WARN}*${NORMAL} ${RC_INDENTATION}$*"
fi
+ local name="rc-scripts"
+ [[ $0 != "/sbin/runscript.sh" ]] && name="${0##*/}"
# Log warnings to system log
- esyslog "daemon.warning" "rc-scripts" "$*"
+ esyslog "daemon.warning" "${name}" "$*"
LAST_E_CMD="ewarn"
return 0
@@ -233,6 +235,8 @@ eerror() {
echo -e " ${BAD}*${NORMAL} ${RC_INDENTATION}$*"
fi
+ local name="rc-scripts"
+ [[ $0 != "/sbin/runscript.sh" ]] && name="${0##*/}"
# Log errors to system log
esyslog "daemon.err" "rc-scripts" "$*"
@@ -466,35 +470,6 @@ dolisting() {
echo "${mylist}"
}
-# void save_options(char *option, char *optstring)
-#
-# save the settings ("optstring") for "option"
-#
-save_options() {
- local myopts="$1"
-
- shift
- if [[ ! -d "${svcdir}/options/${SVCNAME}" ]] ; then
- mkdir -p -m 0755 "${svcdir}/options/${SVCNAME}"
- fi
-
- echo "$*" > "${svcdir}/options/${SVCNAME}/${myopts}"
-
- return 0
-}
-
-# char *get_options(char *option)
-#
-# get the "optstring" for "option" that was saved
-# by calling the save_options function
-#
-get_options() {
- if [[ -f "${svcdir}/options/${SVCNAME}/$1" ]] ; then
- echo "$(< ${svcdir}/options/${SVCNAME}/$1)"
- fi
-
- return 0
-}
# char *add_suffix(char * configfile)
#
@@ -669,6 +644,19 @@ requote() {
echo "$*"
}
+# char* uniqify(char *arg, ...)
+#
+# Ensure that params are unique
+#
+uniqify() {
+ local result= x=
+ while [[ -n "$1" ]] ; do
+ [[ " ${result} " != *" $1 "* ]] && result="${result} $1"
+ shift
+ done
+ echo "${result# *}"
+}
+
##############################################################################
# #
# This should be the last code in here, please add all functions above!! #
diff --git a/sbin/rc b/sbin/rc
index eb4a78d..ca7c710 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -119,7 +119,17 @@ else
else
# Non-normal runlevels don't include boot scripts as default
mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")"
- fi
+
+ # 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
+ [[ -L ${x} ]] && myscripts="${myscripts} ${x##*/}"
+ done
+ einfo "Device initiated services:${HILITE}${myscripts}${NORMAL}"
+ rm -rf /dev/.rcafterinit
+ fi
+ fi
for x in ${mylevels} ; do
[[ -L ${x} ]] && myscripts="${myscripts} ${x##*/}"
diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh
index 81ca457..3d89447 100755
--- a/sbin/rc-daemon.sh
+++ b/sbin/rc-daemon.sh
@@ -265,7 +265,7 @@ rc_start_daemon() {
# Returns 0 if everything was successful otherwise 1
rc_stop_daemon() {
local pid pids retval="0"
-
+
if [[ -n ${cmd} ]]; then
if ! is_daemon_running ${cmd} "${pidfile}" ; then
[[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]] && return 1
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 199a8d2..df0b557 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -255,11 +255,40 @@ is_runlevel_stop() {
[[ -d "${svcdir}/softscripts.new" ]]
}
+# void save_options(char *option, char *optstring)
+#
+# save the settings ("optstring") for "option"
+#
+save_options() {
+ local myopts="$1"
+
+ shift
+ if [[ ! -d "${svcdir}/options/${SVCNAME}" ]] ; then
+ mkdir -p -m 0755 "${svcdir}/options/${SVCNAME}"
+ fi
+
+ echo "$*" > "${svcdir}/options/${SVCNAME}/${myopts}"
+}
+
+# char *get_options(char *option)
+#
+# get the "optstring" for "option" that was saved
+# by calling the save_options function
+#
+get_options() {
+ local svc="${SVCNAME}"
+ [[ -n $2 ]] && svc="$2"
+
+ if [[ -f "${svcdir}/options/${svc}/$1" ]] ; then
+ echo "$(< ${svcdir}/options/${svc}/$1)"
+ fi
+}
+
# void sevice_message([char *type] char *message)
#
# Print out a service message if we are on parallel
service_message() {
- [[ ${RC_PARALLEL_STARTUP} != "yes" ]] && return
+ [[ ${RC_PARALLEL_STARTUP} != "yes" || ${RC_QUIET} == "yes" ]] && return
local cmd="einfo"
case "$1" in
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 2c184c8..3a4dd6f 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -26,6 +26,9 @@ myservice="${SVCNAME}"
# Stop init scripts from working until sysinit completes
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}"
exit 1
fi
@@ -85,9 +88,9 @@ service_inactive "${SVCNAME}"
svcinactive="$?"
svc_quit() {
eerror "ERROR: ${SVCNAME} caught an interrupt"
- if service_inactive "${SVCNAME}" || [[ ${svcinactive} == 0 ]] ; then
+ if service_inactive "${SVCNAME}" || [[ ${svcinactive} == "0" ]] ; then
mark_service_inactive "${SVCNAME}"
- elif [[ ${svcstarted} == 0 ]] ; then
+ elif [[ ${svcstarted} == "0" ]] ; then
mark_service_started "${SVCNAME}"
else
mark_service_stopped "${SVCNAME}"
@@ -175,7 +178,7 @@ svc_stop() {
ewarn "WARNING: you are stopping a boot service."
fi
- if [[ ${svcpause} != "yes" ]] ; then
+ if [[ ${svcpause} != "yes" && ${RC_NO_DEPS} != "yes" ]] ; then
if [[ ${NETSERVICE} == "yes" ]] ; then
# A net.* service
if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" || \
@@ -219,7 +222,7 @@ svc_stop() {
IN_BACKGROUND="${ib_save}"
- if [[ ${retval} != 0 ]] ; then
+ if [[ ${retval} != "0" ]] ; then
eerror "ERROR: problems stopping dependent services."
eerror " ${SVCNAME} is still up."
else
@@ -240,7 +243,7 @@ svc_stop() {
# If a service has been marked inactive, exit now as something
# may attempt to start it again later
- if service_inactive "${SVCNAME}" ; then
+ if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then
svcinactive=0
return 0
fi
@@ -255,7 +258,7 @@ svc_stop() {
if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
mark_service_stopped "${SVCNAME}"
else
- if [[ ${svcinactive} == 0 ]] ; then
+ if [[ ${svcinactive} == "0" ]] ; then
mark_service_inactive "${SVCNAME}"
else
mark_service_started "${SVCNAME}"
@@ -309,82 +312,88 @@ svc_start() {
service_message "Service ${SVCNAME} starting"
+ if broken "${SVCNAME}" ; then
+ eerror "ERROR: Some services needed are missing. Run"
+ eerror " './${SVCNAME} broken' for a list of those"
+ eerror " services. ${SVCNAME} was not started."
+ retval=1
+ fi
+
# Save the IN_BACKGROUND var as we need to clear it for starting depends
local ib_save="${IN_BACKGROUND}"
unset IN_BACKGROUND
- local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")"
- local netservices=
- for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
- $(dolisting "/etc/runlevels/${mylevel}/net.*") ; do
- netservices="${netservices} ${x##*/}"
- done
-
- # Start dependencies, if any.
- if ! is_runlevel_start ; then
- for x in ${startupservices} ; do
- if [[ ${x} == "net" && ${NETSERVICE} != "yes" ]] && ! is_net_up ; then
- for y in ${netservices} ; do
- service_stopped "${y}" && start_service "${y}"
- done
- elif [[ ${x} != "net" ]] ; then
- if service_stopped "${x}" ; then
- start_service "${x}"
- fi
- fi
+ if [[ ${retval} == "0" && ${RC_NO_DEPS} != "yes" ]] ; then
+ local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")"
+ local netservices=
+ for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
+ $(dolisting "/etc/runlevels/${mylevel}/net.*") ; do
+ netservices="${netservices} ${x##*/}"
done
- fi
- # We also wait for any services we're after to finish incase they
- # have a "before" dep but we don't dep on them.
- if is_runlevel_start ; then
- startupservices="${startupservices} $(valid_iafter "${SVCNAME}")"
- fi
+ # Start dependencies, if any.
+ if ! is_runlevel_start ; then
+ for x in ${startupservices} ; do
+ if [[ ${x} == "net" && ${NETSERVICE} != "yes" ]] && ! is_net_up ; then
+ for y in ${netservices} ; do
+ service_stopped "${y}" && start_service "${y}"
+ done
+ elif [[ ${x} != "net" ]] ; then
+ if service_stopped "${x}" ; then
+ start_service "${x}"
+ fi
+ fi
+ done
+ fi
- if [[ " ${startupservices} " == *" net "* ]] ; then
- startupservices=" ${startupservices} "
- startupservices="${startupservices/ net / ${netservices} }"
- startupservices="${startupservices// net /}"
- fi
+ # We also wait for any services we're after to finish incase they
+ # have a "before" dep but we don't dep on them.
+ if is_runlevel_start ; then
+ startupservices="${startupservices} $(valid_iafter "${SVCNAME}")"
+ fi
- # Wait for dependencies to finish.
- for x in ${startupservices} ; do
- service_started "${x}" && continue
- wait_service "${x}"
- if ! service_started "${x}" ; then
- # A 'need' dependency is critical for startup
- if ineed -t "${SVCNAME}" "${x}" >/dev/null \
- || net_service "${x}" && ineed -t "${SVCNAME}" net \
- && ! is_net_up ; then
- if service_inactive "${x}" || service_wasinactive "${x}" || \
- [[ -n $(ls "${svcdir}"/scheduled/*/"${x}" 2>/dev/null) ]] ; then
- svc_schedule_start "${x}" "${SVCNAME}"
- [[ -n ${startinactive} ]] && startinactive="${startinactive}, "
- startinactive="${startinactive}${x}"
- else
- startfail="${x}"
- break
+ if [[ " ${startupservices} " == *" net "* ]] ; then
+ startupservices=" ${startupservices} "
+ startupservices="${startupservices/ net / ${netservices} }"
+ startupservices="${startupservices// net /}"
+ fi
+
+ # Wait for dependencies to finish.
+ for x in ${startupservices} ; do
+ service_started "${x}" && continue
+ wait_service "${x}"
+ if ! service_started "${x}" ; then
+ # A 'need' dependency is critical for startup
+ if ineed -t "${SVCNAME}" "${x}" >/dev/null \
+ || net_service "${x}" && ineed -t "${SVCNAME}" net \
+ && ! is_net_up ; then
+ if service_inactive "${x}" || service_wasinactive "${x}" || \
+ [[ -n $(ls "${svcdir}"/scheduled/*/"${x}" 2>/dev/null) ]] ; then
+ svc_schedule_start "${x}" "${SVCNAME}"
+ [[ -n ${startinactive} ]] && startinactive="${startinactive}, "
+ startinactive="${startinactive}${x}"
+ else
+ startfail="${x}"
+ break
+ fi
fi
fi
+ done
+
+ if [[ -n ${startfail} ]] ; then
+ eerror "ERROR: Problem starting needed service ${startfail}"
+ eerror " ${SVCNAME} was not started."
+ retval=1
+ elif [[ -n ${startinactive} ]] ; then
+ # Change the last , to or for correct grammar.
+ x="${startinactive##*, }"
+ startinactive="${startinactive/%, ${x}/ or ${x}}"
+ ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started."
+ retval=1
fi
- done
-
- if [[ -n ${startfail} ]] ; then
- eerror "ERROR: Problem starting needed service ${startfail}"
- eerror " ${SVCNAME} was not started."
- retval=1
- elif [[ -n ${startinactive} ]] ; then
- # Change the last , to or for correct grammar.
- x="${startinactive##*, }"
- startinactive="${startinactive/%, ${x}/ or ${x}}"
- ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started."
- retval=1
- elif broken "${SVCNAME}" ; then
- eerror "ERROR: Some services needed are missing. Run"
- eerror " './${SVCNAME} broken' for a list of those"
- eerror " services. ${SVCNAME} was not started."
- retval=1
- else
+ fi
+
+ if [[ ${retval} == "0" ]] ; then
IN_BACKGROUND="${ib_save}"
(
exit() {
@@ -407,15 +416,15 @@ svc_start() {
# If a service has been marked inactive, exit now as something
# may attempt to start it again later
- if service_inactive "${SVCNAME}" ; then
+ if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then
svcinactive=0
service_message "ewarn" "WARNING: ${SVCNAME} has started but is inactive"
return 1
fi
fi
- if [[ ${retval} != 0 ]] ; then
- if [[ ${svcinactive} == 0 ]] ; then
+ if [[ ${retval} != "0" ]] ; then
+ if [[ ${svcinactive} == "0" ]] ; then
mark_service_inactive "${SVCNAME}"
else
mark_service_stopped "${SVCNAME}"
@@ -531,12 +540,16 @@ fi
for arg in $* ; do
case "${arg}" in
--quiet)
+ RC_QUIET="yes"
RC_QUIET_STDOUT="yes"
;;
# We check this in functions.sh ...
# --nocolor)
# RC_NOCOLOR="yes"
# ;;
+ --nodeps)
+ RC_NO_DEPS="yes"
+ ;;
--verbose)
RC_VERBOSE="yes"
;;
@@ -652,7 +665,7 @@ for arg in $* ; do
retval="$?"
svcpause="no"
;;
- --quiet|--nocolor)
+ --quiet|--nocolor|--nodeps)
;;
help)
exec "${svclib}"/sh/rc-help.sh "${myscript}" help