aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/rc/rc49
1 files changed, 34 insertions, 15 deletions
diff --git a/libexec/rc/rc b/libexec/rc/rc
index 35db4a850516..722d7fe35884 100644
--- a/libexec/rc/rc
+++ b/libexec/rc/rc
@@ -91,19 +91,31 @@ if ! [ -e ${firstboot_sentinel} ]; then
skip_firstboot="-s firstboot"
fi
+# rc_parallel_start default is "NO"
+rc_parallel_start=${rc_parallel_start:-NO}
+_rc_parallel=''
+# enable rcorder -p if /etc/rc.conf rc_parallel_start is "YES"
+checkyesno rc_parallel_start && _rc_parallel='-p'
+
# Do a first pass to get everything up to $early_late_divider so that
# we can do a second pass that includes $local_startup directories
#
-files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* 2>/dev/null`
+files=`rcorder ${skip} ${skip_firstboot} ${_rc_parallel} /etc/rc.d/* 2>/dev/null`
_rc_elem_done=' '
-for _rc_elem in ${files}; do
- run_rc_script ${_rc_elem} ${_boot}
- _rc_elem_done="${_rc_elem_done}${_rc_elem} "
-
- case "$_rc_elem" in
- */${early_late_divider}) break ;;
- esac
+IFS=$'\n'
+for _rc_group in ${files}; do
+ IFS=$' '
+ for _rc_elem in ${_rc_group}; do
+ run_rc_script ${_rc_elem} ${_boot} &
+ _rc_elem_done="${_rc_elem_done}${_rc_elem} "
+
+ case "$_rc_elem" in
+ */${early_late_divider}) break ;;
+ esac
+ done
+ wait
+ IFS=$'\n'
done
unset files local_rc
@@ -122,14 +134,21 @@ if [ -e ${firstboot_sentinel} ]; then
skip_firstboot=""
fi
-files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null`
-for _rc_elem in ${files}; do
- case "$_rc_elem_done" in
- *" $_rc_elem "*) continue ;;
- esac
-
- run_rc_script ${_rc_elem} ${_boot}
+files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} ${_rc_parallel} 2>/dev/null`
+IFS=$'\n'
+for _rc_group in ${files}; do
+ IFS=$' '
+ for _rc_elem in ${_rc_group}; do
+ case "$_rc_elem_done" in
+ *" $_rc_elem "*) continue ;;
+ esac
+
+ run_rc_script ${_rc_elem} ${_boot} &
+ done
+ wait
+ IFS=$'\n'
done
+unset IFS
# Remove the firstboot sentinel, and reboot if it was requested.
# Be a bit paranoid about removing it to handle the common failure