This commit is contained in:
Marc Beninca 2023-09-30 14:46:03 +02:00
parent 08972d3817
commit 0dc8e3e6b1
23 changed files with 1607 additions and 0 deletions

51
live/env.sh Normal file
View file

@ -0,0 +1,51 @@
function env {
action="${1}"
setparams \
'time_out'
if [ "${action}" == 'load' ] ; then
load_env \
--skip-sig \
--file "${env}" "${@}"
fi
if [ "${action}" == 'save' ] ; then
save_env \
--file "${env}" "${@}"
fi
}
function env_apply {
if [ "${default}" ] ; then
timeout=${time_out}
else
unset timeout
fi
}
function env_init {
env_set
env_mod
env_apply
}
function env_list {
list_env \
--skip-sig \
--file "${env}"
}
function env_mod {
env_mod='?'
if [ -f "${env}" ] ; then
env_mod='-'
if env 'load' ; then
env_mod='r'
if env 'save' ; then
env_mod='w'
fi
fi
fi
}
function env_set {
time_out=10
}

25
live/main.sh Normal file
View file

@ -0,0 +1,25 @@
function debsquash {
boot_toram='true'
lmp="${1}"
sfs="filesystem.squashfs"
if [ -f "(${data})${lmp}/vmlinuz" ]; then
linux_path="(${data})${lmp}/vmlinuz"
initrd_path="(${data})${lmp}/initrd.img"
else
linux_path="(squash)/vmlinuz"
initrd_path="(squash)/initrd.img"
loopback "squash" "${lmp}/${sfs}"
fi
boot_linux="linux \
\"${linux_path}\" \
boot=\"live\" \
elevator=\"deadline\" \
ip=\"frommedia\" \
live-media-path=\"${lmp}\" \
toram"
if [ "${boot_toram}" == "true" ]; then
boot_linux="${boot_linux}=\"${sfs}\""
fi
echo_eval "${boot_linux}"
initrd "${initrd_path}"
}

48
live/menu.sh Normal file
View file

@ -0,0 +1,48 @@
function menu {
if [ "${1}" ] ; then
menu_load "${1}" "${menus}/${1}.sh"
else
menu_load 'main' "${menus}/main.sh"
fi
}
function menu_color {
menu_item \
'black' 'blue' 'green' 'cyan' \
'red' 'magenta' 'brown' 'light-gray' \
'dark-gray' 'light-blue' 'light-green' 'light-cyan' \
'light-red' 'light-magenta' 'yellow' 'white'
}
function menu_init {
if [ "${1}" ] ; then
menuentry "${menu}${1}" { nop }
else
menuentry "${menu}" { nop }
fi
menu_split
default=2
}
function menu_item {
eval "default=\"id_\${${menu}}\""
for item in "${@}" ; do
menuentry "${item}" "${menu}" --id "id_${item}" {
eval "${2}=\"${1}\""
menu
}
done
unset item
}
function menu_load {
menu="${1}"
export menu nav
# env_export
var_export
configfile "${2}"
}
function menu_split {
menuentry '' { nop }
}

11
live/menu/cmd.sh Normal file
View file

@ -0,0 +1,11 @@
menu_init
menuentry 'halt' { halt }
menuentry 'reboot' { reboot }
menuentry 'reload' { menu }
menuentry 'exit normal' { normal_exit }
menuentry 'exit grub' { exit }

17
live/menu/env.sh Normal file
View file

@ -0,0 +1,17 @@
menu_init
menuentry 'list file' {
env_list
pause
}
menuentry 'list variables' {
set
pause
}
menuentry 'reset defaults' {
env_set
env save
env_apply
}

6
live/menu/gfx.sh Normal file
View file

@ -0,0 +1,6 @@
menu_init
menuentry 'list' {
videoinfo
pause
}

13
live/menu/main.sh Normal file
View file

