🧹 chore: upgrade boot loader detection logic

This commit is contained in:
eshanized
2025-01-01 06:36:48 +05:30
parent c2a26f95ea
commit bd4ed5977a

View File

@@ -30,11 +30,7 @@ error() {
# Function to check if a package is installed # Function to check if a package is installed
package_installed() { package_installed() {
if pacman -Qi "$1" &> /dev/null; then pacman -Qi "$1" &> /dev/null
return 0
else
return 1
fi
} }
# Function to handle package installation confirmation # Function to handle package installation confirmation
@@ -56,19 +52,25 @@ post_install() {
warn "If you are using systemd-boot then install the following package..." warn "If you are using systemd-boot then install the following package..."
info "sudo pacman -S snigdhaos-bootloader-systemd" info "sudo pacman -S snigdhaos-bootloader-systemd"
bootloader=$(bootctl status | grep "Product" | awk '{print $2}') local bootloader=$(bootctl status | grep -Eo "(GRUB|systemd-boot)")
if [ "$bootloader" = "systemd-boot" ]; then case "$bootloader" in
info "systemd-bootloader found!" "systemd-boot")
info "Install the following package for your safety!" info "systemd-bootloader found!"
info "sudo pacman -S snigdhaos-bootloader-systemd" info "Install the following package for your safety!"
info "It has all the pacman-hooks which are essentials." info "sudo pacman -S snigdhaos-bootloader-systemd"
elif [ "$bootloader" = "GRUB" ]; then info "It has all the pacman-hooks which are essential."
info "GRUB bootloader found!" ;;
info "Install the following package for your safety!" "GRUB")
info "sudo pacman -S snigdhaos-bootloader-grub" info "GRUB bootloader found!"
info "It has all the pacman-hooks which are essentials." info "Install the following package for your safety!"
fi info "sudo pacman -S snigdhaos-bootloader-grub"
info "It has all the pacman-hooks which are essential."
;;
*)
warn "Unknown bootloader detected!"
;;
esac
confirm_package_installed "snigdhaos-bootloader-grub" confirm_package_installed "snigdhaos-bootloader-grub"
confirm_package_installed "snigdhaos-bootloader-systemd" confirm_package_installed "snigdhaos-bootloader-systemd"
@@ -82,8 +84,8 @@ post_install() {
systemctl disable virtual-machine-check.service systemctl disable virtual-machine-check.service
fi fi
sh /usr/local/bin/snigdhaos-lsb-release bash /usr/local/bin/snigdhaos-lsb-release
sh /usr/local/bin/snigdhaos-os-release bash /usr/local/bin/snigdhaos-os-release
} }
# Function to handle post-upgrade tasks # Function to handle post-upgrade tasks
@@ -93,19 +95,25 @@ post_upgrade() {
warn "If you are using systemd-boot then install the following package..." warn "If you are using systemd-boot then install the following package..."
info "sudo pacman -S snigdhaos-bootloader-systemd" info "sudo pacman -S snigdhaos-bootloader-systemd"
bootloader=$(bootctl status | grep "Product" | awk '{print $2}') local bootloader=$(bootctl status | grep -Eo "(GRUB|systemd-boot)")
if [ "$bootloader" = "systemd-boot" ]; then case "$bootloader" in
info "systemd-bootloader found!" "systemd-boot")
info "Install the following package for your safety!" info "systemd-bootloader found!"
info "sudo pacman -S snigdhaos-bootloader-systemd" info "Install the following package for your safety!"
info "It has all the pacman-hooks which are essentials." info "sudo pacman -S snigdhaos-bootloader-systemd"
elif [ "$bootloader" = "GRUB" ]; then info "It has all the pacman-hooks which are essential."
info "GRUB bootloader found!" ;;
info "Install the following package for your safety!" "GRUB")
info "sudo pacman -S snigdhaos-bootloader-grub" info "GRUB bootloader found!"
info "It has all the pacman-hooks which are essentials." info "Install the following package for your safety!"
fi info "sudo pacman -S snigdhaos-bootloader-grub"
info "It has all the pacman-hooks which are essential."
;;
*)
warn "Unknown bootloader detected!"
;;
esac
confirm_package_installed "snigdhaos-bootloader-grub" confirm_package_installed "snigdhaos-bootloader-grub"
confirm_package_installed "snigdhaos-bootloader-systemd" confirm_package_installed "snigdhaos-bootloader-systemd"
@@ -119,8 +127,8 @@ post_upgrade() {
systemctl disable virtual-machine-check.service systemctl disable virtual-machine-check.service
fi fi
sh /usr/local/bin/snigdhaos-lsb-release bash /usr/local/bin/snigdhaos-lsb-release
sh /usr/local/bin/snigdhaos-os-release bash /usr/local/bin/snigdhaos-os-release
} }
# Function to handle pre-remove tasks # Function to handle pre-remove tasks
@@ -128,4 +136,4 @@ pre_remove() {
if systemctl --all --type service | grep -q "virtual-machine-check"; then if systemctl --all --type service | grep -q "virtual-machine-check"; then
systemctl disable virtual-machine-check.service systemctl disable virtual-machine-check.service
fi fi
} }