source: packages/net/transmission/files/transmission.init @ 21569

Last change on this file since 21569 was 21569, checked in by obsy, 7 years ago

[packages] transmission: update to 2.00b1, add new options

File size: 2.3 KB
Line 
1#!/bin/sh /etc/rc.common
2
3START=99
4BIN=/usr/bin/transmission-daemon
5SSD=start-stop-daemon
6
7LIST_SEP="
8"
9append_params() {
10        local p; local v; local s="$1"; shift
11        for p in $*; do
12                config_get v "$s" "$p"
13                IFS="$LIST_SEP"
14                for v in $v; do
15                        [ -n "$v" ] && (
16                                echo "\""$p"\": "$v"," | sed -e 's|_|-|g' >> $config_dir/settings.json
17                        )
18                done
19                unset IFS
20        done
21}
22
23append_params_quotes() {
24        local p; local v; local s="$1"; shift
25        for p in $*; do
26                config_get v "$s" "$p"
27                IFS="$LIST_SEP"
28                for v in $v; do
29                        [ -n "$v" ] && (
30                                echo "\""$p"\": \""$v"\"," | sed -e 's|/|\\/|g;s|_|-|g' >> $config_dir/settings.json
31                        )
32                done
33                unset IFS
34        done
35}
36
37start_service() {
38        local s="$1"
39        local enable=0
40
41        # disabled?
42        config_get_bool enable "$s" enable 0
43        [ "$enable" == 0 ] && return 0
44        config_get config_dir "$s" config_dir '/tmp/transmission'
45        mkdir -p "$config_dir"
46
47        echo "{" > $config_dir/settings.json
48
49        append_params "$s" \
50                alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \
51                alt_speed_time_enabled alt_speed_time_end alt_speed_up \
52                blocklist_enabled dht_enabled encryption \
53                incomplete_dir_enabled lazy_bitfield_enabled lpd_enabled message_level \
54                open_file_limit peer_limit_global peer_limit_per_torrent peer_port \
55                peer_port_random_high peer_port_random_low peer_port_random_on_start \
56                peer_socket_tos pex_enabled port_forwarding_enabled preallocation \
57                proxy_auth_enabled proxy_enabled proxy_port proxy_type ratio_limit \
58                ratio_limit_enabled rename_partial_files rpc_authentication_required \
59                rpc_enabled rpc_port rpc_whitelist_enabled script_torrent_done_enabled \
60                speed_limit_down speed_limit_down_enabled speed_limit_up \
61                speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
62                umask upload_slots_per_torrent watch_dir_enabled
63
64        append_params_quotes "$s" \
65                bind_address_ipv4 bind_address_ipv6 download_dir incomplete_dir proxy \
66                proxy_auth_password proxy_auth_username rpc_bind_address rpc_password \
67                rpc_username rpc_whitelist script_torrent_done_filename watch_dir
68
69        echo "\""invalid-key"\": false" >> $config_dir/settings.json
70        echo "}" >> $config_dir/settings.json
71       
72        eval "$SSD -q -b -x $BIN -S -- -g $config_dir"
73}
74
75start() {
76        config_load transmission
77        config_foreach start_service transmission
78}
79
80stop() {
81        killall `basename $BIN`
82}
83
84restart() {
85        stop; sleep 5; start
86}
Note: See TracBrowser for help on using the repository browser.