summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-05-25 10:09:00 +0000
committerChristian Heim <phreak@gentoo.org>2006-05-25 10:09:00 +0000
commit641e205510a26ca3ae4ed9d3f7e27221e2656bb7 (patch)
tree86e317c5d043dfbde91cb981229623ca4a189c52
parentMerging baselayout r2022 for branches/rc-scripts_1_6, branches/baselayout-1_1... (diff)
downloadbaselayout-vserver-641e205510a26ca3ae4ed9d3f7e27221e2656bb7.tar.gz
baselayout-vserver-641e205510a26ca3ae4ed9d3f7e27221e2656bb7.tar.bz2
baselayout-vserver-641e205510a26ca3ae4ed9d3f7e27221e2656bb7.zip
Merging r2046
svn path=/baselayout-vserver/trunk/; revision=365
-rw-r--r--ChangeLog150
-rw-r--r--ChangeLog.vserver4
-rw-r--r--etc/conf.d/rc26
-rwxr-xr-xinit.d/halt.sh3
-rw-r--r--net-scripts/conf.d/net.example5
-rwxr-xr-xnet-scripts/init.d/net.lo10
-rw-r--r--net-scripts/net/br2684ctl.sh15
-rw-r--r--net-scripts/net/bridge.sh26
-rwxr-xr-xsbin/depscan.sh2
-rwxr-xr-xsbin/functions.sh16
-rwxr-xr-xsbin/rc55
-rwxr-xr-xsbin/rc-services.sh29
-rwxr-xr-xsbin/runscript.sh54
-rw-r--r--src/runscript.c4
14 files changed, 312 insertions, 87 deletions
diff --git a/ChangeLog b/ChangeLog
index 660f318..99fe554 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,156 @@
revert the -k2 addition to sort in halt.sh as we only echo the second
key to sort, #131001.
+ 24 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Ensure that we call halt.sh in a new shell with LC_ALL=C so that we don't
+ load any locale information which may stop us unmounting /usr, #128848
+ and #133090.
+
+ Don't set clock for OpenVZ systems, #133265 thanks to Kir Kolyshkin.
+
+ Don't remount / in checkroot for unionfs /, #129975 thanks to Daniel.
+
+ Don't stop net interfaces / is unionfs and a branch is network mounted.
+
+* baselayout-1.12.0 (23 May 2006)
+
+ 23 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ halt.sh can now deal with unionfs a bit better, #99682.
+
+ 16 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Always report Xen domU domains correctly, #107976.
+
+ 15 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Always test for space at the end of the bridge name.
+
+ 14 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Don't stop coldplugged services when changing runlevels, #113264.
+
+ Only report inactive start once.
+
+ 13 May 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Remove SVCDIR from functions.sh #133171 by petre rodan.
+
+ 07 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Fix logic in br2684ctl.sh as reported by Alin Nastac, #132549.
+
+ 05 May 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Fix typo s/veend/vewend/ in functions.sh as reported by Yoshino #132262.
+
+ 05 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ If a device initiated service is in the default runlevel then we no
+ longer start it in the boot runlevel.
+
+ 04 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ RC_COLDPLUG is now just a yes|no setting and the service list allowed
+ is now in RC_PLUG_SERVICES.
+ Added RC_HOTPLUG setting similar to RC_COLDPLUG.
+
+* baselayout-1.12.0_pre19 (02 May 2006)
+
+ 01 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ /proc/net/wireless may not have whitespace after $iface:
+ wpa_supplicant no longer requires ctrl_interface set.
+ Thanks to kelmo for those ideas.
+
+ 28 Apr 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Tweak is_older_than than so it skips checking the timestamps on directories,
+ just the files in the directory.
+
+ Rewrite modules-update to make it readable and usuable without old modutils.
+
+ 24 Apr 2006; Roy Marples <uberlord@gentoo.org>:
+
+ revert the -k2 addition to sort in halt.sh as we only echo the second
+ key to sort, #131001.
+
+ 24 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Ensure that we call halt.sh in a new shell with LC_ALL=C so that we don't
+ load any locale information which may stop us unmounting /usr, #128848
+ and #133090.
+
+ Don't set clock for OpenVZ systems, #133265 thanks to Kir Kolyshkin.
+
+ Don't remount / in checkroot for unionfs /, #129975 thanks to Daniel.
+
+ Don't stop net interfaces / is unionfs and a branch is network mounted.
+
+* baselayout-1.12.0 (23 May 2006)
+
+ 23 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ halt.sh can now deal with unionfs a bit better, #99682.
+
+ 16 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Always report Xen domU domains correctly, #107976.
+
+ 15 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Always test for space at the end of the bridge name.
+
+ 14 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Don't stop coldplugged services when changing runlevels, #113264.
+
+ Only report inactive start once.
+
+ 13 May 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Remove SVCDIR from functions.sh #133171 by petre rodan.
+
+ 07 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ Fix logic in br2684ctl.sh as reported by Alin Nastac, #132549.
+
+ 05 May 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Fix typo s/veend/vewend/ in functions.sh as reported by Yoshino #132262.
+
+ 05 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ If a device initiated service is in the default runlevel then we no
+ longer start it in the boot runlevel.
+
+ 04 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ RC_COLDPLUG is now just a yes|no setting and the service list allowed
+ is now in RC_PLUG_SERVICES.
+ Added RC_HOTPLUG setting similar to RC_COLDPLUG.
+
+* baselayout-1.12.0_pre19 (02 May 2006)
+
+ 01 May 2006; Roy Marples <uberlord@gentoo.org>:
+
+ /proc/net/wireless may not have whitespace after $iface:
+ wpa_supplicant no longer requires ctrl_interface set.
+ Thanks to kelmo for those ideas.
+
+ 28 Apr 2006; Mike Frysinger <vapier@gentoo.org>:
+
+ Tweak is_older_than than so it skips checking the timestamps on directories,
+ just the files in the directory.
+
+ Rewrite modules-update to make it readable and usuable without old modutils.
+
+ 24 Apr 2006; Roy Marples <uberlord@gentoo.org>:
+
+ revert the -k2 addition to sort in halt.sh as we only echo the second
+ key to sort, #131001.
+
* baselayout-1.12.0_pre18 (22 Apr 2006)
22 Apr 2006; Mike Frysinger <vapier@gentoo.org>:
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index 169ca5c..61e2bd2 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,10 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 25 May 2006; Christian Heim <phreak@gentoo.org>:
+ Merging latest changes to the baselayout/trunk changes. This merge is based
+ upon revision 2046.
+
21 Apr 2006; Christian Heim <phreak@gentoo.org>:
Merging latest changes to the baselayout/trunk changes. This merge is based
upon revision 2014.
diff --git a/etc/conf.d/rc b/etc/conf.d/rc
index 49b5b19..e383975 100644
--- a/etc/conf.d/rc
+++ b/etc/conf.d/rc
@@ -10,15 +10,29 @@ RC_TTY_NUMBER=0
RC_PARALLEL_STARTUP="no"
+# Do we allow services to be hotplugged? If not, set to RC_HOTPLUG="no"
+# NOTE: This does not affect anything hotplug/udev related, just the
+# starting/stopping of the init.d service triggered by hotplug.
+
+RC_HOTPLUG="yes"
+
# Dynamic /dev managers can trigger coldplug events which cause services to
# start before we are ready for them. If this happens, we can defer these
-# services to start in the boot runlevel. RC_COLDPLUG is a list of services we
-# allow to be coldplugged in this way. Globbing is allowed as is prefixing
-# with ! which means don't coldplug.
-# Example - RC_COLDPLUG="net.wlan !net.* *"
-# This allows net.wlan and any service not matching net.* to coldplug.
+# services to start in the boot runlevel. Set RC_COLDPLUG="no" if you don't
+# want this.
+# NOTE: This does not affect anything coldplug/udev related, just the
+# starting/stopping of the init.d service triggered by coldplug.
+
+RC_COLDPLUG="yes"
+
+# Some people want a finer grain over hotplug/coldplug. RC_PLUG_SERVICES is a
+# list of services that are matched in order, either allowing or not. By
+# default we allow services through as RC_COLDPLUG/RC_HOTPLUG has to be yes
+# anyway.
+# Example - RC_PLUG_SERVICES="net.wlan !net.*"
+# This allows net.wlan and any service not matching net.* to be plugged.
-RC_COLDPLUG="*"
+RC_PLUG_SERVICES=""
# RC_NET_STRICT_CHECKING allows some flexibility with the 'net' service.
# The following values are allowed:
diff --git a/init.d/halt.sh b/init.d/halt.sh
index 117fc6f..9e23ab0 100755
--- a/init.d/halt.sh
+++ b/init.d/halt.sh
@@ -1,6 +1,9 @@
+#!/bin/bash
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
+
# Write a reboot record to /var/log/wtmp before unmounting
halt -w &>/dev/null
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index 2d62a18..10c10c9 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -557,6 +557,11 @@
# You have to specify a VPI and VCI for the interface like so
#br2684ctl_nas0="-a 0.38" # UK VPI and VCI
+# You may want to configure the encapulation method as well by adding the -e
+# option to the command above (may need to be before the -a command)
+# -e 0 # LLC (default)
+# -e 1 # VC mux
+
# Then you can configure the interface as normal
#config_nas0=( "192.168.0.1/24" )
diff --git a/net-scripts/init.d/net.lo b/net-scripts/init.d/net.lo
index ed46320..e5e4990 100755
--- a/net-scripts/init.d/net.lo
+++ b/net-scripts/init.d/net.lo
@@ -976,9 +976,17 @@ run_stop() {
( predown "${iface}" )
eend $? "predown ${iface} failed" || return 1
eoutdent
- elif is_net_fs /; then
+ elif is_net_fs / ; then
eerror "root filesystem is network mounted -- can't stop ${iface}"
return 1
+ elif is_union_fs / ; then
+ for x in $(unionctl "${dir}" --list \
+ | sed -e 's/^\(.*\) .*/\1/') ; do
+ if is_net_fs "${x}" ; then
+ eerror "Part of the root filesystem is network mounted - cannot stop ${iface}"
+ return 1
+ fi
+ done
fi
iface_stop "${iface}" || return 1 # always succeeds, btw
diff --git a/net-scripts/net/br2684ctl.sh b/net-scripts/net/br2684ctl.sh
index 445d2f1..e325817 100644
--- a/net-scripts/net/br2684ctl.sh
+++ b/net-scripts/net/br2684ctl.sh
@@ -35,16 +35,15 @@ br2684ctl_pre_start() {
return 1
fi
- if [[ " ${!opts} " != *" -b "* ]] ; then
- eerror "The -b option is not allowed for br2684ctl_${ifvar}"
+ if [[ " ${!opts} " == *" -b "* || " {!opts} " == *" -c "* ]] ; then
+ eerror "The -b and -c options are not allowed for br2684ctl_${ifvar}"
return 1
fi
einfo "Starting RFC 2684 Bridge control on ${iface}"
-
start-stop-daemon --start --exec /sbin/br2684ctl --background \
--make-pidfile --pidfile "/var/run/br2684ctl-${iface}.pid" \
- -- ${!opts} -c "${number}"
+ -- -c "${number}" ${!opts}
eend $?
}
@@ -52,14 +51,14 @@ br2684ctl_pre_start() {
br2684ctl_post_stop() {
local iface="$1"
local number="${iface#${iface%%[0-9]}}"
+ local pidfile="/var/run/br2684ctl-${iface}.pid"
- [[ $(itype "${iface}") != "nas" ]] && return 0
+ [[ $(interface_type "${iface}") != "nas" ]] && return 0
- [[ -e /var/run/br2864ctl-${iface}.pid ]] || return 0
+ [[ -e ${pidfile} ]] || return 0
einfo "Stopping RFC 2684 Bridge control on ${iface}"
- start-stop-daemon --stop --exec /sbin/br2864ctl \
- --pidfile "/var/run/br2684ctl-${iface}.pid"
+ start-stop-daemon --stop --exec /sbin/br2684ctl --pidfile "${pidfile}"
eend $?
}
diff --git a/net-scripts/net/bridge.sh b/net-scripts/net/bridge.sh
index 67af002..2d4e6f5 100644
--- a/net-scripts/net/bridge.sh
+++ b/net-scripts/net/bridge.sh
@@ -36,29 +36,33 @@ bridge_check_installed() {
# Returns the interfaces added to the given bridge
bridge_get_ports() {
brctl show 2>/dev/null \
- | sed -n -e '/^'"$1"'/,/^\S/ { /^\('"$1"'\|\t\)/s/^.*\t//p }'
+ | sed -n -e '/^'"$1"'[[:space:]]/,/^\S/ { /^\('"$1"'[[:space:]]\|\t\)/s/^.*\t//p }'
}
# char* bridge_get_bridge(char *interface)
#
# Returns the bridge interface of the given interface
bridge_get_bridge() {
- local x="$( brctl show 2>/dev/null \
- | sed -e '1 {d}; /^[^ ]/ { N }; /.*'"$1"'.*/ {s/^\([^ \t]\+\).*/\1/p}; d')"
-
- local -a a=( ${x} )
- if [[ ${#a[@]} == "1" ]] ; then
- echo "${x}"
- elif [[ $1 == "${a[3]}" ]] ; then
- echo "${a[0]}"
- fi
+ local myiface="$1"
+ local bridge= idx= stp= iface= x=
+ while read bridge idx stp iface x ; do
+ if [[ -z ${iface} ]] ; then
+ iface="${stp}"
+ stp="${idx}"
+ idx="${bridge}"
+ fi
+ if [[ ${iface} == "${myiface}" ]] ; then
+ echo "${bridge}"
+ return 0
+ fi
+ done < <(brctl show 2>/dev/null)
}
# bool bridge_exists(char *interface)
#
# Returns 0 if the bridge exists, otherwise 1
bridge_exists() {
- brctl show 2>/dev/null | grep -q "^$1"
+ brctl show 2>/dev/null | grep -q "^$1[[:space:]]"
}
# bool bridge_create(char *interface)
diff --git a/sbin/depscan.sh b/sbin/depscan.sh
index e9454a1..d0cff4a 100755
--- a/sbin/depscan.sh
+++ b/sbin/depscan.sh
@@ -68,7 +68,7 @@ fi
for x in softscripts snapshot options daemons \
started starting inactive wasinactive stopping failed \
- exclusive exitcodes scheduled ; do
+ exclusive exitcodes scheduled coldplugged ; do
if [[ ! -d "${mysvcdir}/${x}" ]] ; then
if ! mkdir -p -m 0755 "${mysvcdir}/${x}" 2>/dev/null ; then
eerror "Could not create needed directory '${mysvcdir}/${x}'!"
diff --git a/sbin/functions.sh b/sbin/functions.sh
index 423ada6..96f74ba 100755
--- a/sbin/functions.sh
+++ b/sbin/functions.sh
@@ -6,9 +6,6 @@ RC_GOT_FUNCTIONS="yes"
# Override defaults with user settings ...
[[ -f /etc/conf.d/rc ]] && source /etc/conf.d/rc
-# daemontools dir
-SVCDIR="/var/lib/supervise"
-
# Check /etc/conf.d/rc for a description of these ...
declare -r svclib="/lib/rcscripts"
declare -r svcdir="${svcdir:-/var/lib/init.d}"
@@ -340,7 +337,7 @@ veend() {
[[ ${RC_VERBOSE} == "yes" ]] && { eend "$@"; return $?; }
return ${1:-0}
}
-veend() {
+vewend() {
[[ ${RC_VERBOSE} == "yes" ]] && { ewend "$@"; return $?; }
return ${1:-0}
}
@@ -510,6 +507,17 @@ is_net_fs() {
return $?
}
+# bool is_net_fs(path)
+#
+# return 0 if path is under unionfs control
+#
+# EXAMPLE: if is_union_fs / ; then ...
+#
+is_union_fs() {
+ [[ ! -x /sbin/unionctl ]] && return 1
+ unionctl "$1" --list &>/dev/null
+}
+
# bool is_uml_sys()
#
# return 0 if the currently running system is User Mode Linux
diff --git a/sbin/rc b/sbin/rc
index 48b63f0..368deeb 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -123,8 +123,16 @@ else
# As we're in the bootlevel, add any services that failed due
# to /dev/.rcsysinit existing to the list
if [[ -d /dev/.rcboot ]] ; then
+ COLDPLUG_SERVICES=
for x in $(dolisting /dev/.rcboot/) ; do
- [[ -L ${x} ]] && myscripts="${myscripts} ${x##*/}"
+ [[ -L ${x} ]] && COLDPLUG_SERVICES="${COLDPLUG_SERVICES} ${x##*/}"
+ done
+ for x in ${COLDPLUG_SERVICES} ; do
+ if [[ ! -e /etc/runlevels/"${BOOTLEVEL}"/"${x}" \
+ && ! -e /etc/runlevels/"${DEFAULTLEVEL}"/"${x}" ]] ; then
+ myscripts="${myscripts} ${x}"
+ mark_service_coldplugged "${x}"
+ fi
done
einfo "Device initiated services:${HILITE}${myscripts}${NORMAL}"
rm -rf /dev/.rcboot
@@ -171,23 +179,15 @@ dep_stop() {
service_stopped "${myservice}" && return 0
- # Candidate for zapping ?
- [[ ! -L "${svcdir}/softscripts.new/${myservice}" ]] || \
- return 0
-
- # If this is a 'net' service, we do not want to stop it if it was
- # not in the previous runlevel, and we are not shutting down,
- # rebooting or going to single runlevel. This is because the user
- # (or hotplut) might have started it (net.ppp?) ...
- if net_service "${myservice}" && \
- [[ ${SOFTLEVEL} != "reboot" && \
- ${SOFTLEVEL} != "shutdown" ]] ; then
- if [[ -z ${OLDSOFTLEVEL} ]] || \
- ! in_runlevel "${myservice}" "${OLDSOFTLEVEL}" ; then
- # This service is not in the previous runlevel, so
- # do not stop it ...
- return 0
- fi
+ [[ -L ${svcdir}/softscripts.new/${service} ]] \
+ && return 0
+
+ if [[ ${SOFTLEVEL} != "reboot" \
+ && ${SOFTLEVEL} != "shutdown" ]] ; then
+ service_coldplugged "${service}" && return 0
+ [[ -z ${OLDSOFTLEVEL} ]] \
+ || ! in_runlevel "${service}" "${OLDSOFTLEVEL}" \
+ && return 0
fi
# Should not work for 'use'
@@ -254,24 +254,15 @@ fi
echo "${SOFTLEVEL}" > "${svcdir}/softlevel"
if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then
- source /sbin/functions.sh
-
# Clear $svcdir from stale entries, but leave the caches around, as it
# should help speed things up a bit
rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \
grep -ve '\(depcache\|deptree\|envcache\)')
-
- # Need try(), etc
- source "${svclib}"/sh/init-functions.sh
- source /etc/init.d/halt.sh
-
- if [[ ${SOFTLEVEL} == "reboot" ]] ; then
- source /etc/init.d/reboot.sh
- else
- source /etc/init.d/shutdown.sh
- fi
-
+ # Call halt.sh with LC_ALL=C so that bash doesn't load any locales
+ # which could interfere with unmounting /usr
+ LC_ALL=C exec /etc/init.d/halt.sh "${SOFTLEVEL}"
+
# Should never get here
exit 0
fi
@@ -292,7 +283,7 @@ get_start_services() {
-L "${svcdir}/softscripts/${LOGGER_SERVICE}" ]] && \
list="${list} ${LOGGER_SERVICE}"
- for x in $(dolisting "${svcdir}/softscripts/") ; do
+ for x in $(dolisting "${svcdir}/softscripts/") ; do
list="${list} ${x##*/}"
done
diff --git a/sbin/rc-services.sh b/sbin/rc-services.sh
index 25e1805..301669d 100755
--- a/sbin/rc-services.sh
+++ b/sbin/rc-services.sh
@@ -405,12 +405,14 @@ start_service() {
# if we can not start the services in parallel
# then just start it and return the exit status
( "/etc/init.d/${service}" start )
+ service_started "${service}" || service_inactive "${service}"
retval=$?
return "${retval}"
else
# if parallel startup is allowed, start it in background
(
- "/etc/init.d/${service}" start
+ "/etc/init.d/${service}" start
+ service_started "${service}" || service_inactive "${service}"
retval=$?
) &
return 0
@@ -448,18 +450,31 @@ stop_service() {
# if we can not start the services in parallel
# then just start it and return the exit status
( "/etc/init.d/${service}" stop )
+ service_stopped "${service}"
retval=$?
return "${retval}"
else
# if parallel startup is allowed, start it in background
(
( "/etc/init.d/${service}" stop )
+ service_stopped "${service}"
retval=$?
) &
return 0
fi
}
+# bool mark_service_coldplugged(service)
+#
+# Mark 'service' as coldplugged.
+#
+mark_service_coldplugged() {
+ [[ -z $1 ]] && return 1
+
+ ln -snf "/etc/init.d/$1" "${svcdir}/coldplugged/$1"
+ return 0
+}
+
# bool mark_service_starting(service)
#
# Mark 'service' as starting.
@@ -536,7 +551,8 @@ mark_service_stopped() {
rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \
"${svcdir}/started/$1" "${svcdir}/inactive/$1" \
"${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
- "${svcdir}/scheduled/$1" "${svcdir}/options/$1"
+ "${svcdir}/scheduled/$1" "${svcdir}/options/$1" \
+ "${svcdir}/coldplugged/$1"
end_service "$1" 0
@@ -559,6 +575,14 @@ test_service_state() {
return 1
}
+# bool service_coldplugged(service)
+#
+# Returns true if 'service' is coldplugged
+#
+service_coldplugged() {
+ test_service_state "$1" "coldplugged"
+}
+
# bool service_starting(service)
#
# Returns true if 'service' is starting
@@ -718,7 +742,6 @@ valid_i() {
${x} == "net" ]] \
&& echo "${x}"
done
-
return 0
}
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
diff --git a/src/runscript.c b/src/runscript.c
index 73e41a0..e519b1f 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -16,8 +16,8 @@
#include <sys/wait.h>
#include <dlfcn.h>
-#include "core/debug.h"
-#include "core/misc.h"
+#include "core/librcscripts/api/debug.h"
+#include "core/librcscripts/api/misc.h"
#ifndef LIBDIR
# define LIBDIR "lib"