transmission: add nice and ionice support, store persistent config, add transmission... 1634/head
authorMaxim Storchak <m.storchak@gmail.com>
Sat, 1 Aug 2015 16:48:00 +0000 (19:48 +0300)
committerMaxim Storchak <m.storchak@gmail.com>
Sun, 2 Aug 2015 18:54:34 +0000 (21:54 +0300)
Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
net/transmission/Makefile
net/transmission/files/transmission.config
net/transmission/files/transmission.init

index 8b50cd69c9ad7583fb9046fd4aa858541a8135c1..1cd4b91f63f3f9b751a166ca0cc3cc2a9a400e70 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=transmission
 PKG_VERSION:=2.84
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://download-origin.transmissionbt.com/files/ http://mirrors.m0k.org/transmission/files
@@ -34,6 +34,7 @@ define Package/transmission-daemon
   $(call Package/transmission/template)
   DEPENDS:=+libcurl +libopenssl +libpthread +libevent2 +librt
   MENU:=1
+  USERID:=transmission=224:transmission=224
 endef
 
 define Package/transmission-cli
index 31e2d5af4a6fa1a5244d1e265deca13ae2080bc3..2ea69d057b6e469256b6170aa37380f3dc137902 100644 (file)
@@ -3,6 +3,8 @@ config transmission
        option config_dir '/tmp/transmission'
        #option user 'nobody'
        option mem_percentage 50
+       option nice 10
+       option ionice_flags '-c 3'
        option alt_speed_down 50
        option alt_speed_enabled false
        option alt_speed_time_begin  540
index 535ace8bb1362ac5649229030b4f21401ac75a76..f7b1d41e1ef3d1e79a195a2e8a5edd05f6add2b8 100644 (file)
@@ -47,8 +47,10 @@ transmission() {
        local USE
 
        local user
-       local download_dir
+       local download_dir config_dir
        local mem_percentage
+       local config_overwrite nice ionice_flags
+       local cmdline
 
        section_enabled "$section" || return 1
 
@@ -56,6 +58,10 @@ transmission() {
        config_get user "$cfg" 'user'
        config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission'
        config_get mem_percentage "$cfg" 'mem_percentage' '50'
+       config_get config_overwrite "$cfg" config_overwrite 1
+       config_get nice "$cfg" nice 0
+       config_get ionice_flags "$cfg" ionice_flags ''
+       which ionice > /dev/null || ionice_flags=''
 
        local MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo)
        if test "$MEM" -gt 1;then
@@ -69,38 +75,45 @@ transmission() {
                [ -z "$user" ] || chown -R $user $config_dir
        }
 
-       echo "{" > $config_file
-
-       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 \
-               dht_enabled encryption idle_seeding_limit idle_seeding_limit_enabled \
-               incomplete_dir_enabled lazy_bitfield_enabled lpd_enabled message_level \
-               peer_limit_global peer_limit_per_torrent peer_port \
-               peer_port_random_high peer_port_random_low peer_port_random_on_start \
-               pex_enabled port_forwarding_enabled preallocation prefetch_enabled \
-               ratio_limit ratio_limit_enabled rename_partial_files rpc_authentication_required \
-               rpc_enabled rpc_port rpc_whitelist_enabled queue_stalled_enabled \
-               queue_stalled_minutes scrape_paused_torrents_enabled script_torrent_done_enabled \
-               seed_queue_enabled seed_queue_size \
-               speed_limit_down speed_limit_down_enabled speed_limit_up \
-               speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
-               umask upload_slots_per_torrent utp_enabled scrape_paused_torrents \
-               watch_dir_enabled
-
-       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
-
-       echo "\""invalid-key"\": false" >> $config_file
-       echo "}" >> $config_file
+       [ "$config_overwrite" == 0 ] || {
+
+               echo "{" > $config_file
+
+               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 \
+                       dht_enabled encryption idle_seeding_limit idle_seeding_limit_enabled \
+                       incomplete_dir_enabled lazy_bitfield_enabled lpd_enabled message_level \
+                       peer_limit_global peer_limit_per_torrent peer_port \
+                       peer_port_random_high peer_port_random_low peer_port_random_on_start \
+                       pex_enabled port_forwarding_enabled preallocation prefetch_enabled \
+                       ratio_limit ratio_limit_enabled rename_partial_files rpc_authentication_required \
+                       rpc_enabled rpc_port rpc_whitelist_enabled queue_stalled_enabled \
+                       queue_stalled_minutes scrape_paused_torrents_enabled script_torrent_done_enabled \
+                       seed_queue_enabled seed_queue_size \
+                       speed_limit_down speed_limit_down_enabled speed_limit_up \
+                       speed_limit_up_enabled start_added_torrents trash_original_torrent_files \
+                       umask upload_slots_per_torrent utp_enabled scrape_paused_torrents \
+                       watch_dir_enabled
+
+               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
+
+               echo "\""invalid-key"\": false" >> $config_file
+               echo "}" >> $config_file
 
+       }
+
+       cmdline="/usr/bin/transmission-daemon -g $config_dir -f"
+       [ "$ionice_flags" ] && cmdline="ionice $ionice_flags $cmdline"
        procd_open_instance
-       procd_set_param command /usr/bin/transmission-daemon -g $config_dir -f
+       procd_set_param command $cmdline
        procd_set_param respawn retry=60
        procd_set_param user "$user"
+       procd_set_param nice "$nice"
        if test -z "$USE";then
                procd_set_param limits core="0 0"
        else