blob: 867b5538d929d9f2548f08b5412f4abd78e3140d (
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
|
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
START=99
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local _loctmp
config_get_bool _loctmp "$section" "$option" 0
[ "$_loctmp" -gt 0 ] && append args "$value"
}
append_parm() {
local section="$1"
local option="$2"
local switch="$3"
local _loctmp
config_get _loctmp "$section" "$option"
[ -z "$_loctmp" ] && return 0
append args "$switch $_loctmp"
}
btpd() {
local cfg="$1"
args=""
directory=""
append_bool "$cfg" useipv4 "-4"
append_bool "$cfg" useipv6 "-6"
append_bool "$cfg" emptystart "--empty-start"
append_parm "$cfg" port "-p"
append_parm "$cfg" directory "-d"
append_parm "$cfg" maxpeers "--max-peers"
append_parm "$cfg" maxuploads "--max-uploads"
append_parm "$cfg" maxkbin "--bw-in"
append_parm "$cfg" maxkbout "--bw-out"
config_get directory "$cfg" directory
}
start() {
config_load btpd
config_foreach btpd btpd
service_start /usr/bin/btpd $args
}
stop() {
config_load btpd
config_foreach btpd btpd
[ -d $directory ] && args="-d $directory "
while btcli $args kill ; do
sleep 3
done 2>/dev/null
service_stop /usr/bin/btpd
}
|