xref: /freebsd/libexec/rc/rc.d/localpkg (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
1#!/bin/sh
2#
3#
4
5# PROVIDE: localpkg
6# REQUIRE: sysvipc linux
7# BEFORE:  securelevel
8# KEYWORD: shutdown
9
10. /etc/rc.subr
11
12name="localpkg"
13desc="Run local init scripts"
14start_cmd="pkg_start"
15stop_cmd="pkg_stop"
16
17pkg_start()
18{
19	local initdone
20
21	# For each dir in $local_startup, search for init scripts matching *.sh
22	#
23	case ${local_startup} in
24	[Nn][Oo] | '')
25		;;
26	*)
27		initdone=
28		find_local_scripts_old
29		for script in ${zlist} ${slist}; do
30			if [ -z "${initdone}" -a -f "${script}" ]; then
31				echo -n 'Local package initialization:'
32				initdone=yes
33			fi
34			if [ -x "${script}" ]; then
35				(set -T
36				trap 'exit 1' 2
37				${script} start)
38			elif [ -f "${script}" -o -L "${script}" ]; then
39				echo -n " (skipping ${script}, not executable)"
40			fi
41		done
42		[ -n "${initdone}" ] && echo '.'
43		;;
44	esac
45}
46
47pkg_stop()
48{
49	local initdone
50
51	case ${local_startup} in
52	[Nn][Oo] | '')
53		;;
54	*)
55		initdone=
56		find_local_scripts_old
57		for script in `reverse_list ${slist} ${zlist}`; do
58			if [ -z "${initdone}" -a -f "${script}" ]; then
59				echo -n 'Shutting down local packages:'
60				initdone=yes
61			fi
62			if [ -x "${script}" ]; then
63				if [ `sysctl -n debug.bootverbose` -eq 1 ]; then
64					echo "==>" ${script}
65				fi
66				(set -T
67				trap 'exit 1' 2
68				${script} stop)
69			fi
70		done
71		[ -n "${initdone}" ] && echo '.'
72		;;
73	esac
74}
75
76load_rc_config $name
77run_rc_command "$1"
78