Hi All,
I have a mini pc that the wife and I take on holiday with us, so we can connect it to the hotel room tv and stream from emby at home. (foudn this to be much more usable than an amazon fire stick.
I would like to use this to automatically download all of the photos from a digital camera memory card when the card is inserted. I have a script and it works, but i cannot for the life of me get the service / path to work: my files are:
#Automatic Photo Backup on Card Insertion
1 messages · Page 1 of 1 (latest)
/etc/systemd/system/photo-import.path:
[Unit]
Description=Watch for media mount
[Path]
PathExistsGlob=/media/woods/*
[Install]
WantedBy=multi-user.target
/etc/systemd/system/photo-import.system:
[Unit]
Description=Import photos from memory cards
After=local-fs.target
[Service]
Type=oneshot
User=woods
ExecStartPre=/bin/sleep 10
ExecStart=/home/woods/Scripts/import_photos.sh
Restart=no
[Install]
WantedBy=multi-user.target
any my script:
#!/bin/bash
IMPORT_DIR=/home/woods/Pictures/Import
LOG_FILE=/home/woods/photo-import.log
echo "$(date): Starting import script" >> "$LOG_FILE"
MOUNTED=0
for MOUNT_POINT in /media/woods/*; do
if mountpoint -q "$MOUNT_POINT"; then
MOUNTED=1
echo "$(date): Found mounted media at $MOUNT_POINT" >> "$LOG_FILE"
# Check if there are files to copy
FILES=("$MOUNT_POINT"/*)
if [ -e "${FILES[0]}" ]; then
echo "$(date): Copying files from $MOUNT_POINT to $IMPORT_DIR" >> "$LOG_FILE"
cp -nrv "$MOUNT_POINT/"* "$IMPORT_DIR/" >> "$LOG_FILE" 2>&1
else
echo "$(date): No files found in $MOUNT_POINT" >> "$LOG_FILE"
fi
else
echo "$(date): $MOUNT_POINT is not a mountpoint" >> "$LOG_FILE"
fi
done
if [ "$MOUNTED" -eq 0 ]; then
echo "$(date): No mounted media found" >> "$LOG_FILE"
fi
sync
echo "$(date): Import complete" >> "$LOG_FILE"