Auto add target dir based on camera model
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# IMPORTANT:
|
||||
# Run the install-little-backup-box.sh script first
|
||||
# to install the required packages and configure the system.
|
||||
|
||||
# Specify a storage device and its mount point
|
||||
STORAGE_MOUNT_POINT="/home/pi/BACKUP"
|
||||
HOME_DIR="/home/pi"
|
||||
|
||||
# Set the ACT LED to heartbeat
|
||||
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger"
|
||||
|
||||
# Create the target directory if it doesn't exist
|
||||
if [ ! -d "$STORAGE_MOUNT_POINT" ]; then
|
||||
mkdir $STORAGE_MOUNT_POINT
|
||||
fi
|
||||
|
||||
# Wait for camera
|
||||
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//')
|
||||
while [ -z ${DEVICE} ]
|
||||
@@ -19,6 +18,11 @@ while [ -z ${DEVICE} ]
|
||||
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//')
|
||||
done
|
||||
|
||||
# Obtain camera model
|
||||
# Create the target directory with the camera model as its name
|
||||
CAMERA=$(gphoto2 --summary | grep "Model" | cut -d: -f2 | tr -d '[:space:]')
|
||||
STORAGE_MOUNT_POINT="$HOME_DIR/$CAMERA"
|
||||
|
||||
# Set the ACT LED to blink at 500ms to indicate that the camera has been detected
|
||||
sudo sh -c "echo 500 > /sys/class/leds/led0/delay_on"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user