Browse Source

change to rtorrent

#146
rootzoll 6 years ago
parent
commit
7f1b81d0a6
  1. 42
      home.admin/50torrentHDD.sh

42
home.admin/50torrentHDD.sh

@ -12,8 +12,8 @@ litecoinTorrentsize=10240000
# load network # load network
network=`cat .network` network=`cat .network`
# make sure lftp is available # make sure rtorrent is available
sudo apt-get install lftp -y sudo apt-get install rtorrent -y
echo "" echo ""
# settings based on network # settings based on network
@ -28,10 +28,10 @@ fi
name="Torrent" name="Torrent"
targetDir="/mnt/hdd/torrent" targetDir="/mnt/hdd/torrent"
targetSize=$size targetSize=$size
maxTimeoutLoops=100000 sessionDir="/home/admin/.rtorrent.session/"
command="sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"" command="sudo rtorrent -n -d ${targetDir} -s ${sessionDir} ./home/admin/assets/${torrent}.torrent"
# starting session if needed # starting screen session if needed
echo "checking if ${name} has a running screen session" echo "checking if ${name} has a running screen session"
screen -wipe 1>/dev/null screen -wipe 1>/dev/null
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
@ -39,6 +39,7 @@ echo "isRunning(${isRunning})"
if [ ${isRunning} -eq 0 ]; then if [ ${isRunning} -eq 0 ]; then
echo "Starting screen session" echo "Starting screen session"
sudo mkdir ${targetDir} 2>/dev/null sudo mkdir ${targetDir} 2>/dev/null
sudo mkdir ${sessionDir} 2>/dev/null
screenCommand="screen -S ${name} -L screen.log -dm ${command}" screenCommand="screen -S ${name} -L screen.log -dm ${command}"
echo "${screenCommand}" echo "${screenCommand}"
bash -c "${screenCommand}" bash -c "${screenCommand}"
@ -47,20 +48,17 @@ else
fi fi
sleep 3 sleep 3
# monitor session # monitor screen session
screenDump="... started ..." screenDump="... started ..."
actualSize=0 actualSize=0
timeout=1 torrentComplete=0
timeoutInfo="-"
while : while :
do do
# check if session is still running # check if completed by inspecting rtorrent session files
screen -wipe 1>/dev/null torrentComplete=$(cat /home/admin/.rtorrent.session/*.torrent.libtorrent_resume | grep ':completei1' -c)
isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) if [ ${torrentComplete} -eq 1 ]; then
if [ ${isRunning} -eq 0 ]; then echo "OK - torrent finished"
timeout=0
echo "OK - session finished"
break break
fi fi
@ -72,29 +70,13 @@ while :
progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc)
echo $progress > ".${name}.progress" echo $progress > ".${name}.progress"
# detect if since last loop any progress occured
#if [ ${actualSize} -eq ${freshSize} ]; then
# timeoutInfo="${timeout}/${maxTimeoutLoops}"
# timeout=$(( $timeout + 1 ))
#else
# timeout=1
# timeoutInfo="no timeout detected"
#fi
actualSize=$freshSize actualSize=$freshSize
# detect if mx timeout loop limit is reached
#if [ ${timeout} -gt ${maxTimeoutLoops} ]; then
# echo "FAIL - download hit timeout"
# break
#fi
# display info screen # display info screen
clear clear
echo "****************************************************" echo "****************************************************"
echo "Monitoring Screen Session: ${name}" echo "Monitoring Screen Session: ${name}"
echo "Progress: ${progress}% (${actualSize} of ${targetSize})" echo "Progress: ${progress}% (${actualSize} of ${targetSize})"
#echo "Timeout: ${timeoutInfo}"
echo "If needed press key x to stop ${name}" echo "If needed press key x to stop ${name}"
echo "NOTICE: This can take multiple hours or days !!" echo "NOTICE: This can take multiple hours or days !!"
echo "Its OK to close terminal now and SSH back in later." echo "Its OK to close terminal now and SSH back in later."

Loading…
Cancel
Save