mirror of
https://github.com/openwrt/packages.git
synced 2026-12-03 20:05:37 +04:00
syncthing: improve discovery argument parsing
Fixes: 47644ba46 ("syncthing: fix discovery and relay extra args")
Signed-off-by: George Sapkin <george@sapk.in>
This commit is contained in:
1 parent
1d49010728
commit
6ccb3b6174
2 files changed
+38
-40
No files matched your search
@@ -7,11 +7,13 @@ config stdiscosrv 'stdiscosrv'
|
||||
# Find the documents from: https://docs.syncthing.net/users/stdiscosrv.html
|
||||
# option cert '/etc/stdiscosrv/cert.pem'
|
||||
# option key '/etc/stdiscosrv/key.pem'
|
||||
# option db_flush_interval '5m'
|
||||
# option db_flush_interval '5m'
|
||||
# option metrics_listen ''
|
||||
|
||||
# CLI options with no value should be defined as booleans and theirs names
|
||||
# should be prefixed with '_'.
|
||||
# option _compression '0'
|
||||
# option _debug '0'
|
||||
# option _http '1'
|
||||
# Running as 'root' is possible, but not recommended
|
||||
# option user 'syncthing'
|
||||
|
||||
# CLI options with no value should be defined as booleans
|
||||
# option compression '0'
|
||||
# option debug '0'
|
||||
# option http '1'
|
||||
@@ -13,43 +13,36 @@ config_cb() {
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
case $option in
|
||||
enabled|listen|cert|db_dir|key)
|
||||
eval $option=$value
|
||||
;;
|
||||
_*)
|
||||
[ "$value" = "0" ] || extra_args="$extra_args -${option//_/-}"
|
||||
;;
|
||||
*)
|
||||
extra_args="$extra_args --${option//_/-}='$value'"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
list_cb() {
|
||||
local name="$1"
|
||||
local value="$2"
|
||||
[ "$name" = "_" ] && extra_args="$extra_args --${value//_/-}" || return 0
|
||||
# Remove the leading underscore from the option name for backward
|
||||
# compatibility
|
||||
option="${option#_}"
|
||||
eval $option="$value"
|
||||
}
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "stdiscosrv"
|
||||
procd_add_reload_trigger 'stdiscosrv'
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local extra_args
|
||||
# Options with default value different with the syncthing should be defined explicitly here
|
||||
local enabled=0
|
||||
local listen=":8443"
|
||||
local conf_dir="/etc/stdiscosrv"
|
||||
local cert="$conf_dir/cert.pem"
|
||||
local key="$conf_dir/key.pem"
|
||||
local db_dir="$conf_dir/discovery.db"
|
||||
local nice=0
|
||||
local user="syncthing"
|
||||
local conf_dir='/etc/stdiscosrv'
|
||||
|
||||
config_load "stdiscosrv"
|
||||
# Options with default value different with the syncthing should be defined
|
||||
# explicitly here
|
||||
local enabled=0
|
||||
local compression=0
|
||||
local cert="$conf_dir/cert.pem"
|
||||
local db_dir="$conf_dir/discovery.db"
|
||||
local db_flush_interval=''
|
||||
local debug=0
|
||||
local http=0
|
||||
local key="$conf_dir/key.pem"
|
||||
local listen=':8443'
|
||||
local metrics_listen=''
|
||||
local nice=0
|
||||
local user='syncthing'
|
||||
|
||||
config_load 'stdiscosrv'
|
||||
|
||||
[ "$enabled" -gt 0 ] || return 0
|
||||
|
||||
@@ -58,19 +51,22 @@ start_service() {
|
||||
[ -d "$db_dir" ] || mkdir -p "$db_dir"
|
||||
[ -d "$conf_dir" ] && chown -R "$user":"$group" "$conf_dir"
|
||||
|
||||
config_get nice stdiscosrv nice "0"
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_append_param command --listen="$listen"
|
||||
procd_append_param command --db-dir="$db_dir"
|
||||
procd_append_param command --cert="$cert"
|
||||
[ "$compression" -eq 0 ] || procd_append_param command --compression
|
||||
procd_append_param command --db-dir="$db_dir"
|
||||
[ -z "$db_flush_interval" ] || procd_append_param command --db-flush-interval="$db_flush_interval"
|
||||
[ "$debug" -eq 0 ] || procd_append_param command --debug
|
||||
[ "$http" -eq 0 ] || procd_append_param command --http
|
||||
procd_append_param command --key="$key"
|
||||
[ -z "$extra_args" ] || procd_append_param command "$extra_args"
|
||||
procd_append_param command --listen="$listen"
|
||||
[ -z "$metrics_listen" ] || procd_append_param command --metrics-listen="$metrics_listen"
|
||||
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user