diff --git a/README.md b/README.md index 3a8edf6..9468c90 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ When prompted, reboot the Raspberry Pi. By default, Little Backup Box is configured to back up storage cards. To make the script transfer files directly from the connected camera, run the `crontab -e` command on Raspberry Pi. Comment the following line by prepending *#* to it: - @reboot sudo /home/pi/little-backup-box/backup.sh > /home/pi/little-backup-box.log + @reboot sudo /home/pi/little-backup-box/backup.sh Uncomment then the line below by removing *#*: - #@reboot sudo /home/pi/little-backup-box/gphoto-backup.sh > /home/pi/gphoto-backup.log + #@reboot sudo /home/pi/little-backup-box/gphoto-backup.sh Save the changes. diff --git a/gphoto-backup.sh b/gphoto-backup.sh index 84857b3..30040e3 100755 --- a/gphoto-backup.sh +++ b/gphoto-backup.sh @@ -5,11 +5,15 @@ # to install the required packages and configure the system. # Specify a storage device and its mount point -HOME_DIR="/home/pi" +HOME_DIR="/home/pi" # Home directory path +SHUTD="5" # Minutes to wait before shutdown due to inactivity # Set the ACT LED to heartbeat sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" +# Shutdown after a specified period of time (in minutes) if no device is connected. +sudo shutdown -h $SHUTD "Shutdown is activated. To cancel: sudo shutdown -c" + # Wait for camera DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//') while [ -z ${DEVICE} ] @@ -18,6 +22,9 @@ while [ -z ${DEVICE} ] DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//') done +# Cancel shutdown +sudo shutdown -c + # 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:]')