refactor
This commit is contained in:
parent
0dc8e3e6b1
commit
39e1a9b927
15 changed files with 72 additions and 81 deletions
25
live/source/boot.sh
Normal file
25
live/source/boot.sh
Normal 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}"
|
||||
}
|
51
live/source/env.sh
Normal file
51
live/source/env.sh
Normal 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
|
||||
}
|
53
live/source/menu.sh
Normal file
53
live/source/menu.sh
Normal file
|
@ -0,0 +1,53 @@
|
|||
function menu {
|
||||
if [ "${1}" ] ; then
|
||||
menu_load "${1}"
|
||||
else
|
||||
export "${menu}"
|
||||
menu_load "${menu}"
|
||||
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
|
||||
# env_export
|
||||
var_export
|
||||
configfile "${live}/menu/${menu}.sh"
|
||||
}
|
||||
|
||||
function menu_split {
|
||||
if [ "${1}" ] ; then
|
||||
menuentry '' --id "${1}" { nop }
|
||||
else
|
||||
menuentry '' { nop }
|
||||
fi
|
||||
}
|
26
live/source/probe.sh
Normal file
26
live/source/probe.sh
Normal 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
|
||||
}
|
54
live/source/scan.sh
Normal file
54
live/source/scan.sh
Normal file
|
@ -0,0 +1,54 @@
|
|||
function scan {
|
||||
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}" {
|
||||
scan="${2}"
|
||||
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
|
||||
}
|
15
live/source/util.sh
Normal file
15
live/source/util.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
function echo_eval {
|
||||
if [ "${1}" ] ; then
|
||||
echo "${@}"
|
||||
eval "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
function nop {
|
||||
true
|
||||
}
|
||||
|
||||
function pause {
|
||||
echo -n 'Press Enter: '
|
||||
read
|
||||
}
|
6
live/source/var.sh
Normal file
6
live/source/var.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
function var_export {
|
||||
export \
|
||||
data esp \
|
||||
env env_mod \
|
||||
live
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue