summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/runscript.sh')
-rwxr-xr-xsbin/runscript.sh54
1 files changed, 35 insertions, 19 deletions
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index a54ff67..867878b 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -23,19 +23,24 @@ export SVCNAME
# Support deprecated myservice variable
myservice="${SVCNAME}"
+svc_trap() {
+ trap 'eerror "ERROR: ${SVCNAME} caught an interrupt"; exit 1' \
+ INT QUIT TSTP
+}
+
+# Setup a default trap
+svc_trap
+
# 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"
- [[ "${RC_COLDPLUG} " == "!* "* ]] && exit 1
- if [[ "${RC_COLDPLUG} " != "* "* ]] ; then
- for x in ${RC_COLDPLUG} ; do
- # We don't quote ${x} so we can do globbing
- [[ ${SVCNAME} == ${x} ]] && break
- [[ "!${SVCNAME}" == ${x} ]] && exit 1
- done
- [[ ${SVCNAME} == ${x} ]] || exit 1
- fi
+ [[ ${RC_COLDPLUG:-yes} != "yes" ]] && exit 1
+ set -f
+ for x in ${RC_PLUG_SERVICES} ; do
+ [[ ${SVCNAME} == ${x} ]] && break
+ [[ "!${SVCNAME}" == ${x} ]] && exit 1
+ done
eerror "${SVCNAME} will be started in the ${BOOTLEVEL} runlevel"
if [[ ! -L /dev/.rcboot/"${SVCNAME}" ]] ; then
[[ ! -d /dev/.rcboot ]] && mkdir /dev/.rcboot
@@ -44,13 +49,23 @@ if [[ -e /dev/.rcsysinit ]] ; then
exit 1
fi
-svc_trap() {
- trap 'eerror "ERROR: ${SVCNAME} caught an interrupt"; exit 1' \
- INT QUIT TSTP
-}
-
-# Setup a default trap
-svc_trap
+# Only hotplug if we're allowed to
+if [[ ${IN_HOTPLUG} == "1" ]] ; then
+ if [[ ${RC_HOTPLUG:-yes} != "yes" ]] ; then
+ eerror "${SVCNAME} is not allowed to be hotplugged"
+ exit 1
+ fi
+
+ set -f
+ for x in ${RC_PLUG_SERVICES} ; do
+ [[ ${SVCNAME} == ${x} ]] && break
+ if [[ "!${SVCNAME}" == ${x} ]] ; then
+ eerror "${SVCNAME} is not allowed to be hotplugged"
+ exit 1
+ fi
+ done
+ set +f
+fi
# State variables
svcpause="no"
@@ -381,9 +396,10 @@ svc_start() {
&& ! 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}"
+ if svc_schedule_start "${x}" "${SVCNAME}" ; then
+ [[ -n ${startinactive} ]] && startinactive="${startinactive}, "
+ startinactive="${startinactive}${x}"
+ fi
else
startfail="${x}"
break