mirror of
https://github.com/Snigdha-OS/snigdhaos-system-config.git
synced 2025-09-21 12:04:57 +02:00
⚡️ perf: add exit status checker
This commit is contained in:
@@ -1,30 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if bootctl is available
|
||||||
|
if ! command -v bootctl &>/dev/null; then
|
||||||
|
echo "Error: bootctl command not found. Unable to determine the current bootloader."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the current bootloader from bootctl status
|
# Get the current bootloader from bootctl status
|
||||||
boot=$(bootctl status | grep -i 'Product' | awk '{printf($2)}')
|
bootloader=$(bootctl status 2>/dev/null | grep -i 'Product' | awk '{print $2}')
|
||||||
|
|
||||||
# Check if the bootloader is GRUB
|
# Provide feedback on the detected bootloader
|
||||||
echo "The system is using $boot to boot."
|
if [[ -z "$bootloader" ]]; then
|
||||||
|
echo "Error: Unable to detect the bootloader using bootctl. Please check the system configuration."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if the bootloader is GRUB and install it if necessary
|
echo "The system is using $bootloader as the bootloader."
|
||||||
if [[ "$boot" == "GRUB" ]]; then
|
|
||||||
|
# Check if the bootloader is GRUB and proceed with installation if necessary
|
||||||
|
if [[ "$bootloader" == "GRUB" ]]; then
|
||||||
echo "GRUB bootloader detected. Installing or reconfiguring GRUB..."
|
echo "GRUB bootloader detected. Installing or reconfiguring GRUB..."
|
||||||
|
|
||||||
# Ensure grub-install exists and is executable
|
# Ensure grub-install exists and is executable
|
||||||
if ! command -v /usr/bin/grub-install &> /dev/null; then
|
if ! command -v grub-install &>/dev/null; then
|
||||||
echo "Error: grub-install command not found. Please install GRUB."
|
echo "Error: grub-install command not found. Please install GRUB."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute the grub-install command
|
# Execute the grub-install command with necessary parameters
|
||||||
sudo /usr/bin/grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=snigdhaos --disable-shim-lock --removable
|
sudo grub-install --target=x86_64-efi \
|
||||||
|
--efi-directory=/boot/efi \
|
||||||
|
--bootloader-id=snigdhaos \
|
||||||
|
--disable-shim-lock \
|
||||||
|
--removable
|
||||||
|
|
||||||
|
# Check the result of the grub-install command
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo "GRUB installation successful."
|
echo "GRUB installation successful."
|
||||||
else
|
else
|
||||||
echo "Error: GRUB installation failed."
|
echo "Error: GRUB installation failed. Please check the logs for more details."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "The system is not using GRUB as the bootloader. No action taken."
|
echo "The system is not using GRUB as the bootloader. No action will be taken."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
Reference in New Issue
Block a user