Add inactivity shutdown

This commit is contained in:
Dmitri Popov
2018-01-26 13:20:17 +01:00
committed by GitHub
parent d759ac4e59
commit e37bc58168

View File

@@ -13,6 +13,9 @@ CARD_MOUNT_POINT="/media/card"
# Set the ACT LED to heartbeat # Set the ACT LED to heartbeat
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" 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) # Wait for a USB storage device (e.g., a USB flash drive)
STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3)
while [ -z ${STORAGE} ] while [ -z ${STORAGE} ]
@@ -24,6 +27,9 @@ done
# When the USB storage device is detected, mount it # When the USB storage device is detected, mount it
mount /dev/$STORAGE_DEV $STORAGE_MOUNT_POINT 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 # 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 timer > /sys/class/leds/led0/trigger"
sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on" sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on"