V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m0s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m0s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
63
lib/cdi_0050_debug/0050_debug_pre_scan.sh
Normal file
63
lib/cdi_0050_debug/0050_debug_pre_scan.sh
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Check for DEBUG mode.
|
||||
# Globals:
|
||||
# LOG_VAR
|
||||
# VAR_DEBUG_TRACE
|
||||
# VAR_DEBUG_TRAP
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
pre_scan_debug() {
|
||||
declare args=("$@")
|
||||
declare dbg_index=-1
|
||||
declare dbg_count=0
|
||||
declare i j
|
||||
|
||||
for i in "${!args[@]}"; do
|
||||
if [[ "${args[i]}" == "-d" || "${args[i]}" == "--debug" ]]; then
|
||||
dbg_index=${i}
|
||||
declare -grx LOG_VAR="${DIR_LOG}/ciss_debian_installer_$$_var.log"
|
||||
touch "${LOG_VAR}" && chmod 0600 "${LOG_VAR}"
|
||||
dump_vars_initial
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if (( dbg_index >= 0 )); then
|
||||
for (( j=dbg_index+1; j<${#args[@]} && dbg_count<2; j++ )); do
|
||||
[[ "${args[j]}" =~ ^- ]] && break
|
||||
case "${args[j],,}" in
|
||||
xtrace)
|
||||
declare -gx VAR_DEBUG_TRACE="true"
|
||||
debug_trace "$@"
|
||||
;;
|
||||
trap)
|
||||
declare -gx VAR_DEBUG_TRAP="true"
|
||||
initialize_debug_trap
|
||||
trap 'debug_trap' DEBUG
|
||||
;;
|
||||
*)
|
||||
arg_mismatch "Invalid debug option: '${args[j]}'." ;;
|
||||
esac
|
||||
dbg_count=$(( dbg_count + 1 ))
|
||||
done
|
||||
|
||||
if (( dbg_count == 0 )); then arg_mismatch "--debug MUST NOT be empty."; fi
|
||||
if (( dbg_count > 2 )); then arg_mismatch "--debug accepts at most two options (XTRACE, TRAP)."; fi
|
||||
fi
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
74
lib/cdi_0050_debug/0051_debug_var_dump.sh
Normal file
74
lib/cdi_0050_debug/0051_debug_var_dump.sh
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Capture an initial snapshot of all variables (excluding '^(BASH|_).*').
|
||||
# Globals:
|
||||
# VAR_DUMP_VARS_INITIAL
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
dump_vars_initial() {
|
||||
# shellcheck disable=SC2155
|
||||
declare -grx VAR_DUMP_VARS_INITIAL=$(mktemp var_dump_vars_initial.XXXXXXXX)
|
||||
# shellcheck disable=SC2312
|
||||
{
|
||||
declare var
|
||||
while IFS= read -r var; do
|
||||
declare -p "${var}" 2> /dev/null
|
||||
done < <(compgen -v | grep -Ev '^(BASH|_).*')
|
||||
} | sort >| "${VAR_DUMP_VARS_INITIAL}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Gather all user-defined variables (name and value).
|
||||
# Globals:
|
||||
# LOG_VAR
|
||||
# VAR_DUMP_VARS_INITIAL
|
||||
# VAR_VERSION
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
dump_vars_exiting() {
|
||||
### Capture the final snapshot of all variables (excluding '^(BASH|_).*').
|
||||
# shellcheck disable=SC2155
|
||||
declare var_dump_vars_final=$(mktemp var_dump_vars_final.XXXXXXXX)
|
||||
set +x
|
||||
# shellcheck disable=SC2312
|
||||
{
|
||||
declare var
|
||||
while IFS= read -r var; do
|
||||
declare -p "${var}" 2>/dev/null
|
||||
done < <(compgen -v | grep -Ev '^(BASH|_).*')
|
||||
} | sort >| "${var_dump_vars_final}"
|
||||
|
||||
{
|
||||
printf "✅ CISS.debian.installer Config Variable Dump. \n"
|
||||
printf "✅ Version : %s \n" "${VAR_VERSION}"
|
||||
printf "\n"
|
||||
printf "===== Initial VAR Environment ===== \n"
|
||||
} >> "${LOG_VAR}"
|
||||
|
||||
comm -23 "${VAR_DUMP_VARS_INITIAL}" "${var_dump_vars_final}" >> "${LOG_VAR}" || true
|
||||
|
||||
{
|
||||
printf "\n"
|
||||
printf "===== Final VAR Environment ===== \n"
|
||||
} >> "${LOG_VAR}"
|
||||
|
||||
comm -13 "${VAR_DUMP_VARS_INITIAL}" "${var_dump_vars_final}" >> "${LOG_VAR}" || true
|
||||
set -x
|
||||
rm -f "${VAR_DUMP_VARS_INITIAL}" "${var_dump_vars_final}"
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
44
lib/cdi_0050_debug/0052_debug_trace.sh
Normal file
44
lib/cdi_0050_debug/0052_debug_trace.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Wrapper for XTRACE Debug.
|
||||
# Globals:
|
||||
# BASH_XTRACEFD
|
||||
# DIR_LOG
|
||||
# LOG_TRC
|
||||
# PS4
|
||||
# SHELLOPTS
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
debug_trace() {
|
||||
### Set a verbose PS4 prompt including timestamp, source, line, exit status of previous command, and function name
|
||||
declare -grx PS4='\e[97m+\e[0m\e[96m$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)\e[0m\e[97m:\e[0m\e[92m[${BASH_SOURCE[0]}:${LINENO}]\e[0m\e[97m|\e[0m\e[93m${?}\e[0m\e[97m>\e[0m\e[95m${FUNCNAME[0]:-main}()\e[0m \e[97m>>\e[0m '
|
||||
# shellcheck disable=SC2155
|
||||
declare -grx LOG_TRC="${DIR_LOG}/ciss_debian_installer_$$_trace.log"
|
||||
### Generates empty LOG_TRC
|
||||
touch "${LOG_TRC}" && chmod 0600 "${LOG_TRC}"
|
||||
### Open file descriptor 42 for writing to the debug log
|
||||
exec 42>| "${LOG_TRC}"
|
||||
### Write Debug Log Header https://www.gnu.org/software/bash/manual/html_node/Bash-Variables
|
||||
debug_trace_header "$#" "$*"
|
||||
### Tell Bash to send xtrace output to FD 42
|
||||
export BASH_XTRACEFD=42
|
||||
### Enable inheritable shell options
|
||||
export SHELLOPTS
|
||||
### Turn on xtrace
|
||||
set -x
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
67
lib/cdi_0050_debug/0053_debug_trace_header.sh
Normal file
67
lib/cdi_0050_debug/0053_debug_trace_header.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Generates XTRACE Debug Log Header.
|
||||
# Globals:
|
||||
# BASHOPTS
|
||||
# BASH_VERSINFO
|
||||
# EPOCHREALTIME
|
||||
# EUID
|
||||
# HOSTNAME
|
||||
# PPID
|
||||
# PWD
|
||||
# SHELLOPTS
|
||||
# UID
|
||||
# VAR_GIT_REL
|
||||
# VAR_RESOURCES
|
||||
# VAR_SYSTEM
|
||||
# VAR_VERSION
|
||||
# Arguments:
|
||||
# 0: Script Name $0
|
||||
# 1: Argument Counter $#
|
||||
# 2: Argument String $*
|
||||
#######################################
|
||||
debug_trace_header() {
|
||||
declare -r arg_counter="$1"
|
||||
declare -r arg_string="$2"
|
||||
#shellcheck disable=SC2312
|
||||
{
|
||||
printf "\e[97m+\e[0m\e[92m%s: CISS.debian.installer Debug XTRACE Log \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)"
|
||||
printf "\e[97m+\e[0m\e[92m%s: GIT Commit : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_GIT_REL}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_VERSION}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Epoch : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${EPOCHREALTIME}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash MAJ Release : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[0]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash MIN Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[1]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Patch Level : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[2]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Build Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[3]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Release : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[4]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: UID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${UID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: EUID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${EUID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Hostname : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${HOSTNAME}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Hostsystem : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_SYSTEM}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script name : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$0"
|
||||
printf "\e[97m+\e[0m\e[92m%s: System Resources : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_RESOURCES}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Argument Counter : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_counter}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Argument String Original : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_string}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$$"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script Parent PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${PPID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script work DIR : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${PWD}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Shell Options : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$-"
|
||||
printf "\e[97m+\e[0m\e[92m%s: BASHOPTS : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASHOPTS}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: SHELLOPTS : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${SHELLOPTS}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: ==== Debug Log Begin ==== : \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)"
|
||||
} >&42
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
115
lib/cdi_0050_debug/0054_debug_trap.sh
Normal file
115
lib/cdi_0050_debug/0054_debug_trap.sh
Normal file
@@ -0,0 +1,115 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Initialize Trap on 'DEBUG'.
|
||||
# Globals:
|
||||
# DIR_LOG
|
||||
# LOG_DBG
|
||||
# MASK_PATTERNS
|
||||
# VAR_LAST_CMD
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
initialize_debug_trap() {
|
||||
declare -gx VAR_LAST_CMD=""
|
||||
declare -gx __preexec_invoke=""
|
||||
# shellcheck disable=SC2155
|
||||
declare -grx LOG_DBG="${DIR_LOG}/ciss_debian_installer_$$_debug.log"
|
||||
### Generates empty LOG_DBG
|
||||
touch "${LOG_DBG}" && chmod 0600 "${LOG_DBG}"
|
||||
### Write Debug Log Header https://www.gnu.org/software/bash/manual/html_node/Bash-Variables
|
||||
debug_trap_header "$#" "$*"
|
||||
### Define patterns and mask replacements
|
||||
declare -Ag MASK_PATTERNS=(
|
||||
["API_KEY"]="********"
|
||||
["api_key"]="********"
|
||||
["password"]="********"
|
||||
["priv_key"]="********"
|
||||
["secret"]="********"
|
||||
["token"]="********"
|
||||
)
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Wrapper to write to DEBUG Logfile.
|
||||
# Globals:
|
||||
# BASH_LINENO
|
||||
# BASH_SOURCE
|
||||
# FUNCNAME
|
||||
# LOG_DBG
|
||||
# PWD
|
||||
# Arguments:
|
||||
# None
|
||||
#######################################
|
||||
debug_trap_logger() {
|
||||
declare var_rc="$1"; shift
|
||||
declare var_msg="$*"
|
||||
# shellcheck disable=SC2155
|
||||
declare var_ts="$(date -u '+%Y-%m-%dT%H:%M:%S.%4N%z')"
|
||||
declare -i i=0
|
||||
for (( i=0; i<${#FUNCNAME[@]}; i++ )); do
|
||||
if [[ ${FUNCNAME[i]} != "debug_trap_logger" && \
|
||||
${FUNCNAME[i]} != "debug_trap" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
declare var_func="${FUNCNAME[i]:-MAIN}"
|
||||
declare var_line="${BASH_LINENO[i-1]:-?}"
|
||||
declare var_script="${BASH_SOURCE[i]:-${BASH_SOURCE[0]}}"
|
||||
declare var_script_rel="${var_script#"${PWD}"/}"
|
||||
printf '%s [%s:%s] %s() |%s| RC:%s \n' "${var_ts}" "${var_script_rel}" "${var_line}" "${var_func}" "${var_msg}" "${var_rc}">> "${LOG_DBG}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Trap function to be called on 'DEBUG'.
|
||||
# Globals:
|
||||
# BASH_COMMAND
|
||||
# MASK_PATTERNS
|
||||
# VAR_LAST_CMD
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# 0: In all cases
|
||||
#######################################
|
||||
debug_trap() {
|
||||
declare rc="$?" var_cmd="${BASH_COMMAND}"
|
||||
|
||||
### Skip any xtrace output or explicit set -x/+x calls
|
||||
if [[ "${var_cmd}" == +* ]] || [[ "${var_cmd}" == "set -x" ]] || [[ "${var_cmd}" == "set +x" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
### Mask sensitive substrings
|
||||
declare key
|
||||
for key in "${!MASK_PATTERNS[@]}"; do
|
||||
#if [[ "${var_cmd}" =~ ${key} ]]; then
|
||||
# var_cmd="${var_cmd//${key}/${MASK_PATTERNS[${key}]}}"
|
||||
#fi
|
||||
case "${var_cmd}" in
|
||||
*"${key}"*) var_cmd="${var_cmd//${key}/${MASK_PATTERNS[${key}]}}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n "${__preexec_invoke:-}" ]]; then
|
||||
debug_trap_logger "${rc}" "${VAR_LAST_CMD}"
|
||||
__preexec_invoke=""
|
||||
fi
|
||||
|
||||
__preexec_invoke=1
|
||||
VAR_LAST_CMD="${var_cmd}"
|
||||
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
68
lib/cdi_0050_debug/0055_debug_trap_header.sh
Normal file
68
lib/cdi_0050_debug/0055_debug_trap_header.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Generates TRAP Debug Log Header.
|
||||
# Globals:
|
||||
# BASHOPTS
|
||||
# BASH_VERSINFO
|
||||
# EPOCHREALTIME
|
||||
# EUID
|
||||
# HOSTNAME
|
||||
# LOG_DBG
|
||||
# PPID
|
||||
# PWD
|
||||
# SHELLOPTS
|
||||
# UID
|
||||
# VAR_GIT_REL
|
||||
# VAR_RESOURCES
|
||||
# VAR_SYSTEM
|
||||
# VAR_VERSION
|
||||
# Arguments:
|
||||
# 0: Script Name $0
|
||||
# 1: Argument Counter $#
|
||||
# 2: Argument String $*
|
||||
#######################################
|
||||
debug_trap_header() {
|
||||
declare -r arg_counter="$1"
|
||||
declare -r arg_string="$2"
|
||||
# shellcheck disable=SC2312
|
||||
{
|
||||
printf "\e[97m+\e[0m\e[92m%s: CISS.debian.installer Debug TRAP Log \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)"
|
||||
printf "\e[97m+\e[0m\e[92m%s: GIT Commit : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_GIT_REL}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_VERSION}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Epoch : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${EPOCHREALTIME}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash MAJ Release : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[0]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash MIN Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[1]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Patch Level : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[2]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Build Version : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[3]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Bash Release : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASH_VERSINFO[4]}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: UID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${UID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: EUID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${EUID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Hostname : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${HOSTNAME}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Hostsystem : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_SYSTEM}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script name : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$0"
|
||||
printf "\e[97m+\e[0m\e[92m%s: System Resources : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_RESOURCES}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Argument Counter : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_counter}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Argument String Original : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_string}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$$"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script Parent PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${PPID}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Script work DIR : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${PWD}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: Shell Options : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$-"
|
||||
printf "\e[97m+\e[0m\e[92m%s: BASHOPTS : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${BASHOPTS}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: SHELLOPTS : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${SHELLOPTS}"
|
||||
printf "\e[97m+\e[0m\e[92m%s: ==== Debug Log Begin ==== : \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)"
|
||||
} >| "${LOG_DBG}"
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
Reference in New Issue
Block a user