rsync-to-picture-frame.sh.original 1.0 KB

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