V8.13.392.2025.11.07
Some checks failed
🛡️ Retrieve DNSSEC status of coresecret.dev. / 🛡️ Retrieve DNSSEC status of coresecret.dev. (push) Successful in 1m5s
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m15s
🔐 Generating a Private Live ISO TRIXIE. / 🔐 Generating a Private Live ISO TRIXIE. (push) Failing after 1m23s
Some checks failed
🛡️ Retrieve DNSSEC status of coresecret.dev. / 🛡️ Retrieve DNSSEC status of coresecret.dev. (push) Successful in 1m5s
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m15s
🔐 Generating a Private Live ISO TRIXIE. / 🔐 Generating a Private Live ISO TRIXIE. (push) Failing after 1m23s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -10,33 +10,60 @@
|
||||
# SPDX-PackageName: CISS.debian.live.builder
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
guard_sourcing
|
||||
guard_sourcing || return "${ERR_GUARD_SRCE}"
|
||||
|
||||
#######################################
|
||||
# Trap function to be called on 'EXIT'.
|
||||
# Globals:
|
||||
# ERRCMMD
|
||||
# ERRCODE
|
||||
# ERRFUNC
|
||||
# ERRLINE
|
||||
# ERRSCRT
|
||||
# ERRTRAP
|
||||
# VAR_EARLY_DEBUG
|
||||
# Arguments:
|
||||
# 1: $?
|
||||
# 2: ${BASH_SOURCE[0]}
|
||||
# 3: ${LINENO}
|
||||
# 4: ${FUNCNAME[0]:-main}
|
||||
# 5: ${BASH_COMMAND}
|
||||
#######################################
|
||||
trap_on_exit() {
|
||||
declare errcode="${ERRCODE:-$1}"
|
||||
declare errscrt="${ERRSCRT:-$2}"
|
||||
declare errline="${ERRLINE:-$3}"
|
||||
declare errfunc="${ERRFUNC:-$4}"
|
||||
declare errcmmd="${ERRCMMD:-$5}"
|
||||
|
||||
trap - DEBUG ERR EXIT INT TERM
|
||||
|
||||
declare -r var_trap_on_exit_code="$1"
|
||||
### Defensive shell behavior inside trap.
|
||||
set +e +o pipefail
|
||||
|
||||
if (( var_trap_on_exit_code == 0 )); then
|
||||
if (( errcode == 0 )); then
|
||||
|
||||
if "${VAR_EARLY_DEBUG}"; then dump_user_vars; fi
|
||||
|
||||
clean_up "${var_trap_on_exit_code}"
|
||||
clean_up "${errcode}"
|
||||
|
||||
print_scr_exit "${var_trap_on_exit_code}"
|
||||
print_scr_exit "${errcode}"
|
||||
|
||||
exit "${var_trap_on_exit_code}"
|
||||
exit "${errcode}"
|
||||
|
||||
else
|
||||
|
||||
exit "${var_trap_on_exit_code}"
|
||||
if [[ ! "${ERRTRAP}" == "true" ]]; then
|
||||
|
||||
if "${VAR_EARLY_DEBUG}"; then dump_user_vars; fi
|
||||
|
||||
clean_up "${errcode}"
|
||||
|
||||
print_scr_exit_non_zero "${errcode}" "${errscrt}" "${errline}" "${errfunc}" "${errcmmd}"
|
||||
|
||||
fi
|
||||
|
||||
exit "${errcode}"
|
||||
|
||||
fi
|
||||
}
|
||||
@@ -45,22 +72,22 @@ trap_on_exit() {
|
||||
readonly -f trap_on_exit
|
||||
|
||||
#######################################
|
||||
# Print Success Message for Trap on 'EXIT' on 'stdout'.
|
||||
# Print success message for trap on 'EXIT' on 'stdout'.
|
||||
# Globals:
|
||||
# LOG_DEBUG
|
||||
# LOG_VAR
|
||||
# SECONDS
|
||||
# VAR_BASH_VER
|
||||
# VAR_DS_VER
|
||||
# VAR_EARLY_DEBUG
|
||||
# VAR_GIT_REL
|
||||
# VAR_HANDLER_BUILD_DIR
|
||||
# VAR_LB_VER
|
||||
# VAR_SCRIPT_SUCCESS
|
||||
# VAR_SYSTEM
|
||||
# VAR_VERSION
|
||||
# VAR_VER_BASH
|
||||
# VAR_VER_DS
|
||||
# VAR_VER_LB
|
||||
# Arguments:
|
||||
# 1: ${var_trap_on_exit_code} of trap_on_exit()
|
||||
# 1: ${errcode} of trap_on_exit()
|
||||
#######################################
|
||||
print_scr_exit() {
|
||||
declare -r var_print_scr_exit_code="$1"
|
||||
@@ -74,9 +101,9 @@ print_scr_exit() {
|
||||
printf "\e[92m✅ Git Commit : %s \e[0m\n" "${VAR_GIT_REL}"
|
||||
printf "\e[92m✅ Version : %s \e[0m\n" "${VAR_VERSION}"
|
||||
printf "\e[92m✅ Hostsystem : %s \e[0m\n" "${VAR_SYSTEM}"
|
||||
printf "\e[92m✅ Bash : %s \e[0m\n" "${VAR_BASH_VER}"
|
||||
printf "\e[92m✅ Live-Build : %s \e[0m\n" "${VAR_LB_VER}"
|
||||
printf "\e[92m✅ Debootstrap : %s \e[0m\n" "${VAR_DS_VER}"
|
||||
printf "\e[92m✅ Bash : %s \e[0m\n" "${VAR_VER_BASH}"
|
||||
printf "\e[92m✅ Live-Build : %s \e[0m\n" "${VAR_VER_LB}"
|
||||
printf "\e[92m✅ Debootstrap : %s \e[0m\n" "${VAR_VER_DS}"
|
||||
printf "\e[92m✅ Aide Initial DB at : %s \e[0m\n" "${VAR_HANDLER_BUILD_DIR}/.integrity/"
|
||||
printf "\e[92m✅ Exited with Status : %s \e[0m\n" "${var_print_scr_exit_code}"
|
||||
printf "\n"
|
||||
@@ -102,4 +129,86 @@ print_scr_exit() {
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f print_scr_exit
|
||||
|
||||
#######################################
|
||||
# Trap on 'EXIT' handler for 'non-0' exit-code.
|
||||
# Globals:
|
||||
# BASHOPTS
|
||||
# EPOCHREALTIME
|
||||
# ERRCMMD
|
||||
# ERRCODE
|
||||
# ERRFUNC
|
||||
# ERRLINE
|
||||
# ERRSCRT
|
||||
# EUID
|
||||
# LOG_DEBUG
|
||||
# LOG_ERROR
|
||||
# LOG_VAR
|
||||
# NL
|
||||
# SECONDS
|
||||
# SHELLOPTS
|
||||
# UID
|
||||
# VAR_ARG_SANITIZED
|
||||
# VAR_EARLY_DEBUG
|
||||
# VAR_GIT_REL
|
||||
# VAR_PARAM_COUNT
|
||||
# VAR_PARAM_STRNG
|
||||
# VAR_SYSTEM
|
||||
# VAR_VERSION
|
||||
# VAR_VER_BASH
|
||||
# VAR_VER_DS
|
||||
# VAR_VER_LB
|
||||
# Arguments:
|
||||
# 1: $?
|
||||
# 2: ${BASH_SOURCE[0]}
|
||||
# 3: ${LINENO}
|
||||
# 4: ${FUNCNAME[0]:-main}
|
||||
# 5: ${BASH_COMMAND}
|
||||
#######################################
|
||||
print_scr_exit_non_zero() {
|
||||
declare errcode="${ERRCODE:-$1}"
|
||||
declare errscrt="${ERRSCRT:-$2}"
|
||||
declare errline="${ERRLINE:-$3}"
|
||||
declare errfunc="${ERRFUNC:-$4}"
|
||||
declare errcmmd="${ERRCMMD:-$5}"
|
||||
|
||||
printf "\e[91m❌ Trap on 'EXIT' : CISS.debian.live.builder Script failed. \e[0m\n" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ : This was most probably caused by an unbound variable. \e[0m\n" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Git Commit : %s \e[0m\n" "${VAR_GIT_REL}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Version : %s \e[0m\n" "${VAR_VERSION}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Epoch : %s \e[0m\n" "${EPOCHREALTIME}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Bash : %s \e[0m\n" "${VAR_VER_BASH}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Live-Build : %s \e[0m\n" "${VAR_VER_LB}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Debootstrap : %s \e[0m\n" "${VAR_VER_DS}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ UID : %s \e[0m\n" "${UID}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ EUID : %s \e[0m\n" "${EUID}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Hostsystem : %s \e[0m\n" "${VAR_SYSTEM}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Error : %s \e[0m\n" "${errcode}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Line : %s \e[0m\n" "${errline}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Script : %s \e[0m\n" "${errscrt}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Function : %s \e[0m\n" "${errfunc}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Command : %s \e[0m\n" "${errcmmd}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Script Runtime : %s \e[0m\n" "${SECONDS}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Arguments Counter : %s \e[0m\n" "${VAR_PARAM_COUNT}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Arguments Original : %s \e[0m\n" "${VAR_PARAM_STRNG}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Arguments Sanitized : %s \e[0m\n" "${VAR_ARG_SANITIZED}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Bashopts : %s \e[0m\n" "${BASHOPTS}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Shellopts : %s \e[0m\n" "${SHELLOPTS}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Error Log saved at : %s \e[0m\n" "${LOG_ERROR}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ batcat --pager='less -r' %s \e[0m\n" "${LOG_ERROR}" | tee -a "${LOG_ERROR}"
|
||||
|
||||
if "${VAR_EARLY_DEBUG}"; then
|
||||
|
||||
printf "\e[91m❌ Vars Dump saved at : %s \e[0m\n" "${LOG_VAR}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ Debug Log saved at : %s \e[0m\n" "${LOG_DEBUG}" | tee -a "${LOG_ERROR}"
|
||||
printf "\e[91m❌ batcat --pager='less -r' %s \e[0m\n" "${LOG_DEBUG}" | tee -a "${LOG_ERROR}"
|
||||
|
||||
fi
|
||||
|
||||
print_stacktrace
|
||||
printf "%b" "${NL}"
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f print_scr_exit_non_zero
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user