From 30d2f304395a2908c50ab215c501d4085428167b Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 21 Aug 2024 17:22:24 +0200 Subject: add removal of entries --- echo | 5 +++++ genefi.sh | 44 ++++++++++++++++++++++++++++++++++---------- grep | 0 3 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 echo create mode 100644 grep diff --git a/echo b/echo new file mode 100644 index 0000000..57db8a9 --- /dev/null +++ b/echo @@ -0,0 +1,5 @@ +BootCurrent: 0000 +Timeout: 1 seconds +BootOrder: 0001,0000 +Boot0000* gentoo-6.6.41 HD(1,GPT,334e6de7-2c83-4e0c-a676-157c989027ee,0x800,0x200000)/File(\EFI\Linux\gentoo-6.6.41-gentoo-dist.efi) +Boot0001* gentoo-6.6.47 HD(1,GPT,334e6de7-2c83-4e0c-a676-157c989027ee,0x800,0x200000)/File(\EFI\Linux\gentoo-6.6.47-gentoo-dist.efi) diff --git a/genefi.sh b/genefi.sh index 5e3ad14..dc3e876 100755 --- a/genefi.sh +++ b/genefi.sh @@ -4,24 +4,48 @@ version () { } generate () { - efi_path=/efi/EFI/Linux - cd $efi_path + local efi_path=/efi/EFI/Linux - select efi_file in *; do break; done; + cd $efi_path + + PS3="Select the efi file: " + select efi_file in *.efi; do break; done; echo "creating EFI entry for $efi_file" readarray -d "-" -t file_arr <<< $efi_file - kernel_version=${file_arr[1]} + local kernel_version=${file_arr[1]} echo "recognized kernel version $kernel_version" - efi_label="gentoo-$kernel_version" + local efi_label="gentoo-$kernel_version" echo "assigned label '$efi_label'" - doas efibootmgr --create --disk=/dev/nvme0n1 --part=1 --label="$efi_label" --loader="\\EFI\\Linux\\$efi_file" --unicode + doas efibootmgr --create --disk=/dev/nvme0n1 --part=1 --label="$efi_label" --loader="\\EFI\\Linux\\$efi_file" --unicode >> /dev/null } -if [[ "$1" = "-v" ]] || [[ "$1" = "-V" ]] || [[ "$1" = "--version" ]]; then - version "0.2.0" -else +remove () { + readarray -d '\n' -t boot_entries <<< $( efibootmgr --unicode | grep -o -E " gentoo-[0-9]+.[0-9]+.[0-9]+" ) + PS3="Select the entry to delete: " + select boot_entry in $boot_entries; do break; done; + local boot_num="$(efibootmgr --unicode | grep "$boot_entry" | grep -o -E "^Boot[0-9]+" | grep -o -E "[0-9]+")" + echo "delete entry $boot_entry (Boot$boot_num)" + doas efibootmgr --unicode -B -b $boot_num >> /dev/null +} + +case $1 in +"-v" | "--version" | "-V") + version "0.3.0" +;; +"generate") + generate +;; +"remove") + remove +;; +"") generate -fi + remove +;; +*) + echo unknown argument +;; +esac diff --git a/grep b/grep new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3