blob: 5bb53a944922828e56afda18ebbb2f1278af99ec (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!/bin/sh /etc/rc.common
START=90
STOP=10
USE_PROCD=1
PROG=/usr/bin/strelaysrv
config_cb() {
[ $# -eq 0 ] && return
option_cb() {
local option="$1"
local value="$2"
# Remove the leading underscore from the option name for backward
# compatibility
option="${option#_}"
eval $option="$value"
}
}
service_triggers() {
procd_add_reload_trigger 'strelaysrv'
}
start_service() {
# Options with default value different with the syncthing should be defined
# explicitly here
local enabled=0
local debug=0
local ext_address=''
local global_rate=''
local keys='/etc/strelaysrv'
local listen=':22067'
local message_timeout=''
local nat=0
local nat_lease=''
local nat_renewal=''
local nat_timeout=''
local network_timeout=''
local nice=0
local per_session_rate=''
local ping_interval=''
local pools=''
local pprof=0
local protocol=''
local provided_by=''
local status_srv=''
local token=''
local user='syncthing'
config_load 'strelaysrv'
[ "$enabled" -gt 0 ] || return 0
local group=$(id -gn $user)
mkdir -p "$keys"
[ -d "$keys" ] && chown -R "$user":"$group" "$keys"
config_get nice strelaysrv nice "0"
procd_open_instance
procd_set_param command "$PROG"
[ "$debug" -eq 0 ] || \
procd_append_param command -debug
[ -z "$ext_address" ] || \
procd_append_param command -ext-address="$ext_address"
[ -z "$global_rate" ] || \
procd_append_param command -global-rate="$global_rate"
procd_append_param command -keys="$keys"
[ -z "$listen" ] || \
procd_append_param command -listen="$listen"
[ -z "$message_timeout" ] || \
procd_append_param command -message-timeout="$message_timeout"
[ "$nat" -eq 0 ] || \
procd_append_param command -nat
[ -z "$nat_lease" ] || \
procd_append_param command -nat-lease="$nat_lease"
[ -z "$nat_renewal" ] || \
procd_append_param command -nat-renewal="$nat_renewal"
[ -z "$nat_timeout" ] || \
procd_append_param command -nat-timeout="$nat_timeout"
[ -z "$network_timeout" ] || \
procd_append_param command -network-timeout="$network_timeout"
[ -z "$per_session_rate" ] || \
procd_append_param command -per-session-rate="$per_session_rate"
[ -z "$ping_interval" ] || \
procd_append_param command -ping-interval="$ping_interval"
# pools is set to an empty value by default
procd_append_param command -pools="$pools"
[ "$pprof" -eq 0 ] || \
procd_append_param command -pprof
[ -z "$protocol" ] || \
procd_append_param command -protocol="$protocol"
[ -z "$provided_by" ] || \
procd_append_param command -provided-by="$provided_by"
# status-srv is set to an empty value by default
procd_append_param command -status-srv="$status_srv"
[ -z "$token" ] || \
procd_append_param command -token="$token"
procd_set_param nice "$nice"
procd_set_param term_timeout 15
procd_set_param user "$user"
procd_set_param group "$group"
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
reload_service() {
stop
start
}
|