'scripts/card-backup.sh' updaten

This commit is contained in:
2019-06-01 12:43:46 +00:00
parent a19cc7fb7c
commit 83246f127c

View File

@@ -19,15 +19,12 @@
# Specify devices and their their mount points # Specify devices and their their mount points
# as well as other settings # as well as other settings
STORAGE_DEV="sda1" # Name of the storage device
STORAGE_MOUNT_POINT="/media/storage" # Mount point of the storage device STORAGE_MOUNT_POINT="/mnt/SMB" # Mount point of the storage device
CARD_DEV="sdb1" # Name of the storage card CARD_DEV="sdb1" # Name of the storage card
CARD_MOUNT_POINT="/media/card" # Mount point of the storage card CARD_MOUNT_POINT="/media/card" # Mount point of the storage card
SHUTD="5" # Minutes to wait before shutdown due to inactivity 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. # 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" sudo shutdown -h $SHUTD "Shutdown is activated. To cancel: sudo shutdown -c"
@@ -41,15 +38,10 @@ while [ -z "${STORAGE}" ]
done 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"
# Cancel shutdown # Cancel shutdown
sudo shutdown -c 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"
# Wait for a card reader or a camera # Wait for a card reader or a camera
# takes first device found # takes first device found
CARD_READER=($(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3)) CARD_READER=($(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3))
@@ -64,8 +56,6 @@ if [ ! -z "${CARD_READER[0]}" ]; then
mount /dev"/${CARD_READER[0]}" "$CARD_MOUNT_POINT" mount /dev"/${CARD_READER[0]}" "$CARD_MOUNT_POINT"
CARD_COUNT=$(find $CARD_MOUNT_POINT/ -type f | wc -l) CARD_COUNT=$(find $CARD_MOUNT_POINT/ -type f | wc -l)
# # Set the ACT LED to blink at 500ms to indicate that the card has been mounted
sudo sh -c "echo 500 > /sys/class/leds/led0/delay_on"
# Create a .id random identifier file if doesn't exist # Create a .id random identifier file if doesn't exist
cd "$CARD_MOUNT_POINT" cd "$CARD_MOUNT_POINT"
@@ -90,21 +80,11 @@ if [ ! -z "${CARD_READER[0]}" ]; then
PERCENT=$(expr 100 \* $STORAGE_COUNT / $CARD_COUNT) PERCENT=$(expr 100 \* $STORAGE_COUNT / $CARD_COUNT)
sudo sh -c "echo $PERCENT" sudo sh -c "echo $PERCENT"
#IF STATEMENTS HERE FOR LEDS #IF STATEMENTS HERE FOR LEDS
if [ $PERCENT -gt 25 ] && [ $PERCENT -lt 49 ]; then
sudo sh -c "echo 300 > /sys/class/leds/led0/delay_on"
elif [ $PERCENT -gt 50 ] && [ $PERCENT -lt 74 ]; then
sudo sh -c "echo 200 > /sys/class/leds/led0/delay_on"
elif [ $PERCENT -gt 75 ] && [ $PERCENT -lt 100 ]; then
sudo sh -c "echo 100 > /sys/class/leds/led0/delay_on"
fi
# then # then
#LEDS #LEDS
#fi #fi
sleep 1 sleep 1
done done
sudo sh -c "echo 1 > /sys/class/leds/led0/brightness"
# Turn off the POWER LED to indicate that the backup is completed
sudo sh -c "echo 0 > /sys/class/leds/led1/brightness"
fi fi
# Shutdown # Shutdown