Add shutdown timeout. Update README.md

This commit is contained in:
Dmitri Popov
2018-03-20 09:15:13 +01:00
parent 9e5026c4d7
commit 2b46f43e59
2 changed files with 10 additions and 3 deletions

View File

@@ -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.

View File

@@ -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:]')