summaryrefslogtreecommitdiff
path: root/sysutils/sd-agent/files/sd-agent.in
blob: c5165a3f1f40768dec6a13c393c6dd9766a0b211 (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
45
46
47
48
49
50
#!/bin/sh

# PROVIDE: %%RCNAME%%
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name=%%RCNAME%%
rcvar=%%RCNAME%%_enable
pidfile="/var/run/sd-agent/sd-agent.pid"
logfile="/var/log/sd-agent/sd-agent.log"

start_precmd="${name}_prestart"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"

load_rc_config $name
: ${%%RCNAME%%_enable:=no}

%%RCNAME%%_user=sd-agent
%%RCNAME%%_group=sd-agent

command='%%PREFIX%%/libexec/sd-agent/agent.py'

%%RCNAME%%_prestart()
{
	install -d -o ${%%RCNAME%%_user} -g ${%%RCNAME%%_group} \
	    $(dirname $pidfile)
	install -d -o ${%%RCNAME%%_user} -g ${%%RCNAME%%_group} \
	    $(dirname $logfile)
}

%%RCNAME%%_start()
{
	su -m ${%%RCNAME%%_user} -c "$command start init"
}

%%RCNAME%%_stop()
{
	$command stop init
}

%%RCNAME%%_status()
{
	$command status init
}

run_rc_command "$1"