From e37bc58168245df052daf21db9fd9a7f4185fdcf Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Fri, 26 Jan 2018 13:20:17 +0100 Subject: [PATCH] Add inactivity shutdown --- backup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backup.sh b/backup.sh index 92dad90..2430f13 100755 --- a/backup.sh +++ b/backup.sh @@ -13,6 +13,9 @@ CARD_MOUNT_POINT="/media/card" # Set the ACT LED to heartbeat sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" +# Shutdown after 7 minutes if no device is connected. +sudo shutdown -h 7 "Shutdown is activated. To cancel: sudo shutdown -c" + # Wait for a USB storage device (e.g., a USB flash drive) STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) while [ -z ${STORAGE} ] @@ -24,6 +27,9 @@ done # When the USB storage device is detected, mount it mount /dev/$STORAGE_DEV $STORAGE_MOUNT_POINT +# Cancel shutdown +sudo shutdown -c + # Set the ACT LED to blink at 1000ms to indicate that the storage device has been mounted sudo sh -c "echo timer > /sys/class/leds/led0/trigger" sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on"