soios/os/layers/training-installer/includes.chroot/etc/grub.d/15_reset_user

41 lines
1.2 KiB
Bash
Executable File

#!/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 "}"