summaryrefslogtreecommitdiff
path: root/net/py-saltyrtc.server/files/saltyrtc-server.in
blob: c8428b30ecd8a4d725321d7cc4b6b1f742080dc6 (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
48
49
50
51
#!/bin/sh

# PROVIDE: saltyrtc_server
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# saltyrtc_server_enable	(bool)	Default: NO
# saltyrtc_server_key		(str)	Default: %%ETCDIR%%/key
# saltyrtc_server_dhp		(str)	Default: %%ETCDIR%%/dhparam.pem
# saltyrtc_server_tlskey	(str)	Default: %%ETCDIR%%/tls.key
# saltyrtc_server_tlscrt	(str)	Default: %%ETCDIR%%/tls.crt
# saltyrtc_server_host		(str)	Default: 0.0.0.0
# saltyrtc_server_port		(int)	Default: 443
#

. /etc/rc.subr

name="saltyrtc_server"
rcvar="${name}_enable"
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
command_interpreter="%%PYTHON_CMD%%"
procname="%%PREFIX%%/bin/saltyrtc-server"

start_precmd="${name}_precmd"

load_rc_config $name

: ${saltyrtc_server_enable:="NO"}
: ${saltyrtc_server_key:="%%ETCDIR%%/key"}
: ${saltyrtc_server_dhp:="%%ETCDIR%%/dhparam.pem"}
: ${saltyrtc_server_tlskey:="%%ETCDIR%%/tls.key"}
: ${saltyrtc_server_tlscrt:="%%ETCDIR%%/tls.crt"}
: ${saltyrtc_server_host:="0.0.0.0"}
: ${saltyrtc_server_port:="443"}

required_files="${saltyrtc_server_dhp} ${saltyrtc_server_tlskey} ${saltyrtc_server_tlscrt}"

command_args_saltyrtc="-k ${saltyrtc_server_key} -dhp ${saltyrtc_server_dhp}"
command_args_saltyrtc="${command_args_saltyrtc} -tk ${saltyrtc_server_tlskey} -tc ${saltyrtc_server_tlscrt}"
command_args_saltyrtc="${command_args_saltyrtc} -h ${saltyrtc_server_host} -p ${saltyrtc_server_port}"
command_args="-o /var/log/${name}.log -p ${pidfile} ${procname} serve ${command_args_saltyrtc}"

saltyrtc_server_precmd() {
  if [ ! -e ${saltyrtc_server_key} ]; then
    mkdir -p `dirname ${saltyrtc_server_key}`
    ${command_interpreter} ${procname} generate ${saltyrtc_server_key}
  fi
}

run_rc_command $1