Skip to content

Instantly share code, notes, and snippets.

@bulljit
Created January 23, 2011 00:08
Show Gist options
  • Save bulljit/791642 to your computer and use it in GitHub Desktop.
Save bulljit/791642 to your computer and use it in GitHub Desktop.
Transmission-Daemon Script: Pause & Resume Torrents
#!/bin/sh
NETRC=~/.netrc.transmission
TR="transmission-remote -N $NETRC" # command + authentication
FILE="lastrunning.list"
# accepts arguments -sleep -wake
if [ -z "$1" ]; then
echo usage: $0 -sleep or -wake
exit
fi
if [ "$1" = "-sleep" ]; then
# save ID# of non-stopped torrents to array
IDa=`$TR -l | grep -v Stopped | sed -e '1d' -e '$d' | awk '{print $1}'`
# save unique hash# for non-stopped torrents instead of dynamic ID#
for ID in $IDa; do
$TR -t $ID -i | grep '^ Hash: ' | cut -c 9- >> $FILE
done
# pause all torrents
$TR -t all --stop
elif [ "$1" = "-wake" ]; then
HASHa=($(cat $FILE))
for (( i=0;i<${#HASHa[@]};i++)); do
$TR -t ${HASHa[${i}]} --start
done
rm $FILE # delete tempfile
fi
exit
@niro1987
Copy link

niro1987 commented May 9, 2014

i saved this script in /home/pi
When i execute it i get:

: not foundansmission_resume.sh: 2: /home/pi/transmission_resume.sh:
: not foundansmission_resume.sh: 6: /home/pi/transmission_resume.sh:
/home/pi/transmission_resume.sh: 17: /home/pi/transmission_resume.sh: Syntax error: word unexpected (expecting "do")

@RAnders00
Copy link

RAnders00 commented May 6, 2016

THIS VERSION OF THE SCRIPT IS BROKEN

You can find a working fork on the gist by @davidsblom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment