V8.00.000.2025.06.17

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-08-08 09:55:15 +02:00
parent 0657155d20
commit 7e1345c7ec
3 changed files with 60 additions and 24 deletions

View File

@@ -22,7 +22,7 @@ guard_sourcing
#######################################
# Wrapper for executing commands in the desired chroot environment.
# Globals:
# ERR_CHRT_COMMAND
# BASH_SOURCE
# TERM
# Arguments:
# 1: Target of the chroot environment.
@@ -35,6 +35,7 @@ do_in_target() {
declare var_chroot_target="$1"; shift
declare -a ary_chroot_command=("$@")
declare -r var_default_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
declare var_mod="${BASH_SOURCE[1]##*/}"; var_mod="${var_mod%%_*}()"
if (( ${#ary_chroot_command[@]} == 0 )); then
@@ -63,12 +64,12 @@ do_in_target() {
then
do_log "emergency" "file_only" "1080() Command: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none ${ary_chroot_command[*]}] failed."
do_log "emergency" "file_only" "1080() Command of [${var_mod}]: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none ${ary_chroot_command[*]}] failed."
return "${ERR_CHRT_COMMAND}"
else
do_log "info" "file_only" "1080() Command: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none ${ary_chroot_command[*]}] successful."
do_log "info" "file_only" "1080() Command of [${var_mod}]: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none ${ary_chroot_command[*]}] successful."
return 0
fi
@@ -78,9 +79,8 @@ do_in_target() {
# Execute a full shell script line inside the chroot via bash -c.
# TODO: Supports interactive debug shell on error.
# Globals:
# ERR_CHRT_COMMAND
# BASH_SOURCE
# TERM
# DEBUG_INTERACTIVE (optional boolean)
# Arguments:
# 1: Target of the chroot environment
# 2: Command string to execute inside a shell (quoted)
@@ -94,6 +94,7 @@ do_in_target_script() {
declare var_chroot_script="$2"
declare var_log_level_on_error="${3:-emergency}"
declare -r var_default_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
declare var_mod="${BASH_SOURCE[1]##*/}"; var_mod="${var_mod%%_*}()"
if [[ -z "${var_chroot_script}" ]]; then
@@ -114,7 +115,7 @@ do_in_target_script() {
then
do_log "${var_log_level_on_error}" "file_only" "1080() Command: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none /bin/bash -c ${var_chroot_script}] failed."
do_log "${var_log_level_on_error}" "file_only" "1080() Command of [${var_mod}]: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none /bin/bash -c ${var_chroot_script}] failed."
return "${ERR_CHRT_COMMAND}"
# TODO: Test with Dialog Wrapper in interactive mode.
@@ -126,7 +127,7 @@ do_in_target_script() {
else
do_log "info" "file_only" "1080() Command: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none /bin/bash -c ${var_chroot_script}] successful."
do_log "info" "file_only" "1080() Command of [${var_mod}]: [chroot ${var_chroot_target} /usr/bin/env -i HOME=/root PATH=${var_default_path} TERM=${TERM} LANG=C.UTF-8 LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none /bin/bash -c ${var_chroot_script}] successful."
return 0
fi