aboutsummaryrefslogtreecommitdiff
path: root/net/benthos/files/benthos.in
blob: e042c13e5896e79dcdc2452cfb7f081a6279010a (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
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# PROVIDE: benthos
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to run NATS:
#
# benthos_enable (bool):	Set it to "YES" to enable benthos.
#				Default is "NO".
# benthos_user:			User name to run as. default "benthos"
# benthos_group:		Group name to run as. default "benthos"
# benthos_resources:		Path to benthos resources files (glob).
# benthos_config:		Path to benthos configuration file.
# benthos_watcher (bool):	Set it to "YES" to enable benthos watcher mode.
#				Default is "NO".
# benthos_options:		Options to pass benthos
#                               (e.g. 'streams' for streams mode).
#

. /etc/rc.subr

name=benthos
rcvar=`set_rcvar`

load_rc_config ${name}

: ${benthos_enable:=NO}
: ${benthos_user:=benthos}
: ${benthos_group:=benthos}
: ${benthos_resources:=""}
: ${benthos_config:="%%PREFIX%%/etc/benthos/config.yaml"}
: ${benthos_watcher:=NO}
: ${benthos_options=""}

if [ -n "${benthos_resources}" ]; then
    benthos_options="--resources '${benthos_resources}' ${benthos_options}"
fi

if [ -n "${benthos_config}" ]; then
    benthos_options="--config ${benthos_config} ${benthos_options}"
fi

if checkyesno benthos_watcher; then
    benthos_options="--watcher ${benthos_options}"
fi

start_precmd=benthos_start_precmd

pidfile="/var/run/${name}.pid"
procname=%%PREFIX%%/bin/benthos
command=/usr/sbin/daemon
command_args="-p ${pidfile} ${procname} ${benthos_options}"

benthos_start_precmd()
{
    install -o ${benthos_user} -g ${benthos_group} /dev/null ${pidfile}
}

run_rc_command "$1"