oem-factory-reset: Fix index used for default boot option

Since we sort the boot options prior to selecting the new default entry,
we need to use the index of the entry in the list prior to being sorted,
vs always setting it as 1. This fixes setting/booting of the default
OS target where the list entries are changed when calling sort.

Test: perform OEM factory reset with Fedora 32 installed, verify
default boot succeeds followng reset.

Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
This commit is contained in:
Matt DeVillier 2020-07-29 00:18:57 -05:00
parent 009c10465a
commit 4c64ca631a
No known key found for this signature in database
GPG Key ID: 2BBB776A35B978FD

View File

@ -221,8 +221,11 @@ set_default_boot_option()
# clear existing default configs
rm "/boot/kexec_default.*.txt" 2>/dev/null
# get correct index for entry
index=$(grep -n "$entry" $option_file | cut -f1 -d ':')
# write new config
echo "$entry" > /boot/kexec_default.1.txt
echo "$entry" > /boot/kexec_default.$index.txt
# validate boot option
cd /boot && /bin/kexec-boot -b "/boot" -e "$entry" -f \