summaryrefslogtreecommitdiffstats
path: root/.scripts
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-08-08 18:33:02 -0400
committerGitHub <noreply@github.com>2018-08-08 18:33:02 -0400
commit53fa60e3dd061f35d5f37c66dfab600890338acd (patch)
tree58b10d900ef58aa6c2b652054713945b44047655 /.scripts
parentcb1975a91be2752f9526fe3617e6415312c4bca1 (diff)
parent832f1b32231a7c9cc99e8fe3a03d29ba4ecff5f2 (diff)
downloadeibhear-53fa60e3dd061f35d5f37c66dfab600890338acd.tar.gz
eibhear-53fa60e3dd061f35d5f37c66dfab600890338acd.tar.zst
eibhear-53fa60e3dd061f35d5f37c66dfab600890338acd.zip
Merge pull request #95 from TomJansen/master
tpb: start transmission-daemon if it is not running
Diffstat (limited to '.scripts')
-rwxr-xr-x.scripts/tpb31
1 files changed, 18 insertions, 13 deletions
diff --git a/.scripts/tpb b/.scripts/tpb
index fb1b5b6..7a2913a 100755
--- a/.scripts/tpb
+++ b/.scripts/tpb
@@ -11,6 +11,7 @@
# you can add -- at the end to indicate end of options
# (if your program supports it, most do)
program='/usr/bin/transmission-remote -a'
+daemon='transmission-daemon'
TPB="https://thepiratebay.org"
# show N first matches by default
@@ -140,22 +141,26 @@ if [ -z "$down" ] ; then
exit 0
fi
-# download all torrents in list
+# starts daemon if it was not already running and download all torrents in list
echo -n "Downloading torrent(s): "
-for torrent in $down ; do
- # check if ID is valid and in range of results, download torrent
- if [ $torrent -ge 1 ] ; then
- if [ $torrent -le $limit ] ; then
- echo -n "$torrent "
- command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`"
- status=$(eval "$command" 2>&1)
- if [ $? -ne 0 ] ; then
- echo -n '(failed!) '
- report="$report\n(#$torrent) $status"
+if ! [ "$(pidof $daemon)" ]; then
+ $daemon
+ for torrent in $down ; do
+ # check if ID is valid and in range of results, download torrent
+ if [ $torrent -ge 1 ] ; then
+ if [ $torrent -le $limit ] ; then
+ echo -n "$torrent "
+ command="$program `echo "$r" | awk -F '|' 'NR=='$torrent'{print $2; exit}'`"
+ status=$(eval "$command" 2>&1)
+ if [ $? -ne 0 ] ; then
+ echo -n '(failed!) '
+ report="$report\n(#$torrent) $status"
+ fi
fi
fi
- fi
-done
+ done
+fi
+
echo
if [ -n "$report" ] ; then
echo -n "Exited with errors:"