summaryrefslogtreecommitdiff
path: root/devel/py-python-velbustcp/files/velbustcpd.in
blob: 03718c0f69e6c7fde3828615a5af0341ebfedc53 (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
#!/bin/sh

# PROVIDE: velbustcpd
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable velbustcpd:
# velbustcpd_enable:	Set to NO by default. Set it to YES to enable it.
# velbustcpd_log_dig:	The directory to store log files
#			Default: /var/log/%%PORTNAME%%
# velbustcpd_pid_dir:	The directory of the pid file
#			Default: /var/run/%%PORTNAME%%
# velbustcpd_user:	The user account velbustcpd daemon runs as what
#			you want it to be.
# velbustcpd_settings:	Location of the settings file
#			Default: %%LOCALBASE%%/etc/%%PORTNAME%%/settings.json

. /etc/rc.subr

name=velbustcpd
rcvar=velbustcpd_enable

load_rc_config ${name}

: ${velbustcpd_enable:=NO}
: ${velbustcpd_log_dir:="/var/log/%%PORTNAME%%"}
: ${velbustcpd_pid_dir:="/var/run/%%PORTNAME%%"}
: ${velbustcpd_user:=%%USERS%%}
: ${velbustcpd_settings:="%%LOCALBASE%%/etc/%%PORTNAME%%/settings.json"}

pidfile="${velbustcpd_pid_dir}/velbustcpd.pid"
logfile="${velbustcpd_log_dir}/velbustcpd.log"
procname="%%PYTHON_CMD%%"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} -o ${logfile} ${procname} \
		%%LOCALBASE%%/bin/velbustcp --settings ${velbustcpd_settings}"
start_precmd=velbustcpd_precmd

velbustcpd_precmd()
{
	if [ ! -d ${velbustcpd_pid_dir} ]; then
		install -d -g ${velbustcpd_user} -o ${velbustcpd_user} ${velbustcpd_pid_dir}
	fi
	if [ ! -d ${velbustcpd_log_dir} ]; then
		install -d -g ${velbustcpd_user} -o ${velbustcpd_user} ${velbustcpd_log_dir}
	fi
}

run_rc_command "$1"