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