2003-08-06 00:35:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: localpkg
|
|
|
|
# REQUIRE: abi
|
|
|
|
# BEFORE: securelevel
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: shutdown
|
2003-08-06 00:35:13 +00:00
|
|
|
|
|
|
|
. /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()
|
|
|
|
{
|
2008-06-22 15:34:40 +00:00
|
|
|
local initdone
|
|
|
|
|
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] | '')
|
|
|
|
;;
|
|
|
|
*)
|
2008-06-22 15:34:40 +00:00
|
|
|
initdone=
|
2005-12-02 20:06:07 +00:00
|
|
|
find_local_scripts_old
|
|
|
|
for script in ${zlist} ${slist}; do
|
2008-06-22 15:34:40 +00:00
|
|
|
if [ -z "${initdone}" -a -f "${script}" ]; then
|
|
|
|
echo -n 'Local package initialization:'
|
|
|
|
initdone=yes
|
|
|
|
fi
|
2003-08-06 00:35:13 +00:00
|
|
|
if [ -x "${script}" ]; then
|
|
|
|
(set -T
|
|
|
|
trap 'exit 1' 2
|
|
|
|
${script} start)
|
|
|
|
elif [ -f "${script}" -o -L "${script}" ]; then
|
2005-12-02 20:06:07 +00:00
|
|
|
echo -n " (skipping ${script}, not executable)"
|
2003-08-06 00:35:13 +00:00
|
|
|
fi
|
|
|
|
done
|
2008-06-22 15:34:40 +00:00
|
|
|
[ -n "${initdone}" ] && echo '.'
|
2003-08-06 00:35:13 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg_stop()
|
|
|
|
{
|
2008-06-22 15:34:40 +00:00
|
|
|
local initdone
|
|
|
|
|
2003-08-06 00:35:13 +00:00
|
|
|
case ${local_startup} in
|
|
|
|
[Nn][Oo] | '')
|
|
|
|
;;
|
|
|
|
*)
|
2008-06-22 15:34:40 +00:00
|
|
|
initdone=
|
2005-12-02 20:06:07 +00:00
|
|
|
find_local_scripts_old
|
|
|
|
for script in `reverse_list ${slist} ${zlist}`; do
|
2008-06-22 15:34:40 +00:00
|
|
|
if [ -z "${initdone}" -a -f "${script}" ]; then
|
|
|
|
echo -n 'Shutting down daemon processes:'
|
|
|
|
initdone=yes
|
|
|
|
fi
|
2003-08-06 00:35:13 +00:00
|
|
|
if [ -x "${script}" ]; then
|
2006-02-12 10:04:56 +00:00
|
|
|
if [ `sysctl -n debug.bootverbose` -eq 1 ]; then
|
|
|
|
echo "==>" ${script}
|
|
|
|
fi
|
2003-08-06 00:35:13 +00:00
|
|
|
(set -T
|
|
|
|
trap 'exit 1' 2
|
|
|
|
${script} stop)
|
|
|
|
fi
|
|
|
|
done
|
2008-06-22 15:34:40 +00:00
|
|
|
[ -n "${initdone}" ] && echo '.'
|
2003-08-06 00:35:13 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
2004-07-28 00:09:19 +00:00
|
|
|
run_rc_command "$1"
|