summaryrefslogtreecommitdiff
path: root/net/syncthing/files/syncthing-relaysrv.in
blob: fabdf2d11595ac093b5491bf0b4922df45fda8aa (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: syncthingrelaysrv
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# syncthingrelaysrv_enable (bool):      Set to NO by default.
#                                       Set it to YES to enable syncthing-relaysrv.
# syncthingrelaysrv_user (user):        Set user to run syncthing-relaysrv.
#                                       Default is "syncthing".
# syncthingrelaysrv_group (group):      Set group to run syncthing-relaysrv.
#                                       Default is "syncthing".
# syncthingrelaysrv_dir (dir):          Set dir to run syncthing-relaysrv in.
#                                       Default is "/var/db/syncthing-relaysrv".
# syncthingrelaysrv_log_file (path):    Syncthing log file
#                                       Default: /var/log/syncthing-relaysrv.log
# syncthingrelaysrv_key (file):         Set key file to use
#                                       Default is "${syncthingrelaysrv_dir}/syncthing.key".
# syncthingrelaysrv_cert (file):        Set cert file to use
#                                       Default is "${syncthingrelaysrv_dir}/syncthing.cert".
# syncthingrelaysrv_args (string):      Extra args to pass to syncthing-relaysrv
#                                       Default is ""

. /etc/rc.subr

name=syncthingrelaysrv
rcvar=syncthingrelaysrv_enable

load_rc_config $name

: ${syncthingrelaysrv_enable:="NO"}
: ${syncthingrelaysrv_user:="syncthing"}
: ${syncthingrelaysrv_group:="syncthing"}
: ${syncthingrelaysrv_dir:="/var/db/syncthing-relaysrv"}
: ${syncthingrelaysrv_log_file=/var/log/syncthing-relaysrv.log}

export STNORESTART=true

pidfile=/var/run/syncthingrelaysrv.pid
procname="%%PREFIX%%/bin/strelaysrv"
command="/usr/sbin/daemon"
command_args="-c -p ${pidfile} ${procname} -keys ${syncthingrelaysrv_dir} ${syncthingrelaysrv_args} >> ${syncthingrelaysrv_log_file} 2>&1"

start_precmd=syncthingrelaysrv_startprecmd

syncthingrelaysrv_startprecmd()
{
        if [ ! -e ${pidfile} ]; then
                install -o ${syncthingrelaysrv_user} -g ${syncthingrelaysrv_group} /dev/null ${pidfile};
        fi

        if [ ! -d ${syncthingrelaysrv_dir} ]; then
                install -d -o ${syncthingrelaysrv_user} -g ${syncthingrelaysrv_group} ${syncthingrelaysrv_dir}
        fi
        if [ ! -e ${syncthingrelaysrv_log_file} ]; then
                install -o ${syncthingrelaysrv_user} -g ${syncthingrelaysrv_group} /dev/null ${syncthingrelaysrv_log_file};
        fi
}

run_rc_command "$1"