Files
shell_sequencer/seqs/transmission.sh

144 lines
4.1 KiB
Bash
Executable File

#!/bin/bash
toolName=transmission
toolDeps=transmission-daemon
toolService=transmission-daemon
toolUser=debian-transmission
toolCronLoc="/etc/cron.d/transmission_daemon"
toolRemote="$(command -v transmission-remote)"
# Get script working directory
# (when called from a different directory)
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
APTOPT=
CONFIG=0
SCRIPT_NAME=$(basename -- $0)
SCRIPT_NAME=${SCRIPT_NAME%%.*}
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
step_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
else
# End if no configuration file exists
[ $DRY -eq 0 ] && return 1
fi
[ $QUIET -ne 0 ] && APTOPT="-y"
return 0
}
step_1_info() { echo "Install $toolName"; }
step_1_alias() { ALIAS="install"; }
step_1() {
exe apt update
exe apt install $toolDeps $APTOPT
exe systemctl stop $toolService
exe systemctl disable $toolService
exe mkdir -p "$TRDA_WATCH_LOCAL"
exe chown ${toolUser}: "$TRDA_WATCH_LOCAL"
}
step_10_info() { echo "Setup blocklist update cron job"; }
step_10_alias() { ALIAS="bllupdate"; }
step_10() {
addConf -s "$TRDA_REMOTE_AUTH" "$TRDA_REMOTE_AUTH_LOC"
[ $? -eq 0 ] && exe chmod 600 "$TRDA_REMOTE_AUTH_LOC"
addConf -s "$TRDA_CRON" "$toolCronLoc"
}
step_11_info() { echo "Setup remote authentication for current user (~/.netrc)"; }
step_11_alias() { ALIAS="netrcauth"; }
step_11() {
local lRemoteAuth="$(realpath ~/.netrc)"
if [ ! -f "$lRemoteAuth" ]; then
addConf -s "$TRDA_REMOTE_AUTH" "$lRemoteAuth"
[ $? -eq 0 ] && exe chmod 600 "$lRemoteAuth"
fi
}
step_12_info() { echo "Add ufw rules for rpc and peer port (default 9091 and 51413)"; }
step_12_alias() { ALIAS="ufw"; }
step_12() {
local trdaRpcPort=9091
exe ufw allow in on eth0 to any port $trdaRpcPort proto tcp comment "Transmission rpc"
exe ufw allow in on tun0 to any port $TRDA_PEER_PORT comment "Transmission peer port"
exe ufw deny out on eth0 to any port $TRDA_PEER_PORT comment "Suppress transmission escapes"
}
step_20_info() { echo "Configuration notes"; }
step_20_alias() { ALIAS="notes"; }
step_20() {
outColor green
cat <<NOTES_EOF
[I] Change rpc password
1) Make sure $toolName service is stopped before editing the configuration file.
2) Adjust config and enter clear text password like this:
"rpc-password": "MYTRANSMISSIONPASS",
3) Start $toolName service again, which will hash the password in the config
[I] Some notes about configuration for smaller internet bandwith
[/etc/transmission/settings.json]
"alt-speed-down": 500,
"alt-speed-enabled": true,
"alt-speed-up": 16,
"blocklist-enabled": true,
"blocklist-url": "http://john.bitsurge.net/public/biglist.p2p.gz",
"download-dir": "/DOWNLOAD_DIR/completed",
"idle-seeding-limit": 15,
"idle-seeding-limit-enabled": true,
"incomplete-dir": "/DOWNLOAD_DIR/incomplete",
"message-level": 1,
"ratio-limit": 0.2000,
"ratio-limit-enabled": true,
"rpc-whitelist": "127.0.0.1,192.168.0.*",
"speed-limit-down": 360,
"speed-limit-up": 16,
"speed-limit-up-enabled": true,
"utp-enabled": true,
"watch-dir": "/var/torrentwatch",
"watch-dir-enabled": true
[I] Changes requested by transmission-daemon
Check syslog after startup to find values for your system.
[/etc/sysctl.conf]
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
NOTES_EOF
}
step_50_info() { echo "List all available torrents"; }
step_50_alias() { ALIAS="list"; }
step_50() {
step netrcauth
outColor green
exe "$toolRemote" -l
}
step_52_info() { echoinfoArgs "<TORRENT ID>"; echo "List information about a torrent"; }
step_52_alias() { ALIAS="info"; }
step_52() {
shift
endCheckEmpty 1 "Id must not be empty"
step netrcauth
outColor green
exep "\"$toolRemote\" -t$1 -i | less"
}
step_54_info() { echo "$toolName status"; }
step_54_alias() { ALIAS="status"; }
step_54() {
step netrcauth
outColor green
exe "$toolRemote" -si
exe "$toolRemote" -st
}
VERSION_SEQREV=13
. /usr/local/bin/sequencer.sh