Browse Source

Merge pull request #1363 from nmav/master

transmission: use procd
lilik-openwrt-22.03
Nikos Mavrogiannopoulos 10 years ago
parent
commit
5dc38551aa
2 changed files with 38 additions and 27 deletions
  1. +1
    -0
      net/transmission/files/transmission.config
  2. +37
    -27
      net/transmission/files/transmission.init

+ 1
- 0
net/transmission/files/transmission.config View File

@ -2,6 +2,7 @@ config transmission
option enabled 0
option config_dir '/tmp/transmission'
#option user 'nobody'
option mem_percentage 50
option alt_speed_down 50
option alt_speed_enabled false
option alt_speed_time_begin 540


+ 37
- 27
net/transmission/files/transmission.init View File

@ -1,7 +1,9 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2012 OpenWrt.org
# Copyright (C) 2010-2015 OpenWrt.org
START=99
USE_PROCD=1
LIST_SEP="
"
@ -40,14 +42,25 @@ section_enabled() {
[ $enabled -gt 0 ]
}
start_instance() {
local s="$1"
transmission() {
local cfg="$1"
local USE
local user
local download_dir
local mem_percentage
section_enabled "$section" || return 1
config_get config_dir "$s" 'config_dir' '/var/etc/transmission'
config_get user "$s" 'user'
config_get config_dir "$cfg" 'config_dir' '/var/etc/transmission'
config_get user "$cfg" 'user'
config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission'
config_get mem_percentage "$cfg" 'mem_percentage' '50'
local MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo)
if test "$MEM" -gt 1;then
USE=$(expr $MEM \* $mem_percentage \* 10)
fi
config_file="$config_dir/settings.json"
[ -d $config_dir ] || {
@ -58,7 +71,7 @@ start_instance() {
echo "{" > $config_file
append_params "$s" \
append_params "$cfg" \
alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \
alt_speed_time_enabled alt_speed_time_end alt_speed_up blocklist_enabled \
cache_size_mb download_queue_enabled download_queue_size \
@ -76,7 +89,7 @@ start_instance() {
umask upload_slots_per_torrent utp_enabled scrape_paused_torrents \
watch_dir_enabled
append_params_quotes "$s" \
append_params_quotes "$cfg" \
blocklist_url bind_address_ipv4 bind_address_ipv6 download_dir incomplete_dir \
peer_congestion_algorithm peer_socket_tos rpc_bind_address rpc_password rpc_url \
rpc_username rpc_whitelist script_torrent_done_filename watch_dir
@ -84,28 +97,25 @@ start_instance() {
echo "\""invalid-key"\": false" >> $config_file
echo "}" >> $config_file
SERVICE_UID="$user" \
service_start /usr/bin/transmission-daemon -g $config_dir
}
stop_instance() {
local s="$1"
local user
section_enabled "$section" || return 1
config_get user "$s" 'user'
SERVICE_UID="$user" \
service_stop /usr/bin/transmission-daemon
procd_open_instance
procd_set_param command /usr/bin/transmission-daemon -g $config_dir -f
procd_set_param respawn
procd_set_param user "$user"
if test -z "$USE";then
procd_set_param limits core="0 0"
else
procd_set_param limits core="0 0" as="$USE $USE"
logger -t transmission "Starting with $USE virt mem"
fi
procd_add_jail transmission log
procd_add_jail_mount $config_file
procd_add_jail_mount_rw $download_dir
procd_close_instance
}
start() {
start_service() {
config_load 'transmission'
config_foreach start_instance 'transmission'
config_foreach transmission 'transmission'
}
stop() {
config_load 'transmission'
config_foreach stop_instance 'transmission'
}

Loading…
Cancel
Save