Created
January 23, 2011 00:08
-
-
Save bulljit/791642 to your computer and use it in GitHub Desktop.
Transmission-Daemon Script: Pause & Resume Torrents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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")