mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-01 08:33:24 +00:00
Introduce startup scripts from the local_startup directories to
the base rcorder. This is accomplished by running rcorder twice, first to get all the disks mounted (through mountcritremote), then again to include the local_startup directories. This dramatically changes the behavior of rc.d/localpkg, as all "local" scripts that have the new rc.d semantics are now run in the base rcorder, so only scripts that have not been converted yet will run in rc.d/localpkg. Make a similar change in rc.shutdown, and add some functions in rc.subr to support these changes. Bump __FreeBSD_version to reflect this change.
This commit is contained in:
parent
0eeba503f6
commit
0f3ce2b32c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153027
34
etc/rc
34
etc/rc
@ -53,7 +53,7 @@ export HOME PATH
|
||||
. /etc/rc.subr
|
||||
|
||||
# Note: the system configuration files are loaded as part of
|
||||
# the RCNG system (rc.d/rcconf.sh). Do not load them here as it may
|
||||
# the rc.d system (rc.d/rcconf.sh). Do not load them here as it may
|
||||
# interfere with diskless booting.
|
||||
#
|
||||
if [ "$1" = autoboot ]; then
|
||||
@ -72,10 +72,42 @@ fi
|
||||
|
||||
skip="-s nostart"
|
||||
[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && skip="$skip -s nojail"
|
||||
|
||||
# Do a first pass to get everything up to mountcritremote so that
|
||||
# we can do a second pass that includes $local_startup directories
|
||||
#
|
||||
files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`
|
||||
|
||||
for _rc_elem in ${files}; do
|
||||
run_rc_script ${_rc_elem} ${_boot}
|
||||
|
||||
case "$_rc_elem" in
|
||||
*/mountcritremote) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
unset files local_rc
|
||||
|
||||
# Now that disks are mounted, for each dir in $local_startup
|
||||
# search for init scripts that use the new rc.d semantics.
|
||||
#
|
||||
case ${local_startup} in
|
||||
[Nn][Oo] | '') ;;
|
||||
*) find_local_scripts_new ;;
|
||||
esac
|
||||
|
||||
files=`rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null`
|
||||
_skip_early=1
|
||||
for _rc_elem in ${files}; do
|
||||
case "$_skip_early" in
|
||||
1) case "$_rc_elem" in
|
||||
*/mountcritremote) _skip_early=0 ;;
|
||||
esac
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
run_rc_script ${_rc_elem} ${_boot}
|
||||
done
|
||||
|
||||
echo ''
|
||||
|
@ -23,29 +23,16 @@ pkg_start()
|
||||
;;
|
||||
*)
|
||||
echo -n 'Local package initialization:'
|
||||
slist=""
|
||||
if [ -z "${script_name_sep}" ]; then
|
||||
script_name_sep=" "
|
||||
fi
|
||||
for dir in ${local_startup}; do
|
||||
if [ -d "${dir}" ]; then
|
||||
for script in ${dir}/*.sh; do
|
||||
slist="${slist}${script_name_sep}${script}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
script_save_sep="$IFS"
|
||||
IFS="${script_name_sep}"
|
||||
for script in ${slist}; do
|
||||
find_local_scripts_old
|
||||
for script in ${zlist} ${slist}; do
|
||||
if [ -x "${script}" ]; then
|
||||
(set -T
|
||||
trap 'exit 1' 2
|
||||
${script} start)
|
||||
elif [ -f "${script}" -o -L "${script}" ]; then
|
||||
echo -n " (skipping ${script##*/}, not executable)"
|
||||
echo -n " (skipping ${script}, not executable)"
|
||||
fi
|
||||
done
|
||||
IFS="${script_save_sep}"
|
||||
echo '.'
|
||||
;;
|
||||
esac
|
||||
@ -53,33 +40,19 @@ pkg_start()
|
||||
|
||||
pkg_stop()
|
||||
{
|
||||
# For each dir in $local_startup, search for init scripts matching *.sh
|
||||
case ${local_startup} in
|
||||
[Nn][Oo] | '')
|
||||
;;
|
||||
*)
|
||||
echo -n 'Shutting down daemon processes:'
|
||||
slist=""
|
||||
if [ -z "${script_name_sep}" ]; then
|
||||
script_name_sep=" "
|
||||
fi
|
||||
for dir in ${local_startup}; do
|
||||
if [ -d "${dir}" ]; then
|
||||
for script in ${dir}/*.sh; do
|
||||
slist="${slist}${script_name_sep}${script}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
script_save_sep="$IFS"
|
||||
IFS="${script_name_sep}"
|
||||
for script in `reverse_list ${slist}`; do
|
||||
find_local_scripts_old
|
||||
for script in `reverse_list ${slist} ${zlist}`; do
|
||||
if [ -x "${script}" ]; then
|
||||
(set -T
|
||||
trap 'exit 1' 2
|
||||
${script} stop)
|
||||
fi
|
||||
done
|
||||
IFS="${script_save_sep}"
|
||||
echo '.'
|
||||
;;
|
||||
esac
|
||||
|
@ -82,7 +82,13 @@ fi
|
||||
#
|
||||
rcorder_opts="-k shutdown"
|
||||
[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && rcorder_opts="$rcorder_opts -s nojail"
|
||||
files=`rcorder ${rcorder_opts} /etc/rc.d/* 2>/dev/null`
|
||||
|
||||
case ${local_startup} in
|
||||
[Nn][Oo] | '') ;;
|
||||
*) find_local_scripts_new ;;
|
||||
esac
|
||||
|
||||
files=`rcorder ${rcorder_opts} /etc/rc.d/* ${local_rc} 2>/dev/null`
|
||||
|
||||
for _rc_elem in `reverse_list $files`; do
|
||||
debug "run_rc_script $_rc_elem faststop"
|
||||
|
38
etc/rc.subr
38
etc/rc.subr
@ -1355,4 +1355,42 @@ geli_make_list()
|
||||
echo ${devices2}
|
||||
}
|
||||
|
||||
# Find scripts in local_startup directories that use the old syntax
|
||||
#
|
||||
find_local_scripts_old () {
|
||||
zlist=''
|
||||
slist=''
|
||||
for dir in ${local_startup}; do
|
||||
if [ -d "${dir}" ]; then
|
||||
for file in ${dir}/[0-9]*.sh; do
|
||||
grep '^# PROVIDE:' $file >/dev/null 2>&1 &&
|
||||
continue
|
||||
zlist="$zlist $file"
|
||||
done
|
||||
for file in ${dir}/[^0-9]*.sh; do
|
||||
grep '^# PROVIDE:' $file >/dev/null 2>&1 &&
|
||||
continue
|
||||
slist="$slist $file"
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
find_local_scripts_new () {
|
||||
local_rc=''
|
||||
for dir in ${local_startup}; do
|
||||
if [ -d "${dir}" ]; then
|
||||
for file in `grep -l '^# PROVIDE:' ${dir}/*`; do
|
||||
case "$file" in
|
||||
*.sample) ;;
|
||||
*) if [ -x "$file" ]; then
|
||||
local_rc="${local_rc} ${file}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
fi
|
||||
|
@ -57,7 +57,7 @@
|
||||
* is created, otherwise 1.
|
||||
*/
|
||||
#undef __FreeBSD_version
|
||||
#define __FreeBSD_version 700006 /* Master, propagated to newvers */
|
||||
#define __FreeBSD_version 700007 /* Master, propagated to newvers */
|
||||
|
||||
#ifndef LOCORE
|
||||
#include <sys/types.h>
|
||||
|
Loading…
Reference in New Issue
Block a user