diff --git a/rpi/flash-image.sh b/rpi/flash-image.sh index 1dffea4..2c3eb9c 100755 --- a/rpi/flash-image.sh +++ b/rpi/flash-image.sh @@ -249,16 +249,9 @@ if [ -n "$MOUNTED" ]; then done fi -# Ask about wiping +# Ask about wiping (defer actual wipe until after final confirmation) echo read -p "Wipe partition table first? (recommended if having issues) [y/N] " wipe_confirm -if [[ "$wipe_confirm" =~ ^[Yy]$ ]]; then - echo "Wiping partition table..." - sudo wipefs -a "$SELECTED" - sudo dd if=/dev/zero of="$SELECTED" bs=1M count=10 status=none - sync - echo " Wiped clean" -fi # Final confirmation echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}" @@ -272,6 +265,15 @@ if [[ ! $REPLY == "yes" ]]; then exit 1 fi +# Now wipe if requested +if [[ "$wipe_confirm" =~ ^[Yy]$ ]]; then + echo "Wiping partition table..." + sudo wipefs -a "$SELECTED" + sudo dd if=/dev/zero of="$SELECTED" bs=1M count=10 status=none + sync + echo " Wiped clean" +fi + echo "" echo -e "${GREEN}Flashing image to $SELECTED...${NC}" echo ""