#!/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 <"; 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