From ff7aa509fa7b05465270769c99dfc4e06afd57bf Mon Sep 17 00:00:00 2001 From: example Date: Fri, 20 Oct 2017 07:42:08 -0500 Subject: [PATCH] Fixes for wolfpack to use right torrentfile location --- offload-wolfpack | 60 +++++++++++++++++++++++++++++------------------- wolfpack | 8 ++++--- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/offload-wolfpack b/offload-wolfpack index a316f4d..7c397d9 100755 --- a/offload-wolfpack +++ b/offload-wolfpack @@ -1,30 +1,42 @@ #!/bin/bash logfile=/var/log/wolfpack.log -lockdir="/tmp/offload-wolfpack-lock" -target='cxford@10.0.1.3' +target="$1" +dir=`sudo -u deluge deluge-console config download_location 2>/dev/null | head -n 1 | sed 's/ download_location: //'` -mkdir "$lockdir" -if [ $? -ne 0 ]; then - echo "Wolfpack running elsewhere" +if [ -z "$target" ]; then + echo Usage: $0 '[target]'; exit 1 fi -echo Starting VPN and delaying 40 seconds.... -systemctl start vpn -sleep 40 -echo | systemctl status vpn | tee -a $logfile -/usr/local/bin/wolfpack --alpha -sleep 10 -rsync -avz /srv/yggdrasil/new_acquisition/* cxford@10.0.1.3:/srv/yggdrasil/new_acquisition 2>&1 | tee -a $logfile -ls -l /srv/yggdrasil/new_acquisition | tee -a $logfile -echo Files transferred from $(uname -n). | tee -a $logfile -rm -Rf /srv/yggdrasil/new_acquisition/* -cat $logfile | ssh cxford@aninix.net "cat >> $logfile" -rm $logfile -for i in $(ls /usr/local/etc/WolfPack/*.pup); do - export cmdstring="$(echo $i | sed "s/pup/$(uname -n)/")" - scp "$i" "$target":"$cmdstring" -done -systemctl stop vpn -systemctl restart openntpd -rmdir "$lockdir" + +sudo -u deluge deluge-console info 2>/dev/null | ( +unset name; +unset id; +unset state; +while read line; do + case "$line" in + "Name:"*) name="$(echo $line | sed 's/Name: //')"; ;; + "State:"*) state="$(echo $line | cut -f 2 -d ' ')"; ;; + "ID:"*) id="$(echo $line | sed 's/ID: //')"; ;; + *) + if [ ! -z "$name" ] && [ ! -z "$id" ] && [ ! -z "$state" ]; then + echo Found "$name" "($id)" with state "$state" + if [ -e "$dir"'/'"$name" ]; then + echo "$name" exists on disk. + fi + if [ "$state" == "Seeding" ]; then + sudo -u deluge deluge-console 2>/dev/null rm "$id"; + rsync -avz "$dir"'/'"$name" $target:/srv/yggdrasil/new_acquisition + ret="$?" + if [ "$ret" -eq 0 ]; then + rm -Rf "$dir"'/'"$name" + else + echo "ERROR: Return was $ret" >> "$dir"/"$name"/error.log + fi + fi; + unset name; unset id; unset state; + fi ;; + esac +done) +cat /var/log/wolfpack.log | ssh $target /bin/bash -c 'cat >> /var/log/wolfpack.log' +cat /dev/null > /var/log/wolfpack.log diff --git a/wolfpack b/wolfpack index 8bdf37e..fd0bcd8 100755 --- a/wolfpack +++ b/wolfpack @@ -78,7 +78,8 @@ function torrent { fi privacycheck; export downloaddir=$(head -n 2 "$1" | tail -n 1) - sudo -u deluge deluge-console config -s torrentfiles_location "$downloaddir" 2>/dev/null + sudo -u deluge deluge-console config -s autoadd_location "$downloaddir" 2>/dev/null + sudo -u deluge deluge-console config -s download_location "$downloaddir" 2>/dev/null for i in $(tail -n +3 "$1"); do getmagnetlink "$i" if [ "$magnetlink" != "" ]; then @@ -98,7 +99,8 @@ function shows { fi privacycheck; export downloaddir=$(head -n 2 "$1" | tail -n 1) - sudo -u deluge deluge-console config -s torrentfiles_location "$downloaddir" 2>/dev/null + sudo -u deluge deluge-console config -s autoadd_location "$downloaddir" 2>/dev/null + sudo -u deluge deluge-console config -s download_location "$downloaddir" 2>/dev/null for i in $(tail -n +3 "$1"); do sepisode=$(echo $i | cut -f 1 -d '#' | xargs) showName="$(echo $i | cut -f 2 -d '#' | xargs)" @@ -131,7 +133,7 @@ function shows { echo "S${newseason}E01" $showName | tee -a "$logfile" echo "$magnetlink" | tee -a "$logfile" /bin/bash -c "$downloadtorrent $magnetlink" - sed -i "s/$i/S${newseason}E01#$showName#$modifier/" "$1" + sed -i "s/$i/S${newseason}E02#$showName#$modifier/" "$1" else nextAirDate="$(nextairdate "$showName")" if [ ! -z "$nextAirDate" ]; then