summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-02-06 11:15:46 +0000
committerChristian Heim <phreak@gentoo.org>2006-02-06 11:15:46 +0000
commit72181598d2f778f6988ffd2145f23f20a587c263 (patch)
tree08abcd896637c7df896f967073bd826a6d301b9d /sbin
parentMerging r1832 (diff)
downloadbaselayout-vserver-72181598d2f778f6988ffd2145f23f20a587c263.tar.gz
baselayout-vserver-72181598d2f778f6988ffd2145f23f20a587c263.tar.bz2
baselayout-vserver-72181598d2f778f6988ffd2145f23f20a587c263.zip
Merging r1851
svn path=/baselayout-vserver/trunk/; revision=228
Diffstat (limited to 'sbin')
-rwxr-xr-xsbin/init-common-post.sh6
-rwxr-xr-xsbin/rc18
-rwxr-xr-xsbin/rc-daemon.sh9
-rwxr-xr-xsbin/runscript.sh46
4 files changed, 62 insertions, 17 deletions
diff --git a/sbin/init-common-post.sh b/sbin/init-common-post.sh
index 2537b21..3aed8b8 100755
--- a/sbin/init-common-post.sh
+++ b/sbin/init-common-post.sh
@@ -41,6 +41,9 @@ rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \
echo "sysinit" > "${svcdir}/softlevel"
+# Ensure all critical services have are in the boot runlevel
+check_critical_services
+
# Update the dependency cache
/sbin/depscan.sh -u
@@ -55,4 +58,7 @@ echo "sysinit" > "${svcdir}/softlevel"
done
)
+# sysinit is now done, so allow init scripts to run normally
+[[ -e /dev/.rcsysinit ]] && rm -f /dev/.rcsysinit
+
# vim:ts=4
diff --git a/sbin/rc b/sbin/rc
index 6527d16..eb4a78d 100755
--- a/sbin/rc
+++ b/sbin/rc
@@ -27,6 +27,21 @@ get_critical_services() {
return 0
}
+# void check_critical_services()
+#
+# Ensure that critical services are in the boot runlevel
+#
+check_critical_services() {
+ local x
+
+ for x in ${CRITICAL_SERVICES} ; do
+ if [[ ! -L "/etc/runlevels/${BOOTLEVEL}/${x}" ]] ; then
+ ewarn "WARNING: Adding critical service ${x} to the ${BOOTLEVEL} runlevel"
+ ln -snf "/etc/init.d/${x}" "/etc/runlevels/${BOOTLEVEL}/${x}"
+ fi
+ done
+}
+
# Save $1
argv1=$1
@@ -56,6 +71,9 @@ then
argv1="${BOOTLEVEL}"
fi
+# Ensure all critical services have are in the boot runlevel
+get_critical_services
+check_critical_services
source "${svclib}/sh/rc-services.sh"
if [[ -f "${svcdir}/softlevel" ]] ; then
diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh
index c8cccb5..7e67dcc 100755
--- a/sbin/rc-daemon.sh
+++ b/sbin/rc-daemon.sh
@@ -101,9 +101,8 @@ rc_setup_daemon_vars() {
# We may want to launch the daemon with a custom command
# This is mainly useful for debugging with apps like valgrind, strace
local bash_service="$( bash_variable "${myservice}" )"
- eval x=\"\$\{RC_DAEMON_${bash_service}\}\"
- if [[ -n ${x} ]]; then
- local -a d=( ${x} )
+ if [[ -n ${RC_DAEMON} ]]; then
+ local -a d=( ${RC_DAEMON} )
if ${stopping}; then
args="--stop"
else
@@ -145,7 +144,7 @@ rc_try_kill_pid() {
pkill "-${signal}" -s "${pid}"
pgrep -s "${pid}" >/dev/null || return 0
else
- local pids="$(ps -eo pid,sid | sed -n 's/'${pid}'$//p')"
+ local pids="$(ps -eo pid,sid | sed -n "s/ ${pid}\$//p")"
[[ -z ${pids} ]] && return 0
kill -s "${signal}" ${pids} 2>/dev/null
e=false
@@ -297,7 +296,7 @@ rc_stop_daemon() {
else
local npids
for pid in ${pids} ; do
- npids="${npids} $(ps -eo pid,ppid | sed -n 's/'"${pid}"'$//p')"
+ npids="${npids} $(ps -eo pid,ppid | sed -n "s/ ${pid}\$//p")"
done
pids="${pids} ${npids}"
fi
diff --git a/sbin/runscript.sh b/sbin/runscript.sh
index 7fdd89e..8441fcc 100755
--- a/sbin/runscript.sh
+++ b/sbin/runscript.sh
@@ -20,7 +20,12 @@ fi
myservice="${myservice##*/}"
export SVCNAME="${myservice}"
-mylevel="$(< "${svcdir}/softlevel")"
+
+# Stop init scripts from working until sysinit completes
+if [[ -e /dev/.rcsysinit ]] ; then
+ eerror "ERROR: cannot run ${myservice} until sysinit completes"
+ exit 1
+fi
svc_trap() {
trap 'eerror "ERROR: ${myservice} caught an interrupt"; exit 1' \
@@ -69,6 +74,11 @@ conf="$(add_suffix "/etc/conf.d/${myservice}")"
conf="$(add_suffix /etc/rc.conf)"
[[ -e ${conf} ]] && source "${conf}"
+mylevel="${SOFTLEVEL}"
+[[ ${SOFTLEVEL} == "${BOOTLEVEL}" \
+ || ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] \
+ && mylevel="${DEFAULTLEVEL}"
+
# Call svc_quit if we abort AND we have obtained a lock
service_started "${myservice}"
svcstarted="$?"
@@ -159,7 +169,7 @@ svc_stop() {
trap "svc_quit" INT QUIT TSTP
mark_service_starting "${myservice}"
- service_message "Stopping service ${myservice}"
+ service_message "Service ${myservice} stopping"
if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
[[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
@@ -261,7 +271,7 @@ svc_stop() {
else
mark_service_stopped "${myservice}"
fi
- service_message "Stopped service ${myservice}"
+ service_message "Service ${myservice} stopped"
fi
# Reset the trap
@@ -298,7 +308,7 @@ svc_start() {
# Ensure that we clean up if we abort for any reason
trap "svc_quit" INT QUIT TSTP
- service_message "Starting service ${myservice}"
+ service_message "Service ${myservice} starting"
# Save the IN_BACKGROUND var as we need to clear it for starting depends
local ib_save="${IN_BACKGROUND}"
@@ -381,8 +391,13 @@ svc_start() {
unset -f exit
exit "$@"
}
+
+ # Apply any ulimits if defined
+ [[ -n ${RC_ULIMIT} ]] && ulimit ${RC_ULIMIT}
+
# Stop einfo/ebegin/eend from working as parallel messes us up
[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes"
+
start
)
retval="$?"
@@ -606,17 +621,24 @@ for arg in $* ; do
&& rm -Rf "${svcdir}/scheduled/${myservice}"
# Restart dependencies as well
- if service_inactive "${myservice}" ; then
- for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
- if service_stopped "${x##*/}" ; then
+ for x in $(dolisting "${svcdir}/snapshot/$$/") ; do
+ if service_stopped "${x##*/}" ; then
+ if service_inactive "${myservice}" \
+ || service_wasinactive "${myservice}" ; then
svc_schedule_start "${myservice}" "${x##*/}"
+ ewarn "WARNING: ${x##*/} is scheduled to start when ${myservice} has started."
+ else
+ start_service "${x##*/}"
fi
- done
- elif service_started "${myservice}" ; then
- svc_start_scheduled
- fi
-
+ fi
+ done
rm -rf "${svcdir}/snapshot/$$"
+
+ service_started "${myservice}" && svc_start_scheduled
+
+ # Wait for services to come up
+ [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait
+
svcrestart="no"
;;
pause)