syncPhotos.sh 742 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Config
  3. export BASE_LOCAL="/Volumes/iPhoto"
  4. SOURCE_LOCAL="/mnt/media/Pictures/iPhoto.sparsebundle"
  5. TARGET="Shared.photolibrary"
  6. if [ -z "${VIDEO_DIR}" ]; then
  7. VIDEO_DIR="${HOME}/bin/video"
  8. fi
  9. # Ensure the remote drive is available
  10. "${VIDEO_DIR}/backup/checkMount.sh"
  11. # Mount the local drive if needed
  12. MOUNTED_LOCAL=0
  13. if [ ! -d "${BASE_LOCAL}" ]; then
  14. MOUNTED_LOCAL=1
  15. hdiutil attach -readonly "${SOURCE_LOCAL}" >/dev/null 2>&1
  16. fi
  17. # Backup if all went well
  18. if [ -d "${BASE_LOCAL}" ]; then
  19. "${VIDEO_DIR}/backup/sync.sh" "${TARGET}" 1000
  20. fi
  21. # Detach the local drive if we mounted it
  22. if [ -d "${BASE_LOCAL}" ] && [ $MOUNTED_LOCAL -gt 0 ]; then
  23. hdiutil detach "${BASE_LOCAL}" >/dev/null 2>&1
  24. fi
  25. # Always exit cleanly
  26. exit 0