summaryrefslogtreecommitdiff
path: root/sysutils/runit/files/runsvdir.in
blob: 64cf7610f82018299f47b03a53176fec2a931f35 (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
#!/bin/sh

# 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=runsvdir_enable

load_rc_config runsvdir

: ${runsvdir_enable:=NO}
: ${runsvdir_path=%%SERVICE_DIR%%}

command="%%PREFIX%%/sbin/runsvdir"
start_cmd=runsvdir_start
stop_postcmd="%%PREFIX%%/sbin/sv exit ${runsvdir_path}/*"

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 -c -f \
	${command} ${runsvdir_path}
}

run_rc_command $1