diff --git a/scripts/camera-backup.sh b/scripts/camera-backup.sh index 6c43d2d..67eba7c 100755 --- a/scripts/camera-backup.sh +++ b/scripts/camera-backup.sh @@ -29,7 +29,7 @@ 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} ] +while [ -z "${DEVICE}" ] do sleep 1 DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,/\//') diff --git a/scripts/card-backup.sh b/scripts/card-backup.sh index 36a8d72..118e799 100755 --- a/scripts/card-backup.sh +++ b/scripts/card-backup.sh @@ -32,15 +32,15 @@ sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" sudo shutdown -h $SHUTD "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} ] +STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) +while [ -z "${STORAGE}" ] do sleep 1 - STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) + STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) done # 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 @@ -50,16 +50,16 @@ 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) +CARD_READER=$(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3) until [ ! -z "$CARD_READER" ] do sleep 1 - CARD_READER=$(ls /dev/sd* | grep $CARD_DEV | cut -d"/" -f3) + 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 + mount /dev"/$CARD_DEV" "$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" @@ -74,7 +74,7 @@ if [ ! -z "$CARD_READER" ]; then cd # Set the backup path - BACKUP_PATH=$STORAGE_MOUNT_POINT/"$ID" + BACKUP_PATH="$STORAGE_MOUNT_POINT"/"$ID" # Perform backup using rsync rsync -ah --exclude "*.id" "$CARD_MOUNT_POINT"/ "$BACKUP_PATH" diff --git a/scripts/device-backup.sh b/scripts/device-backup.sh index 1484aeb..093a41f 100755 --- a/scripts/device-backup.sh +++ b/scripts/device-backup.sh @@ -31,15 +31,15 @@ sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" sudo shutdown -h $SHUTD "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) +STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) while [ -z ${STORAGE} ] do sleep 1 - STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) + STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) done # 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 @@ -49,7 +49,7 @@ sudo sh -c "echo timer > /sys/class/leds/led0/trigger" sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on" # Perform backup using rsync -rsync -av $SOURCE_DIR $STORAGE_MOUNT_POINT +rsync -av "$SOURCE_DIR" "$STORAGE_MOUNT_POINT" # Turn off the ACT LED to indicate that the backup is completed sudo sh -c "echo 0 > /sys/class/leds/led0/brightness" diff --git a/scripts/remote-backup.sh b/scripts/remote-backup.sh index bd0d928..304cc39 100755 --- a/scripts/remote-backup.sh +++ b/scripts/remote-backup.sh @@ -54,11 +54,11 @@ sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger" sudo shutdown -h $SHUTD "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) +STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) while [ -z ${STORAGE} ] do sleep 1 - STORAGE=$(ls /dev/* | grep $STORAGE_DEV | cut -d"/" -f3) + STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) done # When the USB storage device is detected, mount it @@ -72,7 +72,7 @@ sudo sh -c "echo timer > /sys/class/leds/led0/trigger" sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on" # Perform backup using rsync -rsync -avhz -e ssh --delete --progress "$STORAGE_MOUNT_POINT" "$USER"@"$REMOTE":"$BACKUP_DIR" +rsync -avhz -e ssh --delete --progress "$STORAGE_MOUNT_POINT"/ "$USER"@"$REMOTE":"$BACKUP_DIR" if [ ! -z "$NOTIFY_TOKEN" ]; then TEXT=$(sed 's/ /%20/g' <<< "Remote backup completed.")