added hooks
This commit is contained in:
parent
58193b66dd
commit
9f9369bff0
3 changed files with 42 additions and 0 deletions
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Grub reinstallation hook for pacman
|
||||
|
||||
This hook would re-install and re-configiure grub after any changes on Grub package in Arch Linux repository, such as **upgrade** or **reinstallation**
|
||||
|
||||
|
||||
|
||||
|
||||
Parch Linux [website](https://parchlinux.com)
|
9
hooks/90-grub-disk-type.hook
Normal file
9
hooks/90-grub-disk-type.hook
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Trigger]
|
||||
Operation = Upgrade
|
||||
Operation = Install
|
||||
Type = Package
|
||||
Target = grub
|
||||
[Action]
|
||||
Description = Reinstall and remake GRUB configuration
|
||||
When = PostTransaction
|
||||
Exec = /bin/bash -c '/etc/pacman.d/hooks/90-grub-disk-type.sh'
|
25
hooks/90-grub-disk-type.sh
Executable file
25
hooks/90-grub-disk-type.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if the system is running in UEFI mode
|
||||
if [[ -d "/sys/firmware/efi" ]]; then
|
||||
# UEFI mode detected
|
||||
echo "UEFI system detected. Reinstalling GRUB for UEFI..."
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
|
||||
else
|
||||
# Legacy (BIOS) mode detected
|
||||
echo "Legacy (BIOS) system detected. Reinstalling GRUB for BIOS..."
|
||||
|
||||
# Find the primary disk for MBR installations
|
||||
primary_disk=$(lsblk -o NAME,SIZE,MOUNTPOINT -nl | awk '$3=="/" {print $1}' | sed 's/[0-9]//g')
|
||||
|
||||
if [[ -n "$primary_disk" ]]; then
|
||||
grub-install --target=i386-pc --recheck "/dev/$primary_disk"
|
||||
else
|
||||
echo "Error: Unable to determine primary disk. Check your configuration."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generate GRUB configuration
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
Loading…
Add table
Reference in a new issue