lsgm/live/source/env.sh

70 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2023-09-30 12:46:03 +00:00
function env {
2023-11-22 21:56:22 +00:00
action="${1}"
2023-09-30 12:46:03 +00:00
setparams \
2023-11-22 21:56:22 +00:00
'check_squashfs' \
'live_from' \
'pause' \
'time_out'
2023-09-30 12:46:03 +00:00
if [ "${action}" == 'load' ] ; then
load_env \
2023-11-22 21:56:22 +00:00
--file "${env}" \
2023-09-30 12:46:03 +00:00
--skip-sig \
2023-11-22 21:56:22 +00:00
"${@}"
2023-09-30 12:46:03 +00:00
fi
if [ "${action}" == 'save' ] ; then
save_env \
2023-11-22 21:56:22 +00:00
--file "${env}" \
"${@}"
2023-09-30 12:46:03 +00:00
fi
2023-11-22 21:56:22 +00:00
if [ "${action}" == 'set' ] ; then
load_env \
"${@}"
fi
unset action
2023-09-30 12:46:03 +00:00
}
function env_apply {
if [ "${default}" ] ; then
timeout=${time_out}
else
unset timeout
fi
}
2023-11-23 18:29:33 +00:00
function env_get {
unset get
if [ "${1}" == 'check_squashfs' ] ; then get="${check_squashfs}" ; fi
if [ "${1}" == 'live_from' ] ; then get="${live_from}" ; fi
if [ "${1}" == 'pause' ] ; then get="${pause}" ; fi
if [ "${1}" == 'time_out' ] ; then get="${time_out}" ; fi
2023-11-30 12:34:21 +00:00
if [ ! "${get}" ] ; then false ; fi
2023-11-22 21:56:22 +00:00
}
2023-09-30 12:46:03 +00:00
function env_init {
2023-11-11 15:36:57 +00:00
grub_init
2023-11-30 12:34:21 +00:00
sys_set
2023-11-22 21:56:22 +00:00
env set
2023-09-30 12:46:03 +00:00
env_mod
2023-11-22 21:56:22 +00:00
env load
2023-09-30 12:46:03 +00:00
env_apply
}
function env_list {
list_env \
--skip-sig \
--file "${env}"
}
function env_mod {
2023-10-01 17:59:50 +00:00
env_mod='---'
2023-09-30 12:46:03 +00:00
if [ -f "${env}" ] ; then
2023-10-01 17:59:50 +00:00
env_mod='--x'
2023-09-30 12:46:03 +00:00
if env 'load' ; then
2023-10-01 17:59:50 +00:00
env_mod='r-x'
2023-09-30 12:46:03 +00:00
if env 'save' ; then
2023-10-01 17:59:50 +00:00
env_mod='rwx'
2023-09-30 12:46:03 +00:00
fi
fi
fi
}