Browse Source

Retry searching for block devices 20 times before failing (#151)

mention-security-issues
Mayank Chhabra 4 years ago
committed by GitHub
parent
commit
98857949b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      scripts/umbrel-os/external-storage/mount

25
scripts/umbrel-os/external-storage/mount

@ -109,14 +109,27 @@ main () {
check_root check_root
check_dependencies sed wipefs parted mount sync umount check_dependencies sed wipefs parted mount sync umount
block_devices=$(list_block_devices)
no_of_block_devices=$(list_block_devices | wc -l) no_of_block_devices=$(list_block_devices | wc -l)
if [[ $no_of_block_devices -lt 1 ]]; then retry_for_block_devices=1
while [[ $no_of_block_devices -lt 1 ]]; do
echo "No block devices found" echo "No block devices found"
echo "Exiting mount script without doing anything" echo "Waiting for 5 seconds before checking again..."
exit 1
fi sleep 5
no_of_block_devices=$(list_block_devices | wc -l)
retry_for_block_devices=$(( $retry_for_block_devices + 1 ))
if [[ $retry_for_block_devices -gt 20 ]]; then
echo "No block devices found in 20 tries..."
echo "Exiting mount script without doing anything"
exit 1
fi
done
if [[ $no_of_block_devices -gt 1 ]]; then if [[ $no_of_block_devices -gt 1 ]]; then
echo "Multiple block devices found, only one drive is supported" echo "Multiple block devices found, only one drive is supported"
@ -125,7 +138,7 @@ main () {
fi fi
# At this point we know there is only one block device attached # At this point we know there is only one block device attached
block_device=$block_devices block_device=$(list_block_devices)
partition_path="/dev/${block_device}1" partition_path="/dev/${block_device}1"
block_device_model=$(get_block_device_model $block_device) block_device_model=$(get_block_device_model $block_device)
echo "Found device \"${block_device_model}\"" echo "Found device \"${block_device_model}\""

Loading…
Cancel
Save