lsgm/grub.cfg.sh

148 lines
3 KiB
Bash
Raw Normal View History

2023-11-10 19:09:15 +00:00
function grub_fix {
unset cmdroot
regexp --set cmdroot '^\((.*)\)' "${cmdpath}"
if [ "${cmdroot}" != "${root}" ] ; then
echo -n "\
|*${cmdpath}
"
if [ -d "(${cmdroot})/boot/grub/${grub_cpu}-${grub_platform}" ] ; then
prefix="(${cmdroot})/boot/grub"
root="${cmdroot}"
fi
fi
unset cmdroot
check_signatures='enforce'
trust --skip-sig "${prefix}/grub.pgp"
}
2023-11-11 15:36:57 +00:00
function grub_init {
load_env \
'live_name' 'data_uuid'
#
regexp --set esp '^\((.*)\)' "${prefix}"
#
env="(${esp})/grub.env"
load_env \
--skip-sig \
--file "${env}" \
2023-11-22 21:56:22 +00:00
'pause'
2023-11-11 15:36:57 +00:00
#
2023-11-15 11:04:59 +00:00
live="(${esp})/boot/${live_name}"
2023-11-11 15:36:57 +00:00
#
search --no-floppy --set data \
--fs-uuid "${data_uuid}"
}
2023-11-10 19:09:15 +00:00
function grub_list_const {
2023-11-24 05:32:00 +00:00
target="${1}"
setparams \
" cpu-platform | ${grub_cpu}-${grub_platform}" \
" cmdpath | ${cmdpath}"
for entry in "${@}" ; do
if [ "${target}" == 'menu' ] ; then
menuentry "${entry}" { nop }
else
echo "${entry}"
fi
done
unset entry
unset target
2023-11-10 19:09:15 +00:00
}
function grub_list_info {
if [ -f '/.disk/info' -o -f '/.disk/mini-info' ] ; then
for f in '/.disk/info' '/.disk/mini-info' ; do
echo -n "\
|"
if [ -f "${f}" ] ; then
echo -n '*'
else
echo -n ' '
fi
echo "(${root})${f}"
done
unset f
fi
}
function grub_list_vars {
2023-11-24 05:32:00 +00:00
target="${1}"
setparams \
" root | ${root}" \
" prefix | ${prefix}" \
"check_signatures | ${check_signatures}"
for entry in "${@}" ; do
if [ "${target}" == 'menu' ] ; then
menuentry "${entry}" { nop }
else
echo "${entry}"
fi
done
unset entry
unset target
2023-11-10 19:09:15 +00:00
list_trusted
}
function grub_list_xtra {
2023-11-24 05:32:00 +00:00
target="${1}"
setparams \
" env | ${env}" \
" live | ${live}" \
" data | ${data}"
for entry in "${@}" ; do
if [ "${target}" == 'menu' ] ; then
menuentry "${entry}" { nop }
else
echo "${entry}"
fi
done
unset entry
unset target
2023-11-10 19:09:15 +00:00
}
function grub_main {
2023-11-14 12:51:37 +00:00
echo '---'
2023-11-10 19:09:15 +00:00
ls
grub_list_const
grub_split
if [ ! "${data}" ] ; then
grub_list_info
grub_list_vars
grub_split
#
grub_fix
2023-11-11 15:36:57 +00:00
grub_init
2023-11-10 19:09:15 +00:00
for file in ${live}/source/*.sh ; do
source "${file}"
done
unset file
2023-11-30 12:34:21 +00:00
source "${live}/menu/main.sh"
2023-11-10 19:09:15 +00:00
fi
grub_list_vars
grub_list_xtra
grub_split
grub_pause
}
function grub_pause {
echo -n "\
escape | "
2023-11-11 15:36:57 +00:00
sleep \
--interruptible \
--verbose \
2023-11-22 21:56:22 +00:00
"${pause}"
2023-11-10 19:09:15 +00:00
}
function grub_split {
2023-11-24 05:32:00 +00:00
target="${1}"
setparams \
' ---'
if [ "${target}" == 'menu' ] ; then
menuentry "${1}" { nop }
else
echo "${1}"
fi
2023-11-10 19:09:15 +00:00
}
grub_main