original.sh 956 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. # Use install.sh to edit settings
  3. # if the mount already exists, unmount it
  4. mountpoint -q -- "{{mount_dir}}" && fusermount -u "{{mount_dir}}"
  5. # make temp directory (ftp does not support rsync temp files)
  6. [[ ! -d "{{temp_dir}}" ]] && mkdir -p "{{temp_dir}}"
  7. # Mount it and rsync over the photos
  8. if curlftpfs -o uid="{{user_id}}",gid="{{group_id}}" "{{ftp_share}}" "{{mount_dir}}"; then
  9. if ! rsync -r --delete --quiet --temp-dir="{{temp_dir}}" "{{source_dir}}/" "{{mount_dir}}"; then
  10. echo "rsync -r --delete --quiet {{source_dir}}/ {{mount_dir}} failed!"
  11. exit 1
  12. fi
  13. if ! fusermount -u "{{mount_dir}}"; then
  14. echo "Could not unmount {{mount_dir}}"
  15. exit 1
  16. fi
  17. else
  18. echo "Could not mount ftp share"
  19. if ping -c 1 "{{ftp_share}}"; then
  20. echo "Ping OK, check the ftp device settings or the local filesystem permissions"
  21. exit 1
  22. else
  23. echo "Could not ping the device, is it on?"
  24. exit 1
  25. fi
  26. fi
  27. exit $?