daily pastebin goal
95%
SHARE
TWEET

Untitled

a guest Apr 25th, 2018 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Login Info
  4. login="username"
  5. pass="password"
  6. host="hostname or IP"
  7. port="port number"
  8.  
  9. # Folders on seedbox
  10. movie_dir='/home/user/completed/movie-radarr/'
  11. tv_dir='/home/user/completed/tv-sonarr/'
  12.  
  13. # Folders on local
  14. local_movie_dir="/mnt/media/seedbox/Movies/Transferring/"
  15. local_movie_complete="/mnt/media/seedbox/Movies/Completed/"
  16. local_tv_dir="/mnt/media/seedbox/TV/Transferring/"
  17. local_tv_complete="/mnt/media/seedbox/TV/Completed/"
  18.  
  19. # Transfer files
  20. base_name="$(basename "$0")"
  21. lock_file="/tmp/$base_name.lock"
  22. trap "rm -f $lock_file; exit 0" SIGINT SIGTERM
  23. if [ -e "$lock_file" ]
  24. then
  25.     now="$(date +'%Y-%m-%d %H:%M:%S')"
  26.     echo "$now|$base_name is running already."
  27.     exit
  28. else
  29.     touch "$lock_file"
  30.     /usr/local/bin/lftp -p "$port" -u "$login","$pass" sftp://"$host" << EOF
  31.     set sftp:auto-confirm yes
  32.     set xfer:use-temp-file yes
  33.     set xfer:temp-file-name *.lftp
  34.         mirror -c --use-pget-n=25 --Move --log="/log/movie.log" "$movie_dir" "${local_movie_dir}."
  35.         mirror -c -P5 --use-pget-n=5 --Move --log="/log/tv.log" "$tv_dir" "${local_tv_dir}."
  36.     quit
  37. EOF
  38.  
  39.     # Move files
  40.     now="$(date +'%Y-%m-%d %H:%M:%S')"
  41.     if [ "$(ls -A $local_movie_dir)" ]; then
  42.     mv "$local_movie_dir"* "$local_movie_complete"
  43.     echo "$now|Movie transfer completed"
  44.     fi
  45.     if [ "$(ls -A $local_tv_dir)" ]; then
  46.     mv "$local_tv_dir"* "$local_tv_complete"
  47.     echo "$now|TV transfer completed"
  48.     fi
  49.  
  50.     rm -f "$lock_file"
  51.     trap - SIGINT SIGTERM
  52.     exit
  53. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Pastebin PRO 'AUTUMN SPECIAL'!
Get 60% OFF Pastebin PRO accounts!
 
Top