From a90ff2c1f823b36393d0b91a9258f667ce6d14b2 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 6 Oct 2018 21:26:10 +0100 Subject: [PATCH] allows a device in any slot to work --- install-little-backup-box.sh | 2 +- scripts/card-backup.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/install-little-backup-box.sh b/install-little-backup-box.sh index 1494f4b..a345e77 100755 --- a/install-little-backup-box.sh +++ b/install-little-backup-box.sh @@ -26,7 +26,7 @@ sudo chmod -R 775 /media/storage sudo setfacl -Rdm g:pi:rw /media/storage cd -git clone https://github.com/dmpop/little-backup-box.git +git clone https://github.com/skidave/little-backup-box.git cd little-backup-box/fonts sudo cp -R . /home/pi/.fonts cd diff --git a/scripts/card-backup.sh b/scripts/card-backup.sh index 118e799..d11c0af 100755 --- a/scripts/card-backup.sh +++ b/scripts/card-backup.sh @@ -21,7 +21,7 @@ # and other settings STORAGE_DEV="sda1" # Name of the storage device STORAGE_MOUNT_POINT="/media/storage" # Mount point of the storage device -CARD_DEV="sdb1" # Name of the storage card +CARD_DEV="sd[b-z]1" # Name 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 @@ -50,16 +50,17 @@ 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 -CARD_READER=$(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3) -until [ ! -z "$CARD_READER" ] +# takes first device found +CARD_READER=($(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3)) +until [ ! -z "${CARD_READER[0]}" ] do sleep 1 CARD_READER=$(ls /dev/sd* | grep "$CARD_DEV" | cut -d"/" -f3) done # If the card reader is detected, mount it and obtain its UUID -if [ ! -z "$CARD_READER" ]; then - mount /dev"/$CARD_DEV" "$CARD_MOUNT_POINT" +if [ ! -z "${CARD_READER[0]}" ]; then + mount /dev"/${CARD_READER[0]}" "$CARD_MOUNT_POINT" # # 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" @@ -75,7 +76,7 @@ if [ ! -z "$CARD_READER" ]; then # Set the backup path BACKUP_PATH="$STORAGE_MOUNT_POINT"/"$ID" - + # Perform backup using rsync rsync -ah --exclude "*.id" "$CARD_MOUNT_POINT"/ "$BACKUP_PATH"