blob: e98d21a945911c92672ba2f36966179c36c291a5 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/sh
# PROVIDE: syncthingdiscosrv
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# syncthingdiscosrv_enable (bool): Set to NO by default.
# Set it to YES to enable syncthing-discosrv.
# syncthingdiscosrv_user (user): Set user to run syncthing-discosrv.
# Default is "syncthing".
# syncthingdiscosrv_group (group): Set group to run syncthing-discosrv.
# Default is "syncthing".
# syncthingdiscosrv_dir (dir): Set dir to run syncthing-discosrv in.
# Default is "/var/db/syncthing-discosrv".
# syncthingdiscosrv_log_file (path): Syncthing log file
# Default: /var/log/syncthing-discosrv.log
# syncthingdiscosrv_key (file): Set key file to use
# Default is "${syncthingdiscosrv_dir}/syncthing.key".
# syncthingdiscosrv_cert (file): Set cert file to use
# Default is "${syncthingdiscosrv_dir}/syncthing.cert".
# syncthingdiscosrv_args (string): Extra args to pass to syncthing-discosrv
# Default is ""
. /etc/rc.subr
name=syncthingdiscosrv
rcvar=syncthingdiscosrv_enable
load_rc_config $name
: ${syncthingdiscosrv_enable:="NO"}
: ${syncthingdiscosrv_user:="syncthing"}
: ${syncthingdiscosrv_group:="syncthing"}
: ${syncthingdiscosrv_dir:="/var/db/syncthing-discosrv"}
: ${syncthingdiscosrv_log_file=/var/log/syncthing-discosrv.log}
: ${syncthingdiscosrv_key:="${syncthingdiscosrv_dir}/syncthing.key"}
: ${syncthingdiscosrv_cert:="${syncthingdiscosrv_dir}/syncthing.cert"}
export STNORESTART=true
pidfile=/var/run/syncthingdiscosrv.pid
procname="%%PREFIX%%/bin/stdiscosrv"
command="/usr/sbin/daemon"
command_args="-p ${pidfile} ${procname} -key ${syncthingdiscosrv_key} -cert ${syncthingdiscosrv_cert} ${syncthingdiscosrv_args} >> ${syncthingdiscosrv_log_file}"
syncthingdiscosrv_chdir=${syncthingdiscosrv_dir}
start_precmd=syncthingdiscosrv_startprecmd
syncthingdiscosrv_startprecmd()
{
if [ ! -e ${pidfile} ]; then
install -o ${syncthingdiscosrv_user} -g ${syncthingdiscosrv_group} /dev/null ${pidfile};
fi
if [ ! -d ${syncthingdiscosrv_dir} ]; then
install -d -o ${syncthingdiscosrv_user} -g ${syncthingdiscosrv_group} ${syncthingdiscosrv_dir}
fi
if [ ! -e ${syncthingdiscosrv_log_file} ]; then
install -o ${syncthingdiscosrv_user} -g ${syncthingdiscosrv_group} /dev/null ${syncthingdiscosrv_log_file};
fi
}
run_rc_command "$1"
|