summaryrefslogtreecommitdiff
path: root/sysutils/loki/files/loki.in
blob: 4400444818b1fa093a68d031290df67469e2cc20 (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
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh

# PROVIDE: loki
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable loki
# loki_enable="YES"
#
# loki_enable (bool):
#     Set it to YES to enable grafana
#     Set to NO by default
# loki_user (string):
#     Set user that grafana will run under
#     Default is "%%LOKI_USER%%"
# loki_group (string):
#     Set group that own grafana files
#     Default is "%%LOKI_GROUP%%"
# loki_config (string)
#     Set full path to config file
#     Default is "%%PREFIX%%/etc/loki.yaml"
# loki_logfile (string)
#     Set full path to log file
#     Default is "/var/log/loki/loki.log"
# loki_loglevel (string)
#     Set log level. Only log messages with the given severity or above.
#     Valid levels: [debug, info, warn, error]
#     Default is "warn"
# loki_args (string)
#     Set additional command line arguments
#     Default is ""

. /etc/rc.subr

name=loki
rcvar=loki_enable

load_rc_config $name

: ${loki_enable:="NO"}
: ${loki_user:="%%LOKI_USER%%"}
: ${loki_group:="%%LOKI_GROUP%%"}
: ${loki_config:="%%PREFIX%%/etc/loki.yaml"}
: ${loki_logfile:="/var/log/loki/loki.log"}
: ${loki_loglevel:="warn"}

pidfile="/var/run/${name}/${name}.pid"
required_files="${loki_config}"

procname="%%PREFIX%%/bin/loki"
command="/usr/sbin/daemon"
command_args="-p ${pidfile} -t ${name} -o ${loki_logfile} \
	${procname} \
	--config.file=${loki_config} \
	--log.level=${loki_loglevel} \
	${loki_args}"

start_precmd="loki_start_precmd"

loki_start_precmd()
{
	if [ ! -d "/var/run/${name}" ]; then
		install -d -m 0750 -o ${loki_user} -g ${loki_group} "/var/run/${name}"
	fi

	if [ ! -d "/var/log/loki" ]; then
		install -d -m 0750 -o ${loki_user} -g ${loki_group} "/var/log/loki"
	fi
}

run_rc_command "$1"