Update grub with the new uuids.

This commit is contained in:
Storm Dragon
2025-08-26 17:54:38 -04:00
parent a966772418
commit 368818f63e

View File

@@ -340,6 +340,51 @@ if sudo mount "$TARGET_ROOT_PART" "$TEMP_MOUNT" 2>/dev/null; then
sudo cp "$TEMP_MOUNT/etc/fstab" "$TEMP_MOUNT/etc/fstab.backup" || echo "Warning: Could not backup fstab"
fi
# Also mount and update GRUB config on EFI partition
EFI_MOUNT="/mnt/stormux_efi"
sudo mkdir -p "$EFI_MOUNT"
# Find EFI partition (should be partition 2)
EFI_PART="${TARGET_DEVICE}2"
if [[ "$TARGET_DEVICE" =~ nvme|mmcblk ]]; then
EFI_PART="${TARGET_DEVICE}p2"
fi
if sudo mount "$EFI_PART" "$EFI_MOUNT" 2>/dev/null; then
echo "Updating GRUB configuration with new UUIDs..."
if [[ -f "$EFI_MOUNT/grub/grub.cfg" && ${#uuid_mappings[@]} -gt 0 ]]; then
# Backup original grub config
sudo cp "$EFI_MOUNT/grub/grub.cfg" "$EFI_MOUNT/grub/grub.cfg.backup" || echo "Warning: Could not backup grub.cfg"
# Apply UUID updates to grub config
grub_temp=$(mktemp)
sudo cp "$EFI_MOUNT/grub/grub.cfg" "$grub_temp"
for mapping in "${uuid_mappings[@]}"; do
if [[ "$mapping" =~ ^UUID_MAPPING:([^:]+):([^:]+)$ ]]; then
grub_old_uuid="${BASH_REMATCH[1]}"
grub_new_uuid="${BASH_REMATCH[2]}"
# Replace old UUID with new UUID in grub config
sed -i "s/${grub_old_uuid}/${grub_new_uuid}/g" "$grub_temp"
echo "Updated grub.cfg: $grub_old_uuid -> $grub_new_uuid"
fi
done
# Copy updated grub config back
sudo cp "$grub_temp" "$EFI_MOUNT/grub/grub.cfg"
rm -f "$grub_temp"
echo "GRUB configuration updated successfully"
else
echo "No GRUB config found or no UUID mappings to update"
fi
sudo umount "$EFI_MOUNT"
else
echo "Warning: Could not mount EFI partition $EFI_PART"
fi
sudo rmdir "$EFI_MOUNT"
# Restore speech
echo "command toggletempdisablespeech" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock