Skip to content

Instantly share code, notes, and snippets.

@Thijzer
Created August 15, 2014 10:58
Show Gist options
  • Save Thijzer/c7de76733312da6ca602 to your computer and use it in GitHub Desktop.
Save Thijzer/c7de76733312da6ca602 to your computer and use it in GitHub Desktop.
a working script to start stop transmission torrent files
#!/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