transmission: make the memory percentage allowed configurable
authorNikos Mavrogiannopoulos <redacted>
Fri, 12 Jun 2015 22:28:47 +0000 (00:28 +0200)
committerNikos Mavrogiannopoulos <redacted>
Fri, 12 Jun 2015 22:28:47 +0000 (00:28 +0200)
Signed-off-by: Nikos Mavrogiannopoulos <redacted>
net/transmission/files/transmission.config
net/transmission/files/transmission.init

index a8fd56d9b1f65fbe76eed23562f2b4572548e249..31e2d5af4a6fa1a5244d1e265deca13ae2080bc3 100644 (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
index 000043b7af4ee5d641031c35e1efdfac503576da..d9b52bb67270141493356507f61b66c95f514741 100644 (file)
@@ -44,21 +44,23 @@ section_enabled() {
 
 transmission() {
        local cfg="$1"
-       #give transmission 3/5 of the memory of the system
        local USE
-       local MEM=`grep MemTotal /proc/meminfo|sed 's/ \+/ /g'|cut -d ' ' -f 2`
-       if test "$MEM" -gt 1;then
-               USE=`expr $MEM \* 3000 / 5`
-       fi
 
        local user
        local download_dir
+       local mem_percentage
 
        section_enabled "$section" || return 1
 
        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=$(grep MemTotal /proc/meminfo|sed 's/ \+/ /g'|cut -d ' ' -f 2)
+       if test "$MEM" -gt 1;then
+               USE=$(expr $MEM \* $mem_percentage \* 10)
+       fi
 
        config_file="$config_dir/settings.json"
        [ -d $config_dir ] || {
git clone https://git.99rst.org/PROJECT