2003-08-06 00:35:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: localpkg
|
|
|
|
# REQUIRE: abi
|
|
|
|
# BEFORE: securelevel
|
|
|
|
# KEYWORD: FreeBSD shutdown
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="localpkg"
|
2004-07-28 00:09:19 +00:00
|
|
|
start_cmd="pkg_start"
|
|
|
|
stop_cmd="pkg_stop"
|
Ports related rc.d cleanups:
o Separate out local (ports) scripts that use rc.d, and the old style
startup/shutdown scripts and execute them separately. On startup the
rc.d style scripts are executed first and then the old-style scripts.
On shutdown, exactly the reverse happens.
o The rc.d ports scripts should now behave more like base system scripts.
Scripts ending in .sh will be sourced into the current shell, while the
rest will be executed in a subshell. Previously, all ports scripts,
regardless of the .sh suffix, were executed in a subshell.
o The parent script, /etc/rc.d/localpkg, passes its command line arguments
straight to the rc.d ports scripts. This means they should now honor
faststop and faststart commands as well. Old style scripts, should not see
any differences. They will still get either a start or stop command.
o The initial phrase shown during shutdown has been changed to use
"local packages" instead of "daemon processes" to be more inline with the
phrase used during local package startup. The phrases are also used only for
old-style ports script startup/shutdown, whereas previously they were being
used for both rc.d and old-style scripts. This should make startup/shutdown
output a bit less ugly.
Discussed with: portmgr
Has Reservations: eik
2004-07-24 14:56:21 +00:00
|
|
|
|
|
|
|
pkg_start()
|
|
|
|
{
|
2004-07-28 00:09:19 +00:00
|
|
|
# For each dir in $local_startup, search for init scripts matching *.sh
|
|
|
|
#
|
2003-08-06 00:35:13 +00:00
|
|
|
case ${local_startup} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
2004-07-28 00:09:19 +00:00
|
|
|
echo -n 'Local package initialization:'
|
2003-08-06 00:35:13 +00:00
|
|
|
slist=""
|
|
|
|
if [ -z "${script_name_sep}" ]; then
|
|
|
|
script_name_sep=" "
|
|
|
|
fi
|
2004-07-28 00:09:19 +00:00
|
|
|
for dir in ${local_startup}; do
|
|
|
|
if [ -d "${dir}" ]; then
|
|
|
|
for script in ${dir}/*.sh; do
|
|
|
|
slist="${slist}${script_name_sep}${script}"
|
|
|
|
done
|
|
|
|
fi
|
2003-08-06 00:35:13 +00:00
|
|
|
done
|
|
|
|
script_save_sep="$IFS"
|
|
|
|
IFS="${script_name_sep}"
|
|
|
|
for script in ${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)"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="${script_save_sep}"
|
|
|
|
echo '.'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg_stop()
|
|
|
|
{
|
2004-07-28 00:09:19 +00:00
|
|
|
echo -n 'Shutting down daemon processes:'
|
2003-08-06 00:35:13 +00:00
|
|
|
|
|
|
|
# For each dir in $local_startup, search for init scripts matching *.sh
|
|
|
|
case ${local_startup} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
2004-07-28 00:09:19 +00:00
|
|
|
slist=""
|
2003-08-06 00:35:13 +00:00
|
|
|
if [ -z "${script_name_sep}" ]; then
|
|
|
|
script_name_sep=" "
|
|
|
|
fi
|
2004-07-28 00:09:19 +00:00
|
|
|
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
|
2003-08-06 00:35:13 +00:00
|
|
|
script_save_sep="$IFS"
|
|
|
|
IFS="${script_name_sep}"
|
|
|
|
for script in `reverse_list ${slist}`; do
|
|
|
|
if [ -x "${script}" ]; then
|
|
|
|
(set -T
|
|
|
|
trap 'exit 1' 2
|
|
|
|
${script} stop)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="${script_save_sep}"
|
|
|
|
echo '.'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
2004-07-28 00:09:19 +00:00
|
|
|
run_rc_command "$1"
|