aboutsummaryrefslogtreecommitdiff
path: root/sysutils/runit/files/runsvdir.sh.in
blob: 944706da0b564e2e6bb98d01ca91d40edc92405d (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: /service
# BEFORE:  SERVERS
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `runsvdir':
#
#runsvdir_enable="YES"		(default: NO)
#runsvdir_path="/service"	(default: %%SERVICE_DIR%%)
#

. /etc/rc.subr

name="runsvdir"
rcvar=`set_rcvar`

command="%%PREFIX%%/sbin/runsvdir"

start_cmd=runsvdir_start
stop_postcmd=runsvdir_post_stop

runsvdir_start()
{
	/bin/test -d ${runsvdir_path} || /bin/mkdir -p ${runsvdir_path}
	/usr/bin/env -i \
	PATH=/command:%%PREFIX%%/sbin:%%PREFIX%%/bin:/sbin:/bin:/usr/sbin:/usr/bin \
	/usr/sbin/daemon \
	${command} ${runsvdir_path}
}

runsvdir_post_stop()
{
	%%PREFIX%%/sbin/sv exit ${runsvdir_path}/* 
}

# read configuration and set defaults
load_rc_config "$name"
: ${runsvdir_enable="NO"}
: ${runsvdir_path="%%SERVICE_DIR%%"}

run_rc_command "$1"