|
@ -3,75 +3,70 @@ |
|
|
|
|
|
|
|
|
START=99 |
|
|
START=99 |
|
|
USE_PROCD=1 |
|
|
USE_PROCD=1 |
|
|
|
|
|
PROG="/usr/bin/transmission-daemon" |
|
|
|
|
|
|
|
|
LIST_SEP=" |
|
|
LIST_SEP=" |
|
|
" |
|
|
" |
|
|
|
|
|
|
|
|
append_params() { |
|
|
append_params() { |
|
|
local p; local v; local s="$1"; shift |
|
|
local p; local v; local s="$1"; shift |
|
|
|
|
|
IFS="$LIST_SEP" |
|
|
for p in "$@"; do |
|
|
for p in "$@"; do |
|
|
config_get v "$s" "$p" |
|
|
config_get v "$s" "$p" |
|
|
IFS="$LIST_SEP" |
|
|
|
|
|
for v in $v; do |
|
|
for v in $v; do |
|
|
[ -n "$v" ] && ( |
|
|
|
|
|
echo "\"$p\": $v," | sed -e 's|_|-|g' |
|
|
|
|
|
) >> "$config_file" |
|
|
|
|
|
|
|
|
[ -n "$v" ] && echo "\"$p\": $v," | sed -e 's|_|-|g' |
|
|
done |
|
|
done |
|
|
unset IFS |
|
|
|
|
|
done |
|
|
done |
|
|
|
|
|
unset IFS |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
append_params_quotes() { |
|
|
append_params_quotes() { |
|
|
local p; local v; local s="$1"; shift |
|
|
local p; local v; local s="$1"; shift |
|
|
|
|
|
IFS="$LIST_SEP" |
|
|
for p in "$@"; do |
|
|
for p in "$@"; do |
|
|
config_get v "$s" "$p" |
|
|
config_get v "$s" "$p" |
|
|
IFS="$LIST_SEP" |
|
|
|
|
|
for v in $v; do |
|
|
for v in $v; do |
|
|
[ -n "$v" ] && ( |
|
|
|
|
|
|
|
|
[ -n "$v" ] && { |
|
|
printf "\"%s" "$p" | sed -e 's|/|\\/|g;s|_|-|g'; \ |
|
|
printf "\"%s" "$p" | sed -e 's|/|\\/|g;s|_|-|g'; \ |
|
|
echo "\": \"$v\"," |
|
|
echo "\": \"$v\"," |
|
|
) >> "$config_file" |
|
|
|
|
|
|
|
|
} |
|
|
done |
|
|
done |
|
|
unset IFS |
|
|
|
|
|
done |
|
|
done |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
section_enabled() { |
|
|
|
|
|
config_get_bool enabled "$1" enabled 0 |
|
|
|
|
|
[ $enabled -gt 0 ] |
|
|
|
|
|
|
|
|
unset IFS |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
transmission() { |
|
|
transmission() { |
|
|
local cfg="$1" |
|
|
local cfg="$1" |
|
|
local USE |
|
|
|
|
|
|
|
|
|
|
|
local user |
|
|
|
|
|
local group |
|
|
|
|
|
local config_overwrite |
|
|
|
|
|
local download_dir config_dir incomplete_dir incomplete_dir_enabled |
|
|
|
|
|
local mem_percentage |
|
|
|
|
|
local nice |
|
|
|
|
|
local web_home |
|
|
|
|
|
|
|
|
|
|
|
section_enabled "$section" || return 1 |
|
|
|
|
|
|
|
|
local enabled |
|
|
|
|
|
config_get_bool enabled "$cfg" enabled 0 |
|
|
|
|
|
[ "$enabled" -gt 0 ] || return 1 |
|
|
|
|
|
|
|
|
|
|
|
local config_dir |
|
|
config_get config_dir "$cfg" 'config_dir' '/var/etc/transmission' |
|
|
config_get config_dir "$cfg" 'config_dir' '/var/etc/transmission' |
|
|
|
|
|
local user |
|
|
config_get user "$cfg" 'user' |
|
|
config_get user "$cfg" 'user' |
|
|
|
|
|
local group |
|
|
config_get group "$cfg" 'group' |
|
|
config_get group "$cfg" 'group' |
|
|
|
|
|
local download_dir |
|
|
config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission' |
|
|
config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission' |
|
|
|
|
|
local incomplete_dir |
|
|
config_get incomplete_dir "$cfg" 'incomplete_dir' '/var/etc/transmission' |
|
|
config_get incomplete_dir "$cfg" 'incomplete_dir' '/var/etc/transmission' |
|
|
|
|
|
local incomplete_dir_enabled |
|
|
config_get incomplete_dir_enabled "$cfg" 'incomplete_dir_enabled' 0 |
|
|
config_get incomplete_dir_enabled "$cfg" 'incomplete_dir_enabled' 0 |
|
|
|
|
|
local mem_percentage |
|
|
config_get mem_percentage "$cfg" 'mem_percentage' '50' |
|
|
config_get mem_percentage "$cfg" 'mem_percentage' '50' |
|
|
|
|
|
local config_overwrite |
|
|
config_get config_overwrite "$cfg" config_overwrite 1 |
|
|
config_get config_overwrite "$cfg" config_overwrite 1 |
|
|
|
|
|
local nice |
|
|
config_get nice "$cfg" nice 0 |
|
|
config_get nice "$cfg" nice 0 |
|
|
|
|
|
local web_home |
|
|
config_get web_home "$cfg" 'web_home' |
|
|
config_get web_home "$cfg" 'web_home' |
|
|
|
|
|
|
|
|
local MEM |
|
|
local MEM |
|
|
|
|
|
|
|
|
MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo) |
|
|
MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo) |
|
|
if test "$MEM" -gt 1;then |
|
|
|
|
|
USE=$((MEM * mem_percentage * 10)) |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
local USE |
|
|
|
|
|
[ "$MEM" -gt 1 ] && USE=$((MEM * mem_percentage * 10)) |
|
|
|
|
|
|
|
|
config_file="$config_dir/settings.json" |
|
|
config_file="$config_dir/settings.json" |
|
|
[ -d "$config_dir" ] || { |
|
|
[ -d "$config_dir" ] || { |
|
@ -99,7 +94,7 @@ transmission() { |
|
|
|
|
|
|
|
|
[ "$config_overwrite" = 0 ] || { |
|
|
[ "$config_overwrite" = 0 ] || { |
|
|
|
|
|
|
|
|
echo "{" > "$config_file" |
|
|
|
|
|
|
|
|
echo "{" |
|
|
|
|
|
|
|
|
append_params "$cfg" \ |
|
|
append_params "$cfg" \ |
|
|
alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \ |
|
|
alt_speed_down alt_speed_enabled alt_speed_time_begin alt_speed_time_day \ |
|
@ -124,15 +119,14 @@ transmission() { |
|
|
peer_congestion_algorithm peer_socket_tos rpc_bind_address rpc_password rpc_url \ |
|
|
peer_congestion_algorithm peer_socket_tos rpc_bind_address rpc_password rpc_url \ |
|
|
rpc_username rpc_host_whitelist rpc_whitelist script_torrent_done_filename watch_dir |
|
|
rpc_username rpc_host_whitelist rpc_whitelist script_torrent_done_filename watch_dir |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
echo "\"invalid-key\": false" |
|
|
echo "\"invalid-key\": false" |
|
|
echo "}" |
|
|
echo "}" |
|
|
} >> "$config_file" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} > "$config_file" |
|
|
|
|
|
|
|
|
procd_open_instance |
|
|
procd_open_instance |
|
|
procd_set_param command "/usr/bin/transmission-daemon" |
|
|
|
|
|
procd_append_param command -f --log-error -g "$config_dir" |
|
|
|
|
|
|
|
|
procd_set_param command "$PROG" |
|
|
|
|
|
procd_append_param command -f -g "$config_dir" |
|
|
procd_set_param user "$user" |
|
|
procd_set_param user "$user" |
|
|
procd_set_param group "$group" |
|
|
procd_set_param group "$group" |
|
|
procd_set_param nice "$nice" |
|
|
procd_set_param nice "$nice" |
|
@ -147,9 +141,7 @@ transmission() { |
|
|
logger -t transmission "Starting with $USE virt mem" |
|
|
logger -t transmission "Starting with $USE virt mem" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if test -d "$web_home"; then |
|
|
|
|
|
procd_set_param env TRANSMISSION_WEB_HOME="$web_home" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
[ -d "$web_home" ] && procd_set_param env TRANSMISSION_WEB_HOME="$web_home" |
|
|
|
|
|
|
|
|
procd_add_jail transmission log |
|
|
procd_add_jail transmission log |
|
|
procd_add_jail_mount "$config_file" |
|
|
procd_add_jail_mount "$config_file" |
|
@ -166,3 +158,6 @@ start_service() { |
|
|
config_foreach transmission 'transmission' |
|
|
config_foreach transmission 'transmission' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reload_service() { |
|
|
|
|
|
procd_send_signal "$PROG" |
|
|
|
|
|
} |