torrent fix

This commit is contained in:
rootzoll
2018-07-25 17:58:27 +02:00
parent ce36c99dae
commit d9efbd5d2a

View File

@@ -17,24 +17,45 @@ if [ ${mountOK} -eq 1 ]; then
# HDD is empty - download HDD content # HDD is empty - download HDD content
echo "OK - HDD is ready." echo "OK - HDD is ready."
echo "" echo ""
echo "*** Downloading HDD ***"
tmpfile=$(mktemp) downloading=1
chmod a+x $tmpfile retry=0
echo "killall transmission-cli" > $tmpfile while [ $downloading -eq 1 ]
sudo transmission-cli ./assets/$torrent.torrent -D -w /mnt/hdd -f $tmpfile do
echo "" echo "*** Downloading HDD ***"
echo "*** Checking Download ***" tmpfile=$(mktemp)
echo "wait a moment" chmod a+x $tmpfile
sleep 5 echo "killall transmission-cli" > $tmpfile
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile
if [ ${#downloadsize} -eq 0 ]; then echo ""
downloadsize=0 echo "*** Checking Download ***"
fi echo "wait a moment"
# add some tolerance for checking sleep 5
torrentsize="$(($torrentsize-1024000))" downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9')
echo "download size is(${downloadsize})" if [ ${#downloadsize} -eq 0 ]; then
downloadsize=0
fi
# add some tolerance for checking
torrentsize="$(($torrentsize-1024000))"
echo "download size is(${downloadsize})"
if [ ${downloadsize} -lt ${torrentsize} ]; then
echo ""
echo "FAIL - download is not ${torrentsize}"
retry=$(($retry+1))
if [ ${retry} -gt 2 ]; then
echo "All Retry FAILED"
downloading=0
else
echo "--> RETRY(${retry}) in 10 secs"
sleep 10
echo ""
fi
else
echo "OK - Download is complete"
downloading=0
fi
done
if [ ${downloadsize} -lt ${torrentsize} ]; then if [ ${downloadsize} -lt ${torrentsize} ]; then
echo "FAIL - download is not ${torrentsize}"
sleep 3 sleep 3
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57 dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57
response=$? response=$?