summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenedikt Boehm <hollow@gentoo.org>2005-09-26 14:29:47 +0000
committerBenedikt Boehm <hollow@gentoo.org>2005-09-26 14:29:47 +0000
commit04e3d8d8d4d5099d0be47fc3db870bd5f9ffc134 (patch)
tree0a263ff3b2d8bd27d58ed29fc8cf551f2b58c2d4 /sbin/runscript.sh
parentfix init timeout (diff)
downloadbaselayout-vserver-04e3d8d8d4d5099d0be47fc3db870bd5f9ffc134.tar.gz
baselayout-vserver-04e3d8d8d4d5099d0be47fc3db870bd5f9ffc134.tar.bz2
baselayout-vserver-04e3d8d8d4d5099d0be47fc3db870bd5f9ffc134.zip
sync with baselayout trunk, rev 1550
svn path=/baselayout-vserver/trunk/; revision=41
Diffstat (limited to 'sbin/runscript.sh')
-rwxr-xr-xsbin/runscript.sh32
1 files changed, 15 insertions, 17 deletions
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index bb31bfc..79820f3 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -20,7 +20,7 @@ svcpause="no"
svcrestart="no"
myscript=$1
-if [[ -L $1 ]] && [[ ! -L /etc/init.d/${1##*/} ]] ; then
+if [[ -L $1 && ! -L /etc/init.d/${1##*/} ]] ; then
myservice=$(readlink "$1")
else
myservice=$1
@@ -97,8 +97,7 @@ svc_stop() {
service_message "Stopping service ${myservice}"
if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
- [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]]
- then
+ [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
ewarn "WARNING: you are stopping a boot service."
fi
@@ -115,8 +114,7 @@ svc_stop() {
# If some service 'need' $mydep, stop it first; or if it is a runlevel change,
# first stop all services that is started 'after' $mydep.
if needsme "${mydep}" >/dev/null || \
- (is_runlevel_stop && ibefore "${mydep}" >/dev/null)
- then
+ (is_runlevel_stop && ibefore "${mydep}" >/dev/null) ; then
local -a sl=( $(needsme "${mydep}") )
# On runlevel change, stop all services "after $mydep" first ...
@@ -133,8 +131,7 @@ svc_stop() {
fi
if ibefore -t "${mydep}" "${x}" >/dev/null && \
- [[ -L ${svcdir}/softscripts.new/${x} ]]
- then
+ [[ -L ${svcdir}/softscripts.new/${x} ]] ; then
# Service do not 'need' $mydep, and is still present in
# new runlevel ...
unset sl[x]
@@ -154,8 +151,7 @@ svc_stop() {
service_stopped "${x}" && continue
if ibefore -t "${mydep}" "${x}" >/dev/null && \
- [[ -L "${svcdir}/softscripts.new/${x}" ]]
- then
+ [[ -L ${svcdir}/softscripts.new/${x} ]] ; then
# Service do not 'need' $mydep, and is still present in
# new runlevel ...
continue
@@ -168,8 +164,8 @@ svc_stop() {
# clean as possible, else do not stop our service if
# a dependent service did not stop.
if needsme -t "${mydep}" "${x}" >/dev/null && \
- [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]]
- then
+ [[ ${SOFTLEVEL} != "reboot" && \
+ ${SOFTLEVEL} != "shutdown" ]] ; then
retval=1
fi
break
@@ -270,7 +266,7 @@ svc_start() {
# Start dependencies, if any
for x in ${startupservices} ; do
- if service_stopped "${x}"; then
+ if service_stopped "${x}" ; then
start_service "${x}"
fi
done
@@ -315,7 +311,7 @@ svc_start() {
service_inactive "${myservice}" && return 1
fi
- if [[ ${retval} != 0 ]]; then
+ if [[ ${retval} != 0 ]] ; then
is_runlevel_start && mark_service_failed "${myservice}"
# Remove link if service didn't start; but only if we're not booting
@@ -400,7 +396,7 @@ svc_homegrown() {
# Walk through the list of available options, looking for the
# requested one.
for x in ${opts} ; do
- if [[ ${x} == ${arg} ]] ; then
+ if [[ ${x} == "${arg}" ]] ; then
if typeset -F "${x}" &>/dev/null ; then
# Run the homegrown function
"${x}"
@@ -468,9 +464,8 @@ for arg in $* ; do
# Simple way to try and detect if the service use svc_{start,stop}
# to restart if it have a custom restart() funtion.
if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${myservice}") ]] ; then
- if [[ -z $(egrep 'svc_stop' "/etc/init.d/${myservice}") ]] || \
- [[ -z $(egrep 'svc_start' "/etc/init.d/${myservice}") ]]
- then
+ if [[ -z $(egrep 'svc_stop' "/etc/init.d/${myservice}") || \
+ -z $(egrep 'svc_start' "/etc/init.d/${myservice}") ]] ; then
echo
ewarn "Please use 'svc_stop; svc_start' and not 'stop; start' to"
ewarn "restart the service in its custom 'restart()' function."
@@ -507,6 +502,9 @@ for arg in $* ; do
;;
--quiet|--nocolor)
;;
+ help)
+ exec "${svclib}"/sh/rc-help.sh "${myscript}" help
+ ;;
*)
# Allow for homegrown functions
svc_homegrown ${arg}