Fix UUID extraction to handle commented fstab lines
Modified grep logic to extract UUIDs even if the fstab lines are already commented out from a previous run. Uses sed to strip comment prefixes before extracting UUIDs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -50,10 +50,10 @@ umount /media/usb1 2>/dev/null || true
|
|||||||
echo -e "${GREEN}✓ Unmounted drives${NC}"
|
echo -e "${GREEN}✓ Unmounted drives${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Step 3: Extract UUIDs from fstab
|
# Step 3: Extract UUIDs from fstab (including commented lines)
|
||||||
echo "Step 3: Reading UUIDs from /etc/fstab..."
|
echo "Step 3: Reading UUIDs from /etc/fstab..."
|
||||||
USB0_UUID=$(grep "usb0" /etc/fstab 2>/dev/null | grep -v "^#" | grep -oP 'UUID=\K[^\s]+' || echo "")
|
USB0_UUID=$(grep "usb0" /etc/fstab 2>/dev/null | sed 's/^#[^ ]* //' | grep -oP 'UUID=\K[^\s]+' || echo "")
|
||||||
USB1_UUID=$(grep "usb1" /etc/fstab 2>/dev/null | grep -v "^#" | grep -oP 'UUID=\K[^\s]+' || echo "")
|
USB1_UUID=$(grep "usb1" /etc/fstab 2>/dev/null | sed 's/^#[^ ]* //' | grep -oP 'UUID=\K[^\s]+' || echo "")
|
||||||
|
|
||||||
if [ -z "$USB0_UUID" ] && [ -z "$USB1_UUID" ]; then
|
if [ -z "$USB0_UUID" ] && [ -z "$USB1_UUID" ]; then
|
||||||
echo -e "${YELLOW}⚠ No UUIDs found in fstab${NC}"
|
echo -e "${YELLOW}⚠ No UUIDs found in fstab${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user