Add a boot menu item for resetting SOI user

This commit is contained in:
Jan Schär 2024-06-22 12:01:46 +02:00
parent 697bbc3618
commit ecdc506a1a
6 changed files with 80 additions and 8 deletions

View file

@ -0,0 +1,40 @@
#!/bin/sh
set -e
. "$pkgdatadir/grub-mkconfig_lib"
list=
for i in /boot/vmlinuz-* ; do
if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
done
linux="$(version_find_latest $list)"
basename="$(basename $linux)"
rel_dirname="$(make_system_path_relative_to_its_root /boot)"
version="$(echo $basename | sed -e "s,^[^0-9]*-,,g")"
prepare_boot="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab | grub_add_tab)"
LINUX_ROOT_DEVICE="UUID=${GRUB_DEVICE_UUID}"
linux_entry ()
{
title="$1"
args="$2"
echo " menuentry '$(echo "$title" | grub_quote)' {"
echo " load_video"
echo " insmod gzio"
echo "$prepare_boot"
echo " echo '$(echo "Loading Linux ${version} ..." | grub_quote)'"
echo " linux ${rel_dirname}/${basename} root=${LINUX_ROOT_DEVICE} ro ${args}"
echo " echo 'Loading initial ramdisk ...'"
echo " initrd ${rel_dirname}/initrd.img-${version}"
echo " }"
}
echo "submenu 'Reset SOI user...' {"
echo " menuentry 'Cancel' {"
echo " configfile \$prefix/grub.cfg"
echo " }"
linux_entry "Reset SOI user (THIS DELETES USER DATA)" "reset-user"
linux_entry "Reset SOI user (THIS DELETES USER DATA) and power off" "reset-user reset-user-poweroff"
echo "}"