1 #!/bin/sh /etc/rc.common
4 BIN
=/usr
/bin
/transmission-daemon
10 local p
; local v
; local s
="$1"; shift
12 config_get v
"$s" "$p"
16 echo "\""$p"\": "$v"," |
sed -e 's|_|-|g' >> $config_dir/settings.json
23 append_params_quotes
() {
24 local p
; local v
; local s
="$1"; shift
26 config_get v
"$s" "$p"
30 echo -n "\""$p |
sed -e 's|/|\\/|g;s|_|-|g' >> $config_dir/settings.json
; \
31 echo "\": \""$v"\"," >> $config_dir/settings.json
42 local run_as_usr
='root'
43 local open_file_limit
=0
44 local ulimit_files
=`ulimit -n`
47 config_get_bool
enable "$s" enable 0 # compatibility with prev version
48 config_get_bool enabled
"$s" enabled
0
49 [ "$enabled" == 0 -a "$enable" == 0 ] && return 0
50 config_get config_dir
"$s" config_dir
'/tmp/transmission'
51 mkdir
-p "$config_dir"
52 config_get run_as_usr
"$s" run_daemon_as_user
'root'
54 echo "{" > $config_dir/settings.json
57 alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \
58 alt_speed_time_enabled alt_speed_time_end alt_speed_up blocklist_enabled \
59 cache_size_mb download_queue_enabled download_queue_size \
60 dht_enabled encryption idle_seeding_limit idle_seeding_limit_enabled \
61 incomplete_dir_enabled lazy_bitfield_enabled lpd_enabled message_level \
62 open_file_limit peer_limit_global peer_limit_per_torrent peer_port \
63 peer_port_random_high peer_port_random_low peer_port_random_on_start \
64 peer_socket_tos pex_enabled port_forwarding_enabled preallocation prefetch_enabled \
65 ratio_limit ratio_limit_enabled rename_partial_files rpc_authentication_required \
66 rpc_enabled rpc_port rpc_whitelist_enabled queue_stalled_enabled \
67 queue_stalled_minutes scrape_paused_torrents_enabled script_torrent_done_enabled \
68 seed_queue_enabled seed_queue_size \
69 speed_limit_down speed_limit_down_enabled speed_limit_up \
70 speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
71 umask upload_slots_per_torrent utp_enabled scrape_paused_torrents \
74 append_params_quotes
"$s" \
75 blocklist_url bind_address_ipv4 bind_address_ipv6 download_dir incomplete_dir \
76 peer_congestion_algorithm rpc_bind_address rpc_password rpc_url \
77 rpc_username rpc_whitelist script_torrent_done_filename watch_dir
79 echo "\""invalid-key
"\": false" >> $config_dir/settings.json
80 echo "}" >> $config_dir/settings.json
82 chown
-R $run_as_usr $config_dir
84 config_get open_file_limit
"$s" open_file_limit
32
85 let open_limit_files
="$open_file_limit + 8"
87 if [ ${open_file_limit} -gt ${ulimit_files} ]; then
88 ulimit -n $open_limit_files
91 eval "$SSD -c $run_as_usr -q -b -x $BIN -S -- -g $config_dir"
95 config_load transmission
96 config_foreach start_service transmission
100 service_kill $
(basename $BIN)