summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-01-19 17:13:13 +0000
committerChristian Heim <phreak@gentoo.org>2006-01-19 17:13:13 +0000
commit2fc04a041525a0215e9eb3ca54e4617c1be7b4f7 (patch)
tree2d0c6f0239789614db2400bdd742d6aa96c1c201
parentMerging r1828 (diff)
downloadbaselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.tar.gz
baselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.tar.bz2
baselayout-vserver-2fc04a041525a0215e9eb3ca54e4617c1be7b4f7.zip
Merging r1832
svn path=/baselayout-vserver/trunk/; revision=212
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLog.vserver14
-rwxr-xr-xnet-scripts/init.d/net.lo29
-rw-r--r--net-scripts/net.modules.d/ifconfig8
-rw-r--r--net-scripts/net.modules.d/iproute29
-rwxr-xr-xsbin/depscan.sh6
-rwxr-xr-xsbin/rc-services.sh47
-rwxr-xr-xsbin/runscript.sh203
8 files changed, 173 insertions, 153 deletions
diff --git a/ChangeLog b/ChangeLog
index 279d4fb..cbf86f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,16 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 19 Jan 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Give a better error message when no valid DHCP client is installed.
+
+ 18 Jan 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Services should not get stuck in rc anymore, #119242.
+
+ We only hotplug net.* scripts on interfaces that are marked as ethernet.
+
16 Jan 2006; Roy Marples <uberlord@gentoo.org>:
Renamed restart in $svcdir to scheduled as it makes much more sense.
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index e279dd7..dc6863e 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,20 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2
+ 19 Jan 2006; Christian Heim <phreak@gentoo.org>:
+ Importing latest baselayout/trunk changes. This merge is based upon
+ revision 1832.
+
+ ChangeLog | 10
+ ChangeLog.vserver | 14 +
+ net-scripts/init.d/net.lo | 29 +-
+ net-scripts/net.modules.d/ifconfig | 8
+ net-scripts/net.modules.d/iproute2 | 9
+ sbin/depscan.sh | 6
+ sbin/rc-services.sh | 47 ++--
+ sbin/runscript.sh | 203 +++++++-----------
+ 8 files changed, 173 insertions(+), 153 deletions(-)
+
17 Jan 2006; Christian Heim <phreak@gentoo.org>:
Importing latest baselayout/trunk changes. This merge is based upon
revision 1828.
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index b9c2352..43bfd46 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -16,7 +16,7 @@ depend() {
# Load any custom depend functions for the given interface
# For example, br0 may need eth0 and eth1
- local iface="${myservice##*.}"
+ local iface="${myservice#*.}"
[[ $(type -t "depend_${iface}") == "function" ]] && depend_${iface}
return 0
@@ -25,10 +25,7 @@ depend() {
# Define where our modules are
MODULES_DIR="${svclib}/net.modules.d"
-# Some defaults
-background="${background:-no}"
-
-# Load some functions shared between ourselves and our dhcp helpers
+# 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.
@@ -571,12 +568,11 @@ iface_start() {
# 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" )
- ewarn "Configuration not set for ${iface} - assuming dhcp"
else
- eerror "Cannot default to dhcp as there is no dhcp module loaded"
- eerror "No configuration for ${iface}"
+ eerror "No DHCP client installed"
return 1
fi
# else
@@ -621,7 +617,11 @@ iface_start() {
[[ ${x} == "0" ]] && interface_add_address "${iface}" ${conf[@]}; x="$?"
eend "${x}" && config_worked=true && continue
else
- eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"
+ if [[ ${conf[0]} == "dhcp" ]] ; then
+ eerror "No DHCP client installed"
+ else
+ eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"
+ fi
fi
if [[ -n ${fallback[config_counter]} ]]; then
@@ -855,11 +855,8 @@ run() {
local -a MODULES mods
local IN_BACKGROUND="${IN_BACKGROUND}"
- # No point in backgrounding if we're already there ...
- # This is also required so we can select the "best" interface
if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]]; then
IN_BACKGROUND=true
- background=false
else
IN_BACKGROUND=false
fi
@@ -885,6 +882,14 @@ run() {
run_stop "${iface}" && r=0
remove_state "${iface}"
else
+ # Only hotplug on ethernet interfaces
+ if [[ ${IN_HOTPLUG} == 1 ]] ; then
+ if ! interface_is_ethernet "${iface}" ; then
+ eerror "We only hotplug for ethernet interfaces"
+ return 1
+ fi
+ fi
+
run_start "${iface}" && r=0
fi
fi
diff --git a/net-scripts/net.modules.d/ifconfig b/net-scripts/net.modules.d/ifconfig
index 05ef95a..eacbd57 100644
--- a/net-scripts/net.modules.d/ifconfig
+++ b/net-scripts/net.modules.d/ifconfig
@@ -97,6 +97,14 @@ ifconfig_get_address() {
[[ -n ${x[0]} ]] && echo "${x[0]}/${x[1]}"
}
+# bool ifconfig_is_ethernet(char *interface)
+#
+# Return 0 if the link is ethernet, otherwise 1.
+ifconfig_is_ethernet() {
+ ifconfig "$1" | grep -q "^$1[[:space:]]*Link encap:Ethernet[[:space:]]"
+}
+
+
# void ifconfig_get_mac_address(char *interface)
#
# Fetch the mac address assingned to the network card
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2
index 8b6a9a7..09fcfa5 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2
@@ -97,12 +97,19 @@ iproute2_get_address() {
| sed -n -e 's/.*inet \([^ ]*\).*/\1/p'
}
+# bool iproute2_is_ethernet(char *interface)
+#
+# Return 0 if the link is ethernet, otherwise 1.
+iproute2_is_ethernet() {
+ ip link show "$1" | grep -q "^[[:space:]]*link/ether[[:space:]]*"
+}
+
# void iproute2_get_mac_address(char *interface)
#
# Fetch the mac address assingned to the network card
iproute2_get_mac_address() {
local mac=$( ip link show "$1" | sed -n -e \
- 's/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
+ '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' )
[[ ${mac} != '00:00:00:00:00:00' \
&& ${mac} != '44:44:44:44:44:44' \
&& ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \
diff --git a/sbin/depscan.sh b/sbin/depscan.sh
index 20669d2..a67b8d7 100755
--- a/sbin/depscan.sh
+++ b/sbin/depscan.sh
@@ -16,7 +16,7 @@ if [[ ! -d ${svcdir} ]] ; then
fi
for x in softscripts snapshot options daemons \
- started starting inactive stopping failed \
+ started starting inactive wasinactive stopping failed \
exclusive exitcodes scheduled ; do
if [[ ! -d "${svcdir}/${x}" ]] ; then
if ! mkdir -p -m 0755 "${svcdir}/${x}" 2>/dev/null ; then
@@ -35,7 +35,7 @@ if [[ $1 == "-u" ]] ; then
# If its not there, we have to update, and make sure its present
# for next mtime testing
- if [[ ! -e ${svcdir}/depcache ]] ; then
+ if [[ ! -e "${svcdir}/depcache" ]] ; then
update=1
touch "${svcdir}/depcache"
fi
@@ -56,7 +56,7 @@ if [[ $1 == "-u" ]] ; then
shift
fi
-[[ ${update} == 0 ]] && exit 0
+[[ ${update} == 0 && -e "${svcdir}/deptree" ]] && exit 0
ebegin "Caching service dependencies"
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 98bbcd9..1b68506 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -378,14 +378,12 @@ start_service() {
# then just start it and return the exit status
( "/etc/init.d/${service}" start )
retval=$?
- end_service "${service}" "${retval}"
return "${retval}"
else
# if parallel startup is allowed, start it in background
(
"/etc/init.d/${service}" start
retval=$?
- end_service "${service}" "${retval}"
) &
return 0
fi
@@ -423,14 +421,12 @@ stop_service() {
# then just start it and return the exit status
( "/etc/init.d/${service}" stop )
retval=$?
- end_service "${service}" "${retval}"
return "${retval}"
else
# if parallel startup is allowed, start it in background
(
( "/etc/init.d/${service}" stop )
retval=$?
- end_service "${service}" "${retval}"
) &
return 0
fi
@@ -445,8 +441,9 @@ mark_service_starting() {
ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1
- [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
+ [[ -f "${svcdir}/inactive/$1" ]] \
+ && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1"
return 0
}
@@ -459,10 +456,12 @@ mark_service_started() {
ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
- [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
- [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
- [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
+ rm -f "${svcdir}/starting/$1" "${svcdir}/inactive/$1" \
+ "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
+ "${svcdir}"/scheduled/*/"$1"
+ end_service "$1" 0
+
return 0
}
@@ -475,9 +474,10 @@ mark_service_inactive() {
ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
- [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
- [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
- [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
+ rm -f "${svcdir}/started/$1" "${svcdir}/wasinactive/$1" \
+ "${svcdir}/starting/$1" "${svcdir}/stopping/$1"
+
+ end_service "$1" 0
return 0
}
@@ -491,8 +491,10 @@ mark_service_stopping() {
ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1
- [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
- [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
+ rm -f "${svcdir}/started/$1"
+ [[ -f "${svcdir}/inactive/$1" ]] \
+ && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1"
+
return 0
}
@@ -503,11 +505,12 @@ mark_service_stopping() {
mark_service_stopped() {
[[ -z $1 ]] && return 1
- [[ -f "${svcdir}/daemons/$1" ]] && rm -f "${svcdir}/daemons/$1"
- [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
- [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
- [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
- [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
+ rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \
+ "${svcdir}/started/$1" "${svcdir}/inactive/$1" \
+ "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
+ "${svcdir}/scheduled/$1"
+
+ end_service "$1" 0
return 0
}
@@ -552,6 +555,14 @@ service_inactive() {
test_service_state "$1" "inactive"
}
+# bool service_wasinactive(service)
+#
+# Returns true if 'service' is inactive
+#
+service_wasinactive() {
+ test_service_state "$1" "wasinactive"
+}
+
# bool service_stopping(service)
#
# Returns true if 'service' is stopping
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 19adc43..7fdd89e 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -11,10 +11,6 @@ if [[ ${EUID} != 0 ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then
exit 1
fi
-# State variables
-svcpause="no"
-svcrestart="no"
-
myscript="$1"
if [[ -L $1 && ! -L "/etc/init.d/${1##*/}" ]] ; then
myservice="$(readlink "$1")"
@@ -27,13 +23,17 @@ export SVCNAME="${myservice}"
mylevel="$(< "${svcdir}/softlevel")"
svc_trap() {
- trap 'eerror "ERROR: \"${myservice}\" caught an interrupt"; exit 1' \
+ trap 'eerror "ERROR: ${myservice} caught an interrupt"; exit 1' \
INT QUIT TSTP
}
# Setup a default trap
svc_trap
+# State variables
+svcpause="no"
+svcrestart="no"
+
# Functions to handle dependencies and services
[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"
# Functions to control daemons
@@ -76,7 +76,6 @@ service_inactive "${myservice}"
svcinactive="$?"
svc_quit() {
eerror "ERROR: ${myservice} caught an interrupt"
- end_service "${myservice}"
if service_inactive "${myservice}" || [[ ${svcinactive} == 0 ]] ; then
mark_service_inactive "${myservice}"
elif [[ ${svcstarted} == 0 ]] ; then
@@ -132,7 +131,7 @@ svc_start_scheduled() {
services="${services} ${x##*/}"
done
- for x in $(trace_dependencies "${services}") ; do
+ for x in ${services} ; do
service_stopped "${x}" && start_service "${x}"
rm -f "${svcdir}/scheduled/${myservice}/${x}"
done
@@ -143,29 +142,23 @@ svc_start_scheduled() {
svc_stop() {
local x= mydep= mydeps= retval=0
local -a servicelist=()
-
- # Do not try to stop if it had already failed to do so on runlevel change
+
+ # Do not try to stop if it had already failed to do so
if is_runlevel_stop && service_failed "${myservice}" ; then
return 1
- fi
-
- if service_stopped "${myservice}" ; then
+ elif service_stopped "${myservice}" ; then
ewarn "WARNING: ${myservice} has not yet been started."
return 0
fi
-
if ! mark_service_stopping "${myservice}" ; then
- ewarn "WARNING: ${myservice} is already stopping."
- return 0
+ eerror "ERROR: ${myservice} is already stopping."
+ return 1
fi
- # Lock service starting too ...
- mark_service_starting "${myservice}"
-
+
# Ensure that we clean up if we abort for any reason
trap "svc_quit" INT QUIT TSTP
-
- begin_service "${myservice}"
-
+
+ mark_service_starting "${myservice}"
service_message "Stopping service ${myservice}"
if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
@@ -202,8 +195,6 @@ svc_stop() {
done
done
- [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait
-
for x in "${service_list[@]}" ; do
# We need to test if the service has been marked stopped
# as the fifo may still be around if called by custom code
@@ -242,7 +233,6 @@ svc_stop() {
# may attempt to start it again later
if service_inactive "${myservice}" ; then
svcinactive=0
- end_service "${myservice}" 0
return 0
fi
fi
@@ -253,7 +243,9 @@ svc_stop() {
is_runlevel_stop && mark_service_failed "${myservice}"
# If we are halting the system, do it as cleanly as possible
- if [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
+ if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
+ mark_service_stopped "${myservice}"
+ else
if [[ ${svcinactive} == 0 ]] ; then
mark_service_inactive "${myservice}"
else
@@ -263,8 +255,6 @@ svc_stop() {
service_message "eerror" "ERROR: ${myservice} failed to stop"
else
- # If we're stopped from a daemon that sets ${IN_BACKGROUND} such as
- # wpa_monitor when we mark as inactive instead of taking the down
svcstarted=1
if service_inactive "${myservice}" ; then
svcinactive=0
@@ -274,8 +264,6 @@ svc_stop() {
service_message "Stopped service ${myservice}"
fi
- end_service "${myservice}" "${retval}"
-
# Reset the trap
svc_trap
@@ -288,14 +276,9 @@ svc_start() {
# Do not try to start if i have done so already on runlevel change
if is_runlevel_start && service_failed "${myservice}" ; then
return 1
- fi
-
- if service_started "${myservice}" ; then
+ elif service_started "${myservice}" ; then
ewarn "WARNING: ${myservice} has already been started."
return 0
- elif service_stopping "${myservice}" ; then
- eerror "ERROR: please wait for ${myservice} to stop first."
- return 1
elif service_inactive "${myservice}" ; then
if [[ ${IN_BACKGROUND} != "true" ]] ; then
ewarn "WARNING: ${myservice} has already been started."
@@ -304,42 +287,44 @@ svc_start() {
fi
if ! mark_service_starting "${myservice}" ; then
- ewarn "WARNING: ${myservice} is already starting."
- return 0
+ if service_stopping "${myservice}" ; then
+ eerror "ERROR: ${myservice} is already stopping."
+ else
+ eerror "ERROR: ${myservice} is already starting."
+ fi
+ return 1
fi
# Ensure that we clean up if we abort for any reason
trap "svc_quit" INT QUIT TSTP
-
- begin_service "${myservice}"
+
service_message "Starting service ${myservice}"
# Save the IN_BACKGROUND var as we need to clear it for starting depends
local ib_save="${IN_BACKGROUND}"
unset IN_BACKGROUND
-
- local startupservices="$(trace_dependencies $(ineed "${myservice}") \
- $(valid_iuse "${myservice}"))"
- local netservices="$(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
- $(dolisting "/etc/runlevels/${mylevel}/net.*")"
- local startupnetservices=
- # Start dependencies, if any.
- # We don't handle "after" deps here as it's the job of rc to start them.
- for x in ${startupservices} ; do
- if [[ ${x} == "net" && ${NETSERVICE} != "yes" ]] && ! is_net_up ; then
- for y in ${netservices} ; do
- y="${y##*/}"
- service_stopped "${y}" && start_service "${y}"
- done
- elif [[ ${x} != "net" ]] ; then
- if service_stopped "${x}" ; then
- start_service "${x}"
- fi
- fi
+ local startupservices="$(ineed "${myservice}") $(valid_iuse "${myservice}")"
+ local netservices=
+ for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \
+ $(dolisting "/etc/runlevels/${mylevel}/net.*") ; do
+ netservices="${netservices} ${x##*/}"
done
- [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait
+ # 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
# We also wait for any services we're after to finish incase they
# have a "before" dep but we don't dep on them.
@@ -347,50 +332,35 @@ svc_start() {
startupservices="${startupservices} $(valid_iafter "${myservice}")"
fi
+ if [[ " ${startupservices} " == *" net "* ]] ; then
+ startupservices=" ${startupservices} "
+ startupservices="${startupservices/ net / ${netservices} }"
+ startupservices="${startupservices// net /}"
+ fi
+
# Wait for dependencies to finish.
for x in ${startupservices} ; do
- if [[ ${x} == "net" && ${NETSERVICE} != "yes" ]] ; then
- for y in ${netservices} ; do
- y="${y##*/}"
- # Don't wait if it's already been started
- service_started "${y}" && continue
- wait_service "${y}"
- if ! service_started "${y}" ; then
- # A 'need' dependency is critical for startup
- if ineed -t "${myservice}" "${x}" >/dev/null ; then
- if ! is_net_up ; then
- if service_inactive "${y}" ; then
- svc_schedule_start "${y}" "${myservice}"
- startinactive="${y}"
- else
- startfail="${y}"
- fi
- break
- fi
- fi
- fi
- done
- elif [[ ${x} != "net" ]] ; then
- # Don't wait if it's already been started
- service_started "${x}" && continue
- wait_service "${x}"
- if ! service_started "${x}" ; then
- # A 'need' dependacy is critical for startup
- if ineed -t "${myservice}" "${x}" >/dev/null ; then
- if service_inactive "${x}" ; then
- svc_schedule_start "${x}"
- startinactive="${x}"
- else
- startfail="${x}"
- fi
- break
+ service_started "${x}" && continue
+ wait_service "${x}"
+ if ! service_started "${x}" ; then
+ # A 'need' dependency is critical for startup
+ if ineed -t "${myservice}" "${x}" >/dev/null \
+ || net_service "${x}" && ineed -t "${myservice}" 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}" "${myservice}"
+ startinactive="${x}"
+ else
+ startfail="${x}"
fi
+ break
fi
fi
done
- if [[ ${startfail} == "yes" ]] ; then
- eerror "ERROR: Problem starting needed service ${startfail}."
+ if [[ -n ${startfail} ]] ; then
+ eerror "ERROR: Problem starting needed service ${startfail}"
eerror " ${myservice} was not started."
retval=1
elif [[ -n ${startinactive} ]] ; then
@@ -422,21 +392,15 @@ svc_start() {
if service_inactive "${myservice}" ; then
svcinactive=0
service_message "ewarn" "WARNING: ${myservice} has started but is inactive"
- end_service "${myservice}" 1
return 1
fi
fi
if [[ ${retval} != 0 ]] ; then
- # Remove link if service didn't start; but only if we're not booting
- # If we're booting, we need to continue and do our best to get the
- # system up.
- if [[ ${SOFTLEVEL} != "${BOOTLEVEL}" ]] ; then
- if [[ ${svcinactive} == 0 ]] ; then
- mark_service_inactive "${myservice}"
- else
- mark_service_stopped "${myservice}"
- fi
+ if [[ ${svcinactive} == 0 ]] ; then
+ mark_service_inactive "${myservice}"
+ else
+ mark_service_stopped "${myservice}"
fi
if [[ -z ${startinactive} ]] ; then
@@ -449,7 +413,6 @@ svc_start() {
service_message "Service ${myservice} started"
fi
- end_service "${myservice}" "${retval}"
# Reset the trap
svc_trap
@@ -561,6 +524,8 @@ for arg in $* ; do
;;
esac
done
+
+retval=0
for arg in $* ; do
case "${arg}" in
stop)
@@ -585,31 +550,26 @@ for arg in $* ; do
svc_schedule_start "${myservice}" "${x##*/}"
fi
done
+ else
+ rm -f "${svcdir}"/scheduled/*/"${myservice}"
fi
-
- exit "${retval}"
+
;;
start)
svc_start
- retval=$?
+ retval="$?"
service_started "${myservice}" && svc_start_scheduled
- exit "${retval}"
;;
needsme|ineed|usesme|iuse|broken)
trace_dependencies "-${arg}"
;;
status)
svc_status
+ retval="$?"
;;
zap)
- if [[ -e "${svcdir}/scheduled/${myservice}" ]] ; then
- rm -Rf "${svcdir}/scheduled/${myservice}"
- fi
- if ! service_stopped "${myservice}" ; then
- einfo "Manually resetting ${myservice} to stopped state."
- mark_service_stopped "${myservice}"
- fi
- end_service "${myservice}"
+ einfo "Manually resetting ${myservice} to stopped state."
+ mark_service_stopped "${myservice}"
;;
restart)
svcrestart="yes"
@@ -640,6 +600,7 @@ for arg in $* ; do
else
restart
fi
+ retval="$?"
[[ -e "${svcdir}/scheduled/${myservice}" ]] \
&& rm -Rf "${svcdir}/scheduled/${myservice}"
@@ -661,6 +622,7 @@ for arg in $* ; do
pause)
svcpause="yes"
svc_stop
+ retval="$?"
svcpause="no"
;;
--quiet|--nocolor)
@@ -671,8 +633,11 @@ for arg in $* ; do
*)
# Allow for homegrown functions
svc_homegrown ${arg}
+ retval="$?"
;;
esac
done
+exit "${retval}"
+
# vim:ts=4