diff options
-rw-r--r-- | echo | 5 | ||||
-rwxr-xr-x | genefi.sh | 44 | ||||
-rw-r--r-- | grep | 0 |
3 files changed, 39 insertions, 10 deletions
@@ -0,0 +1,5 @@ | |||
1 | BootCurrent: 0000 | ||
2 | Timeout: 1 seconds | ||
3 | BootOrder: 0001,0000 | ||
4 | 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) | ||
5 | 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) | ||
@@ -4,24 +4,48 @@ version () { | |||
4 | } | 4 | } |
5 | 5 | ||
6 | generate () { | 6 | generate () { |
7 | efi_path=/efi/EFI/Linux | 7 | local efi_path=/efi/EFI/Linux |
8 | cd $efi_path | ||
9 | 8 | ||
10 | select efi_file in *; do break; done; | 9 | cd $efi_path |
10 | |||
11 | PS3="Select the efi file: " | ||
12 | select efi_file in *.efi; do break; done; | ||
11 | echo "creating EFI entry for $efi_file" | 13 | echo "creating EFI entry for $efi_file" |
12 | 14 | ||
13 | readarray -d "-" -t file_arr <<< $efi_file | 15 | readarray -d "-" -t file_arr <<< $efi_file |
14 | kernel_version=${file_arr[1]} | 16 | local kernel_version=${file_arr[1]} |
15 | echo "recognized kernel version $kernel_version" | 17 | echo "recognized kernel version $kernel_version" |
16 | 18 | ||
17 | efi_label="gentoo-$kernel_version" | 19 | local efi_label="gentoo-$kernel_version" |
18 | echo "assigned label '$efi_label'" | 20 | echo "assigned label '$efi_label'" |
19 | 21 | ||
20 | doas efibootmgr --create --disk=/dev/nvme0n1 --part=1 --label="$efi_label" --loader="\\EFI\\Linux\\$efi_file" --unicode | 22 | doas efibootmgr --create --disk=/dev/nvme0n1 --part=1 --label="$efi_label" --loader="\\EFI\\Linux\\$efi_file" --unicode >> /dev/null |
21 | } | 23 | } |
22 | 24 | ||
23 | if [[ "$1" = "-v" ]] || [[ "$1" = "-V" ]] || [[ "$1" = "--version" ]]; then | 25 | remove () { |
24 | version "0.2.0" | 26 | readarray -d '\n' -t boot_entries <<< $( efibootmgr --unicode | grep -o -E " gentoo-[0-9]+.[0-9]+.[0-9]+" ) |
25 | else | 27 | PS3="Select the entry to delete: " |
28 | select boot_entry in $boot_entries; do break; done; | ||
29 | local boot_num="$(efibootmgr --unicode | grep "$boot_entry" | grep -o -E "^Boot[0-9]+" | grep -o -E "[0-9]+")" | ||
30 | echo "delete entry $boot_entry (Boot$boot_num)" | ||
31 | doas efibootmgr --unicode -B -b $boot_num >> /dev/null | ||
32 | } | ||
33 | |||
34 | case $1 in | ||
35 | "-v" | "--version" | "-V") | ||
36 | version "0.3.0" | ||
37 | ;; | ||
38 | "generate") | ||
39 | generate | ||
40 | ;; | ||
41 | "remove") | ||
42 | remove | ||
43 | ;; | ||
44 | "") | ||
26 | generate | 45 | generate |
27 | fi | 46 | remove |
47 | ;; | ||
48 | *) | ||
49 | echo unknown argument | ||
50 | ;; | ||
51 | esac | ||