summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2015-11-25 00:43:04 -0500
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2015-11-25 00:43:04 -0500
commitd9679d54b95cb6e2d9dea9c3d8550355007531c8 (patch)
treeb1ea1885cdf36c9a8700c91c4d8d5b7a7b0dc006
parentaec1e3e329b0828a8615529ccb9f6a941457b70b (diff)
Finish import script.
-rwxr-xr-ximport/photobox_import2.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/import/photobox_import2.sh b/import/photobox_import2.sh
index d49a356..050154a 100755
--- a/import/photobox_import2.sh
+++ b/import/photobox_import2.sh
@@ -23,21 +23,31 @@ readonly pending_path="$(make_unique $pending_root/$(date +%Y-%m-%d))"
(
flock -x -w 120 200 || exit 1
+ if [[ $input != *Kingston* ]]; then
+ echo "Not on the SD card reader: $input"
+ exit 1
+ fi
+ if [[ -z $(find "$input" -type f -print -quit | head) ]]; then
+ echo "No files found. Exiting."
+ umount $input
+ exit 0
+ fi
+
mkdir -p "$backup_path"
rsync -Hvax "$input/." "$backup_path/."
echo "Contents backed up to: $backup_path"
if [[ -d "$backup_path/DCIM" && \
- -n $(find "$backup_path/DCIM" -iregex "$photoregex" -print -quit) ]]; then
- "Found photos"
+ -n $(find "$backup_path/DCIM" -iregex "$photoregex" -print -quit | head) ]]; then
+ echo "Found photos"
mkdir -p "${pending_path}.importing"
rsync -avx "$backup_path"/DCIM/*/* "${pending_path}.importing/"
mv "${pending_path}.importing" "${pending_path}"
echo "Photos written to ${pending_path}"
fi
- "Deleting original files"
+ echo "Deleting original files"
# Prevents 'rm -rf /'
- rm -r "/media/$(basename $input)/*"
+ rm -r "/media/$(basename $input)"
umount "${input}"
) 200>/tmp/photobox_import2.lock | systemd-cat -t photobox_import