summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/localpkg
blob: 7efe504c465191141cbafaeda10072fc83be47e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: localpkg
# REQUIRE: abi
# BEFORE:  securelevel
# KEYWORD: shutdown

. /etc/rc.subr

name="localpkg"
start_cmd="pkg_start"
stop_cmd="pkg_stop"

pkg_start()
{
	local initdone

	# For each dir in $local_startup, search for init scripts matching *.sh
	#
	case ${local_startup} in
	[Nn][Oo] | '')
		;;
	*)
		initdone=
		find_local_scripts_old
		for script in ${zlist} ${slist}; do
			if [ -z "${initdone}" -a -f "${script}" ]; then
				echo -n 'Local package initialization:'
				initdone=yes
			fi
			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
		[ -n "${initdone}" ] && echo '.'
		;;
	esac
}

pkg_stop()
{
	local initdone

	case ${local_startup} in
	[Nn][Oo] | '')
		;;
	*)
		initdone=
		find_local_scripts_old
		for script in `reverse_list ${slist} ${zlist}`; do
			if [ -z "${initdone}" -a -f "${script}" ]; then
				echo -n 'Shutting down daemon processes:'
				initdone=yes
			fi
			if [ -x "${script}" ]; then
				if [ `sysctl -n debug.bootverbose` -eq 1 ]; then
					echo "==>" ${script}
				fi
				(set -T
				trap 'exit 1' 2
				${script} stop)
			fi
		done
		[ -n "${initdone}" ] && echo '.'
		;;
	esac
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud