Advertisement
legendairy

LFTP Script

May 13th, 2012
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. --------------------------------LFTP------------------------------------
  2. http://torrent-invites.com/seedbox-tutorials/132965-tutorial-auto-sync-seedbox-home-linux-mac-machine-lftp-shell-script.html
  3. The following instructions explain how to automate LFTP (the fastest and most automated transfer). This can be achieved through a PC, installing Cygwin, a Mac, or Linux.
  4.  
  5. To note, I have this look into my completed torrent directory called "LFTP" on my Seedbox, whenever something new is seen, they will be transferred at max bandwidth to my home. Only one instance of this script will run, if it is currently transferring, it creates a lock and will not run again until the current operation has completed.
  6.  
  7. For PC
  8. install cygwin
  9. * lftp
  10. * bash
  11. * cygrunsrv
  12. * cron
  13.  
  14. For Mac
  15. install LFTP command line
  16.  
  17.  
  18. Create a file called synctorrents.sh, replace all <> with your values
  19. ..........................................................................................
  20.  
  21. #!/bin/bash
  22. login=<username>
  23. pass=<password>
  24. host=<host dns>
  25. remote_dir=lftp/
  26. local_dir=/cygdrive/s/lftp<your directory, the S is the drive letter>
  27.  
  28. trap "rm -f /tmp/synctorrent.lock" SIGINT SIGTERM
  29. if [ -e /tmp/synctorrent.lock ]
  30. then
  31. echo "Synctorrent is running already."
  32. exit 1
  33. else
  34. touch /tmp/synctorrent.lock
  35. lftp -u $login,$pass $host << EOF
  36. set ftp:ssl-allow no
  37. set mirror:use-pget-n 5
  38. mirror -c -P5 --log=synctorrents.log $remote_dir $local_dir
  39. quit
  40. EOF
  41. rm -f /tmp/synctorrent.lock
  42. exit 0
  43. fi
  44.  
  45.  
  46. ..........................................................................................
  47. chmod +x synctorrents.sh (gives the script executing privs)
  48.  
  49. create a crontab
  50. 1. $ touch crontab (creates a blank file crontab)
  51. 2. nano crontab
  52. 3. */2 * * * * /home/user/synctorrents.sh >> /home/user/sync_cron.log 2>&1 (syncs every 2 min)
  53. 4. save and exit
  54. 5. crontab /crontab (points crontab to the file you just made and edited)
  55. 6. crontab -l (lists crontab, confirm to make sure it is linked correctly)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement