summaryrefslogtreecommitdiff
path: root/sysutils/py-mqttwarn/files/mqttwarn.in
blob: 5c22a9adcbfe28b6be0ad3d965f8d46e579d97c1 (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
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

# PROVIDE: mqttwarn
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable mqttwarn:
# mqttwarn_enable (bool):	Set to "NO" by default.
#				Set it to "YES" to enable mqttwarn
#

. /etc/rc.subr

name="mqttwarn"
rcvar=${name}_enable

pidfile="/var/run/${name}/${name}.pid"
mqttwarn_user="mqttwarn"
mqttwarn_command="%%PREFIX%%/bin/mqttwarn"
command="/usr/sbin/daemon"

load_rc_config $name

: ${mqttwarn_enable:=NO}
: ${mqttwarn_user:=mqttwarn}
: ${mqttwarn_group:=mqttwarn}
: ${mqttwarn_syslog_facility:=local3}

start_precmd=mqttwarn_prestart

# these environment varialbes need to be set or the app will fail to start.
mqttwarn_env="MQTTWARNINI='/usr/local/etc/mqttwarn/mqttwarn.ini' MQTTWARNLOG='/var/log/mqttwarn/mqttwarn.log'"

mqttwarn_prestart()
{
	# create the file pid, and directory, with correct permissions
	if [ ! -e ${pidfile} ]; then
		install -o ${mqttwarn_user} -g ${mqttwarn_group} /dev/null ${pidfile};
	else
		chown ${mqttwarn_user}:${mqttwarn_group} ${pidfile};
	fi
}

command_args="-P ${pidfile} -t ${name} -T ${name} -l ${mqttwarn_syslog_facility} ${mqttwarn_command}"

run_rc_command "$1"