All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 43s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
164 lines
5.9 KiB
Bash
164 lines
5.9 KiB
Bash
#!/bin/bash
|
|
# SPDX-Version: 3.0
|
|
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
|
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
|
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
|
# SPDX-FileType: SOURCE
|
|
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
|
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
|
# SPDX-PackageName: CISS.debian.installer
|
|
# SPDX-Security-Contact: security@coresecret.eu
|
|
|
|
guard_sourcing
|
|
|
|
#######################################
|
|
# Print Error Message for Trap on 'ERR' in '${ERROR_LOG}'.
|
|
# Globals:
|
|
# VAR_PARAM_COUNT
|
|
# ARG_STR_ORG_INPUT
|
|
# ERRCMMD
|
|
# ERRCODE
|
|
# ERRFUNC
|
|
# ERRLINE
|
|
# ERRSCRT
|
|
# LOG_DBG
|
|
# LOG_ERR
|
|
# LOG_TRC
|
|
# LOG_VAR
|
|
# NL
|
|
# SECONDS
|
|
# VAR_ARG_SANITIZED
|
|
# VAR_DEBUG_TRACE
|
|
# VAR_DEBUG_TRAP
|
|
# VAR_GIT_HEAD
|
|
# VAR_SYSTEM
|
|
# VAR_VERSION
|
|
# Arguments:
|
|
# None
|
|
#######################################
|
|
print_file_err() {
|
|
{
|
|
printf "❌ CISS.debian.installer Script failed. %s" "${NL}"
|
|
printf "❌ GIT Commit : %s %s" "${VAR_GIT_HEAD}" "${NL}"
|
|
printf "❌ Version : %s %s" "${VAR_VERSION}" "${NL}"
|
|
printf "❌ Hostsystem : %s %s" "${VAR_SYSTEM}" "${NL}"
|
|
printf "❌ Error : %s %s" "${ERRCODE}" "${NL}"
|
|
printf "❌ Line : %s %s" "${ERRLINE}" "${NL}"
|
|
printf "❌ Script : %s %s" "${ERRSCRT}" "${NL}"
|
|
printf "❌ Function : %s %s" "${ERRFUNC}" "${NL}"
|
|
printf "❌ Command : %s %s" "${ERRCMMD}" "${NL}"
|
|
printf "❌ Script PID : %s %s" "${$}" "${NL}"
|
|
printf "❌ Script Runtime : %s %s" "${SECONDS}" "${NL}"
|
|
printf "❌ Arguments Counter : %s %s" "${VAR_PARAM_COUNT}" "${NL}"
|
|
printf "❌ Arguments Original : %s %s" "${ARG_STR_ORG_INPUT}" "${NL}"
|
|
printf "❌ Arguments Sanitized : %s %s" "${VAR_ARG_SANITIZED}" "${NL}"
|
|
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
|
|
printf "❌ Vars Dump saved at : %s %s" "${LOG_VAR}" "${NL}"
|
|
fi
|
|
if "${VAR_DEBUG_TRAP}"; then
|
|
printf "❌ DEBUG Log saved at : %s %s" "${LOG_DBG}" "${NL}"
|
|
printf "❌ cat %s %s" "${LOG_DBG}" "${NL}"
|
|
fi
|
|
if "${VAR_DEBUG_TRACE}"; then
|
|
printf "❌ TRACE Log saved at : %s %s" "${LOG_TRC}" "${NL}"
|
|
printf "❌ cat %s %s" "${LOG_TRC}" "${NL}"
|
|
fi
|
|
printf "%s" "${NL}"
|
|
} >> "${LOG_ERR}"
|
|
}
|
|
|
|
#######################################
|
|
# Print Error Message for Trap on 'ERR' on Terminal.
|
|
# Globals:
|
|
# VAR_PARAM_COUNT
|
|
# ARG_STR_ORG_INPUT
|
|
# RED
|
|
# RES
|
|
# ERRCMMD
|
|
# ERRCODE
|
|
# ERRFUNC
|
|
# ERRLINE
|
|
# ERRSCRT
|
|
# LOG_DBG
|
|
# LOG_ERR
|
|
# LOG_TRC
|
|
# LOG_VAR
|
|
# NL
|
|
# SECONDS
|
|
# VAR_ARG_SANITIZED
|
|
# VAR_DEBUG_TRACE
|
|
# VAR_DEBUG_TRAP
|
|
# VAR_GIT_HEAD
|
|
# VAR_SYSTEM
|
|
# VAR_VERSION
|
|
# Arguments:
|
|
# None
|
|
#######################################
|
|
print_scr_err() {
|
|
printf "%s❌ CISS.debian.installer Script failed. %s%s" "${RED}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ GIT Commit : %s %s%s" "${RED}" "${VAR_GIT_HEAD}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Version : %s %s%s" "${RED}" "${VAR_VERSION}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Hostsystem : %s %s%s" "${RED}" "${VAR_SYSTEM}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Error : %s %s%s" "${RED}" "${ERRCODE}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Line : %s %s%s" "${RED}" "${ERRLINE}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Script : %s %s%s" "${RED}" "${ERRSCRT}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Function : %s %s%s" "${RED}" "${ERRFUNC}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Command : %s %s%s" "${RED}" "${ERRCMMD}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Script PID : %s %s%s" "${RED}" "${$}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Script Runtime : %s %s%s" "${RED}" "${SECONDS}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Arguments Counter : %s %s%s" "${RED}" "${VAR_PARAM_COUNT}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Arguments Original : %s %s%s" "${RED}" "${ARG_STR_ORG_INPUT}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Arguments Sanitized : %s %s%s" "${RED}" "${VAR_ARG_SANITIZED}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ Error Log saved at : %s %s%s" "${RED}" "${LOG_ERR}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ cat %s %s%s" "${RED}" "${LOG_ERR}" "${RES}" "${NL}" >&2
|
|
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
|
|
printf "%s❌ Vars Dump saved at : %s %s%s" "${RED}" "${LOG_VAR}" "${RES}" "${NL}" >&2
|
|
fi
|
|
if "${VAR_DEBUG_TRAP}"; then
|
|
printf "%s❌ Debug Log saved at : %s %s%s" "${RED}" "${LOG_DBG}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ cat %s %s%s" "${RED}" "${LOG_DBG}" "${RES}" "${NL}" >&2
|
|
fi
|
|
if "${VAR_DEBUG_TRACE}"; then
|
|
printf "%s❌ Debug Log saved at : %s %s%s" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
|
printf "%s❌ cat %s %s%s" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
|
fi
|
|
printf "%s" "${NL}"
|
|
}
|
|
|
|
#######################################
|
|
# Trap function to be called on 'ERR'.
|
|
# Globals:
|
|
# ERRCMMD
|
|
# ERRCODE
|
|
# ERRFUNC
|
|
# ERRLINE
|
|
# ERRSCRT
|
|
# VAR_DEBUG_TRACE
|
|
# VAR_DEBUG_TRAP
|
|
# VAR_IN_DIALOG_WR
|
|
# Arguments:
|
|
# $1: "$?"
|
|
# $2: "${BASH_SOURCE[0]}"
|
|
# $3: "${LINENO}"
|
|
# $4: "${FUNCNAME[0]:-main}"
|
|
# $5: "${BASH_COMMAND}"
|
|
#######################################
|
|
trap_err() {
|
|
trap - DEBUG ERR INT
|
|
declare -g ERRCODE="$1"
|
|
declare -g ERRSCRT="$2"
|
|
declare -g ERRLINE="$3"
|
|
declare -g ERRFUNC="$4"
|
|
declare -g ERRCMMD="$5"
|
|
ERRTRAP="true"
|
|
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then dump_vars_exiting; fi
|
|
case "${VAR_IN_DIALOG_WR}" in
|
|
box ) dialog_box_cleaner ;;
|
|
gauge ) dialog_gauge_cleaner ;;
|
|
esac
|
|
print_file_err
|
|
print_scr_err
|
|
}
|
|
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|