summaryrefslogtreecommitdiff
path: root/genefi.sh
diff options
context:
space:
mode:
Diffstat (limited to 'genefi.sh')
-rwxr-xr-xgenefi.sh44
1 files changed, 34 insertions, 10 deletions
diff --git a/genefi.sh b/genefi.sh
index 5e3ad14..dc3e876 100755
--- a/genefi.sh
+++ b/genefi.sh
@@ -4,24 +4,48 @@ version () {
4} 4}
5 5
6generate () { 6generate () {
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
23if [[ "$1" = "-v" ]] || [[ "$1" = "-V" ]] || [[ "$1" = "--version" ]]; then 25remove () {
24 version "0.2.0" 26 readarray -d '\n' -t boot_entries <<< $( efibootmgr --unicode | grep -o -E " gentoo-[0-9]+.[0-9]+.[0-9]+" )
25else 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
34case $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
27fi 46 remove
47;;
48*)
49 echo unknown argument
50;;
51esac