@@ -13,89 +13,80 @@ config_cb() {
1313 option_cb () {
1414 local option=" $1 "
1515 local value=" $2 "
16+
1617 case $option in
17- enabled|gui_address|home|logfile|macprocs|nice|user)
18- eval $option =$value
19- ;;
20- debug)
21- extra_args=" $extra_args --${option// _/ -} -$value "
22- ;;
23- _* )
24- [ " $value " = " 0" ] || extra_args=" $extra_args -${option// _/ -} "
25- ;;
26- * )
27- extra_args=" $extra_args --${option// _/ -} =$value "
18+
19+ # Support old option names
20+ logfile)
21+ option=' log_file'
2822 ;;
23+
2924 esac
30- }
3125
32- list_cb () {
33- local name=" $1 "
34- local value=" $2 "
35- [ " $name " = " _" ] && extra_args=" $extra_args --${value// _/ -} " || return 0
26+ eval $option =" $value "
3627 }
3728}
3829
39- service_triggers ()
40- {
41- procd_add_reload_trigger " syncthing"
30+ service_triggers () {
31+ procd_add_reload_trigger ' syncthing'
4232}
4333
4434start_service () {
45- local extra_args=" --no-browser"
46-
47- # Options with default value different with the syncthing should be defined explicitly here
35+ # Options with default value different with the syncthing should be defined
36+ # explicitly here
4837 local enabled=0
49- local gui_address=" http://0.0.0.0:8384"
50- local home=" /etc/syncthing"
51- local logfile=" /var/log/syncthing.log"
38+ local db_delete_retention_interval=' '
39+ local db_maintenance_interval=' '
40+ local gui_address=' http://0.0.0.0:8384'
41+ local gui_apikey=' '
42+ local home=' /etc/syncthing'
43+ local log_file=' /var/log/syncthing.log'
44+ local log_level=' INFO'
45+ local log_max_old_files=7
46+ local log_max_size=1048576
5247 local macprocs=0
5348 local nice=0
54- local user=" syncthing"
49+ local user=' syncthing'
5550
56- config_load " syncthing"
51+ config_load ' syncthing'
5752
5853 local group=$( id -gn $user )
5954
60- # Some of the default values below might not match the defaults
61- # in /etc/config/syncthing: the reason is to remain backwards
62- # compatible with the older versions of this service as it
63- # evolves.
6455 [ " $enabled " -gt 0 ] || return 0
6556
66- # For backwards compatibility
67- IDX_DB=$( readlink -n " $home " /index-v0.14.0.db)
68- if [ ! -z " $IDX_DB " ]; then
69- [ -d " $IDX_DB " ] || mkdir -p " $IDX_DB "
70-
71- # A separate step to handle an upgrade use case
72- [ -d " $IDX_DB " ] && chown -R $user :$group " $IDX_DB "
73- fi
74-
7557 [ -d " $home " ] || mkdir -p " $home "
7658 # A separate step to handle an upgrade use case
7759 [ -d " $home " ] && chown -R $user :$group " $home "
7860
79- # Changes to "niceness"/macprocs are not picked up by "reload_config"
80- # nor by "restart": the service has to be stopped/started
81- # for it to take effect
61+ # Changes to "niceness"/macprocs are not picked up either by reload_config
62+ # or by restart: the service has to be stopped/started for it to take effect
8263 if [ $macprocs -le 0 ]; then
8364 # Default to the number of cores in this case
8465 macprocs=$( grep -c ^processor /proc/cpuinfo)
8566 fi
8667
8768 procd_open_instance
8869 procd_set_param command " $PROG "
89- procd_set_param env GOMAXPROCS=" $macprocs " STNOUPGRADE=1
70+ procd_set_param env GOMAXPROCS=" $macprocs "
9071 procd_append_param command serve
72+ [ -z " $db_delete_retention_interval " ] || procd_append_param command --db-delete-retention-interval=" $db_delete_retention_interval "
73+ [ -z " $db_maintenance_interval " ] || procd_append_param command --db-maintenance-interval=" $db_maintenance_interval "
9174 procd_append_param command --gui-address=" $gui_address "
75+ [ -z " $gui_apikey " ] || procd_append_param command --gui_apikey=" $gui_apikey "
9276 procd_append_param command --home=" $home "
93- procd_append_param command --logfile=" $logfile "
94- [ -z " $extra_args " ] || procd_append_param command $extra_args
77+ procd_append_param command --log-file=" $log_file "
78+ [ -z " $log_level " ] || procd_append_param command --log-level=" $log_level "
79+ [ -z " $log_max_old_files " ] || procd_append_param command --log-max-old-files=" $log_max_old_files "
80+ [ -z " $log_max_size " ] || procd_append_param command --log-max-size=" $log_max_size "
81+ procd_append_param command --no-browser
82+ procd_append_param command --no-port-probing
83+ procd_append_param command --no-restart
84+ # The package is built with noupgrade tag so --no-upgrade is not necessary
9585
9686 procd_set_param nice " $nice "
9787 procd_set_param term_timeout 15
9888 procd_set_param user " $user "
89+ procd_set_param group " $group "
9990 procd_set_param respawn
10091 procd_set_param stdout 0
10192 procd_set_param stderr 1
0 commit comments