@ -0,0 +1,13 @@
menuentry 'nav →' { menu 'nav' }
menu_split
menuentry 'data / boot / bash / latest / gui' { debsquash '/boot/bash/latest/gui' }
menuentry 'data / boot / bash / latest / tui' { debsquash '/boot/bash/latest/tui' }
menuentry 'data / boot / bash / stable / gui' { debsquash '/boot/bash/stable/gui' }
menuentry 'data / boot / bash / stable / tui' { debsquash '/boot/bash/stable/tui' }
menu_split
menuentry "cmd → ${cmdpath}${grub_cpu}-${grub_platform}" { menu 'cmd' }
menuentry "env → ${env}${env_mod}" { menu 'env' }
menuentry 'gfx → ?' { menu 'gfx' }
menuentry 'ovl → ?' { nop }
menu_split
scan

3
live/menu/nav.sh Normal file
View file

@ -0,0 +1,3 @@
menu_init "${nav}"
nav "${nav}"

54
live/nav.sh Normal file
View file

@ -0,0 +1,54 @@
function nav {
if [ "${1}" ] ; then
paths="${1}/*"
else
regexp --set default '(\(.*\))' "${cmdpath}"
paths='(*)'
fi
for path in ${paths} ; do
if [ "${1}" ] ; then
regexp --set tmp '.*/(.*)' "${path}"
else
if [ "${path}" == "${default}" ] ; then
tmp="${path}"
else
tmp=" ${path}"
fi
probe_set "${path}"
tmp="${tmp}${probe_entry}"
fi
if [ "${tmp}" != '*' ] ; then
if [ -d "${path}" ] ; then
menuentry "${tmp}" "${path}" --id "${path}" {
nav="${2}"
menu "${menu}"
}
else
menuentry "${tmp}" {
nop
}
fi
fi
if [ ! "${1}" ] ; then
if [ "${probe_fs}" == 'fat' ] ; then
if [ -f "${path}/efi/boot/bootx64.efi" ] ; then
menuentry ' efi/boot/bootx64.efi →' "${path}" {
chainloader "${2}/efi/boot/bootx64.efi"
}
fi
elif [ "${probe_fs}" ] ; then
if [ -d "${path}/boot/bash" ] ; then
for x in ${path}/boot/bash/* ; do
if [ -f "${x}/gui/filesystem.squashfs" ] ; then
regexp --set y '\(.*\)/(.*)' "${x}/gui"
menuentry " ${y}" {
nop
}
fi
done
fi
fi
probe_unset
fi
done
}

26
live/probe.sh Normal file
View file

@ -0,0 +1,26 @@
function probe_set {
probe_unset
if [ "${1}" ] ; then
probe "${1}" --set probe_fs --fs
probe "${1}" --set probe_fs_uuid --fs-uuid
probe "${1}" --set probe_label --label
probe "${1}" --set probe_part_uuid --part-uuid
fi
if [ "${probe_label}" ] ; then
probe_entry="${probe_entry}${probe_label}"
fi
if [ "${probe_fs}" ] ; then
probe_entry="${probe_entry}${probe_fs}"
fi
if [ "${probe_fs_uuid}" ] ; then
probe_entry="${probe_entry}${probe_fs_uuid}"
fi
}
function probe_unset {
unset probe_entry
unset probe_fs
unset probe_fs_uuid
unset probe_label
unset probe_part_uuid
}

3
live/scan.sh Normal file
View file

@ -0,0 +1,3 @@
function scan {
menuentry 'scan' { nop }
}

15
live/util.sh Normal file
View file

@ -0,0 +1,15 @@
function echo_eval {
if [ "${1}" ] ; then
echo "${@}"
eval "${@}"
fi
}
function nop {
true
}
function pause {
echo -n 'Press Enter: '
read
}

26
live/var.sh Normal file
View file

@ -0,0 +1,26 @@
function var_echo {
echo "check_signatures: ${check_signatures} | pager: ${pager}"
echo "prefix: ${prefix} | root: ${root}"
echo
echo "data: ${data} | esp: ${esp}"
echo "env: ${env} | env_mod: ${env_mod}"
echo "live: ${live} | menus: ${menus}"
}
function var_export {
export \
data esp \
env env_mod \
live menus
}
function var_menu {
menuentry "check_signatures: ${check_signatures} | pager: ${pager}" {
nop
}
menuentry "prefix: ${prefix} | root: ${root}" { nop }
menu_split
menuentry "data: ${data} | esp: ${esp}" { nop }
menuentry "env: ${env} | env_mod: ${env_mod}" { nop }
menuentry "live: ${live} | menus: ${menus}" { nop }
}