summaryrefslogtreecommitdiff
path: root/genefi.sh
blob: 5e3ad14ba374f3e255e3766bcc58f7de41701737 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
version () {
	echo "genefi by fxqnlr v$1"
}

generate () {
	efi_path=/efi/EFI/Linux
	cd $efi_path

	select efi_file in *; do break; done;
	echo "creating EFI entry for $efi_file"

	readarray -d "-" -t file_arr <<< $efi_file
	kernel_version=${file_arr[1]}
	echo "recognized kernel version $kernel_version"

	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
}

if [[ "$1" = "-v" ]] || [[ "$1" = "-V" ]] || [[ "$1" = "--version" ]]; then
	version "0.2.0"
else
	generate
fi