Created
August 15, 2014 10:58
-
-
Save Thijzer/c7de76733312da6ca602 to your computer and use it in GitHub Desktop.
a working script to start stop transmission torrent files
This file contains 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 | |
for i in $(cat $FILE) | |
do | |
$TR -t $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