V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -14,6 +14,10 @@ guard_sourcing
|
||||
|
||||
#######################################
|
||||
# Print-colored text.
|
||||
# Globals:
|
||||
# NL
|
||||
# RES
|
||||
# WHI
|
||||
# Arguments:
|
||||
# 1: Color code.
|
||||
# *: Text to print.
|
||||
@@ -22,6 +26,6 @@ color_echo() {
|
||||
declare c="$1"
|
||||
shift
|
||||
declare msg="${*}"
|
||||
printf "%s[INFO]%s %s%s.%s%s" "${c}" "${RES}" "${WHI}" "${msg}" "${RES}" "${NL}"
|
||||
printf "%b[INFO]%b %b%s.%b%b" "${c}" "${RES}" "${WHI}" "${msg}" "${RES}" "${NL}"
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
51
lib/0024_logging_helper.sh
Normal file
51
lib/0024_logging_helper.sh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/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 around 'printf' for clean code.
|
||||
# Globals:
|
||||
# RES
|
||||
# Arguments:
|
||||
# 1: One of "${BLA}" | "${RED}" | "${GRE}" | "${YEL}" | "${BLU}" | "${MAG}" | "${CYA}" | "${WHI}"
|
||||
# 2: Text string to print on terminal.
|
||||
#######################################
|
||||
do_print_color() {
|
||||
printf "%b\n" "${1}${2}${RES}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Wrapper around 'printf' for clean, uniform terminal output and line fold for long text strings for better readability.
|
||||
# Globals:
|
||||
# RES
|
||||
# Arguments:
|
||||
# 1: One of "${BLA}" | "${RED}" | "${GRE}" | "${YEL}" | "${BLU}" | "${MAG}" | "${CYA}" | "${WHI}"
|
||||
# 2: Text string to print on terminal.
|
||||
#######################################
|
||||
do_print_fold() {
|
||||
declare var_color="$1"; shift
|
||||
declare var_msg_string="$*"
|
||||
declare var_formatted_string="${var_color}${var_msg_string}${RES}"
|
||||
# shellcheck disable=SC2312
|
||||
printf "%b\n" "${var_formatted_string}" | fold -s -w 76 | sed '1! s/^/ /'
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Wrapper around 'printf' for logfile redirect.
|
||||
# Arguments:
|
||||
# 1: Text string to redirect to a log file.
|
||||
#######################################
|
||||
do_print_log() {
|
||||
printf "%s\n" "${1}"
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
@@ -76,7 +76,7 @@ do_get_log_color() {
|
||||
# LOG_INS
|
||||
# Arguments:
|
||||
# 1: "${LOG_LEVEL}" one of: "debug" | "info" | "notice" | "warn" | "error" | "critical" | "fatal" | "emergency"
|
||||
# 2: "${LOG_ONLY}" boolean "true" | "false"
|
||||
# 2: "${LOG_ONLY}" one of: "file_only" | "tty"
|
||||
# @: "${MESSAGE[*]}" arbitrary text string to log.
|
||||
#######################################
|
||||
do_log() {
|
||||
|
||||
@@ -13,24 +13,36 @@
|
||||
guard_sourcing
|
||||
|
||||
#######################################
|
||||
# Unbound Variable Check and call Trap on ERR.
|
||||
# Unbound Variable Check.
|
||||
# Globals:
|
||||
# ERR_UNBOUND_VARIABLE
|
||||
# GRE
|
||||
# NL
|
||||
# RED
|
||||
# RES
|
||||
# Arguments:
|
||||
# 1: VAR_NAME to check
|
||||
# 1: VAR_NAME to check NOT the variable itself.
|
||||
# Returns:
|
||||
# ERR_UNBOUND_VARIABLE
|
||||
#######################################
|
||||
check_var() {
|
||||
declare var_name_to_check="$1"
|
||||
if [[ -n "${!var_name_to_check+exists}" ]]; then
|
||||
|
||||
### First check: Is the passed-in variable name itself set?
|
||||
if ! [[ -v var_name_to_check ]]; then
|
||||
printf "%b❌ Error: Variable NOT set: '%s'. Exiting Script. %b%b" "${RED}" "${var_name_to_check}" "${RES}" "${NL}" >&2
|
||||
return "${ERR_UNBOUND_VARIABLE}"
|
||||
fi
|
||||
|
||||
### Second check: Is the variable referenced by var_name_to_check declared?
|
||||
if [[ -v "${var_name_to_check}" ]]; then
|
||||
if [[ -n "${!var_name_to_check}" ]]; then
|
||||
printf "\e[92m✅ Variable: '%s' exists and is NOT empty: '%s' \e[0m\n" "${var_name_to_check}" "${!var_name_to_check}"
|
||||
printf "%b✅ Variable: '%s' exists and is NOT empty: '%s'. %b%b" "${GRE}" "${var_name_to_check}" "${!var_name_to_check}" "${RES}" "${NL}"
|
||||
else
|
||||
printf "\e[92m✅ Variable: '%s' exists but is empty. \e[0m\n" "${var_name_to_check}"
|
||||
printf "%b✅ Variable: '%s' exists but is empty. %b%b" "${GRE}" "${var_name_to_check}" "${RES}" "${NL}"
|
||||
fi
|
||||
else
|
||||
printf "\e[91m❌ Variable: '%s' is not declared. Exiting Script. \e[0m\n" "${var_name_to_check}" >&2
|
||||
printf "%b❌ Error: Variable NOT declared: '%s'. Exiting Script. %b%b" "${RED}" "${var_name_to_check}" "${RES}" "${NL}" >&2
|
||||
return "${ERR_UNBOUND_VARIABLE}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -15,17 +15,22 @@ guard_sourcing
|
||||
#######################################
|
||||
# Print Error Message for Trap on 'ERR' in '${ERROR_LOG}'.
|
||||
# Globals:
|
||||
# BASH_VERSINFO
|
||||
# EPOCHREALTIME
|
||||
# ERRCMMD
|
||||
# ERRCODE
|
||||
# ERRFUNC
|
||||
# ERRLINE
|
||||
# ERRSCRT
|
||||
# EUID
|
||||
# HOSTNAME
|
||||
# LOG_DBG
|
||||
# LOG_ERR
|
||||
# LOG_TRC
|
||||
# LOG_VAR
|
||||
# NL
|
||||
# SECONDS
|
||||
# UID
|
||||
# VAR_ARG_SANITIZED
|
||||
# VAR_DEBUG_TRACE
|
||||
# VAR_DEBUG_TRAP
|
||||
@@ -39,30 +44,39 @@ guard_sourcing
|
||||
#######################################
|
||||
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" "${VAR_PARAM_STRNG}" "${NL}"
|
||||
printf "❌ Arguments Sanitized : %s %s" "${VAR_ARG_SANITIZED}" "${NL}"
|
||||
printf "❌ CISS.debian.installer Script failed. %b" "${NL}"
|
||||
printf "❌ GIT Commit : %s %b" "${VAR_GIT_HEAD}" "${NL}"
|
||||
printf "❌ Version : %s %b" "${VAR_VERSION}" "${NL}"
|
||||
printf "❌ Epoch : %s %b" "${EPOCHREALTIME}" "${NL}"
|
||||
printf "❌ Bash MAJ Release : %s %b" "${BASH_VERSINFO[0]}" "${NL}"
|
||||
printf "❌ Bash MIN Version : %s %b" "${BASH_VERSINFO[1]}" "${NL}"
|
||||
printf "❌ Bash Patch Level : %s %b" "${BASH_VERSINFO[2]}" "${NL}"
|
||||
printf "❌ Bash Build Version : %s %b" "${BASH_VERSINFO[3]}" "${NL}"
|
||||
printf "❌ Bash Release : %s %b" "${BASH_VERSINFO[4]}" "${NL}"
|
||||
printf "❌ UID : %s %b" "${UID}" "${NL}"
|
||||
printf "❌ EUID : %s %b" "${EUID}" "${NL}"
|
||||
printf "❌ Hostname : %s %b" "${HOSTNAME}" "${NL}"
|
||||
printf "❌ Hostsystem : %s %b" "${VAR_SYSTEM}" "${NL}"
|
||||
printf "❌ Error : %s %b" "${ERRCODE}" "${NL}"
|
||||
printf "❌ Line : %s %b" "${ERRLINE}" "${NL}"
|
||||
printf "❌ Script : %s %b" "${ERRSCRT}" "${NL}"
|
||||
printf "❌ Function : %s %b" "${ERRFUNC}" "${NL}"
|
||||
printf "❌ Command : %s %b" "${ERRCMMD}" "${NL}"
|
||||
printf "❌ Script PID : %s %b" "${$}" "${NL}"
|
||||
printf "❌ Script Runtime : %s %b" "${SECONDS}" "${NL}"
|
||||
printf "❌ Arguments Counter : %s %b" "${VAR_PARAM_COUNT}" "${NL}"
|
||||
printf "❌ Arguments Original : %s %b" "${VAR_PARAM_STRNG}" "${NL}"
|
||||
printf "❌ Arguments Sanitized : %s %b" "${VAR_ARG_SANITIZED}" "${NL}"
|
||||
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
|
||||
printf "❌ Vars Dump saved at : %s %s" "${LOG_VAR}" "${NL}"
|
||||
printf "❌ Vars Dump saved at : %s %b" "${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}"
|
||||
printf "❌ DEBUG Log saved at : %s %b" "${LOG_DBG}" "${NL}"
|
||||
printf "❌ cat %s %b" "${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}"
|
||||
printf "❌ TRACE Log saved at : %s %b" "${LOG_TRC}" "${NL}"
|
||||
printf "❌ cat %s %b" "${LOG_TRC}" "${NL}"
|
||||
fi
|
||||
printf "%s" "${NL}"
|
||||
} >> "${LOG_ERR}"
|
||||
@@ -71,19 +85,22 @@ print_file_err() {
|
||||
#######################################
|
||||
# Print Error Message for Trap on 'ERR' on Terminal.
|
||||
# Globals:
|
||||
# BASH_VERSINFO
|
||||
# EPOCHREALTIME
|
||||
# ERRCMMD
|
||||
# ERRCODE
|
||||
# ERRFUNC
|
||||
# ERRLINE
|
||||
# ERRSCRT
|
||||
# EUID
|
||||
# HOSTNAME
|
||||
# LOG_DBG
|
||||
# LOG_ERR
|
||||
# LOG_TRC
|
||||
# LOG_VAR
|
||||
# NL
|
||||
# RED
|
||||
# RES
|
||||
# SECONDS
|
||||
# UID
|
||||
# VAR_ARG_SANITIZED
|
||||
# VAR_DEBUG_TRACE
|
||||
# VAR_DEBUG_TRAP
|
||||
@@ -96,35 +113,44 @@ print_file_err() {
|
||||
# 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}" "${VAR_PARAM_STRNG}" "${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
|
||||
printf "%b❌ CISS.debian.installer Script failed. %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ GIT Commit : %s %b%b" "${RED}" "${VAR_GIT_HEAD}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Version : %s %b%b" "${RED}" "${VAR_VERSION}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Epoch : %s %b%b" "${RED}" "${EPOCHREALTIME}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash MAJ Release : %s %b%b" "${RED}" "${BASH_VERSINFO[0]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash MIN Version : %s %b%b" "${RED}" "${BASH_VERSINFO[1]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash Patch Level : %s %b%b" "${RED}" "${BASH_VERSINFO[2]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash Build Version : %s %b%b" "${RED}" "${BASH_VERSINFO[3]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash Release : %s %b%b" "${RED}" "${BASH_VERSINFO[4]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ UID : %s %b%b" "${RED}" "${UID}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ EUID : %s %b%b" "${RED}" "${EUID}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Hostname : %s %b%b" "${RED}" "${HOSTNAME}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Hostsystem : %s %b%b" "${RED}" "${VAR_SYSTEM}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Error : %s %b%b" "${RED}" "${ERRCODE}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Line : %s %b%b" "${RED}" "${ERRLINE}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script : %s %b%b" "${RED}" "${ERRSCRT}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Function : %s %b%b" "${RED}" "${ERRFUNC}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Command : %s %b%b" "${RED}" "${ERRCMMD}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script PID : %s %b%b" "${RED}" "${$}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script Runtime : %s %b%b" "${RED}" "${SECONDS}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Counter : %s %b%b" "${RED}" "${VAR_PARAM_COUNT}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Original : %s %b%b" "${RED}" "${VAR_PARAM_STRNG}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Sanitized : %s %b%b" "${RED}" "${VAR_ARG_SANITIZED}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Error Log saved at : %s %b%b" "${RED}" "${LOG_ERR}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ cat %s %b%b" "${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
|
||||
printf "%b❌ Vars Dump saved at : %s %b%b" "${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
|
||||
printf "%b❌ Debug Log saved at : %s %b%b" "${RED}" "${LOG_DBG}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ cat %s %b%b" "${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
|
||||
printf "%b❌ Debug Log saved at : %s %b%b" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ cat %s %b%b" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
||||
fi
|
||||
print_stacktrace
|
||||
printf "%s" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
}
|
||||
|
||||
#######################################
|
||||
@@ -141,10 +167,10 @@ print_scr_err() {
|
||||
#######################################
|
||||
print_stacktrace() {
|
||||
if (( ${#FUNCNAME[@]} > 2 )); then
|
||||
printf "%s" "${NL}"
|
||||
printf "%s❌ Call Stack (most recent call first): %s%s" "${RED}" "${RES}" "${NL}" >&2
|
||||
printf "%b" "${NL}"
|
||||
printf "%b❌ Call Stack (most recent call first): %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
for ((i=1; i<${#FUNCNAME[@]}-1; i++)); do
|
||||
printf "%s❌ ↳ %s() at [%s:%s] %s%s" "${RED}" "${FUNCNAME[i]}" "${BASH_SOURCE[i]}" "${BASH_LINENO[i-1]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ ↳ %s() at [%s:%s] %b%b" "${RED}" "${FUNCNAME[i]}" "${BASH_SOURCE[i]}" "${BASH_LINENO[i-1]}" "${RES}" "${NL}" >&2
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -69,26 +69,26 @@ trap_exit_zero() {
|
||||
clean_up "${var_trap_exit_zero_code}"
|
||||
|
||||
if [[ "${VAR_SCRIPT_SUCCESS}" == "true" ]]; then
|
||||
printf "%s" "${NL}"
|
||||
printf "%s✅ CISS.debian.installer Script successful. %s%s" "${GRE}" "${RES}" "${NL}"
|
||||
printf "%s✅ Exited with Status : %s %s%s" "${GRE}" "${var_trap_exit_zero_code}" "${RES}" "${NL}"
|
||||
printf "%s" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
printf "%b✅ CISS.debian.installer Script successful. %s%s" "${GRE}" "${RES}" "${NL}"
|
||||
printf "%b✅ Exited with Status : %s %b%b" "${GRE}" "${var_trap_exit_zero_code}" "${RES}" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
|
||||
printf "%s✅ Vars Dump saved at : %s %s%s" "${GRE}" "${LOG_VAR}" "${RES}" "${NL}"
|
||||
printf "%s✅ cat %s %s%s" "${GRE}" "${LOG_VAR}" "${RES}" "${NL}"
|
||||
printf "%b✅ Vars Dump saved at : %s %b%b" "${GRE}" "${LOG_VAR}" "${RES}" "${NL}"
|
||||
printf "%b✅ cat %s %b%b" "${GRE}" "${LOG_VAR}" "${RES}" "${NL}"
|
||||
fi
|
||||
if [[ "${VAR_DEBUG_TRAP}" == "true" ]]; then
|
||||
printf "%s✅ DEBUG Log saved at : %s %s%s" "${GRE}" "${LOG_DBG}" "${RES}" "${NL}"
|
||||
printf "%s✅ cat %s %s%s" "${GRE}" "${LOG_DBG}" "${RES}" "${NL}"
|
||||
printf "%b✅ DEBUG Log saved at : %s %b%b" "${GRE}" "${LOG_DBG}" "${RES}" "${NL}"
|
||||
printf "%b✅ cat %s %b%b" "${GRE}" "${LOG_DBG}" "${RES}" "${NL}"
|
||||
fi
|
||||
if [[ "${VAR_DEBUG_TRACE}" == "true" ]]; then
|
||||
printf "%s✅ TRACE Log saved at : %s %s%s" "${GRE}" "${LOG_TRC}" "${RES}" "${NL}"
|
||||
printf "%s✅ cat %s %s%s" "${GRE}" "${LOG_TRC}" "${RES}" "${NL}"
|
||||
printf "%b✅ TRACE Log saved at : %s %b%b" "${GRE}" "${LOG_TRC}" "${RES}" "${NL}"
|
||||
printf "%b✅ cat %s %b%b" "${GRE}" "${LOG_TRC}" "${RES}" "${NL}"
|
||||
fi
|
||||
printf "%s" "${NL}"
|
||||
printf "%s💷 Please consider donating to my work at: %s%s" "${MAG}" "${RES}" "${NL}"
|
||||
printf "%s🔗 https://coresecret.eu/spenden/ %s%s" "${MAG}" "${RES}" "${NL}"
|
||||
printf "%s" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
printf "%b💷 Please consider donating to my work at: %b%b" "${MAG}" "${RES}" "${NL}"
|
||||
printf "%b🔗 https://coresecret.eu/spenden/ %b%b" "${MAG}" "${RES}" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
fi
|
||||
exit "${var_trap_exit_zero_code}"
|
||||
}
|
||||
@@ -134,30 +134,37 @@ trap_exit_non_zero() {
|
||||
gauge ) dialog_gauge_cleaner ;;
|
||||
esac
|
||||
clean_up "${var_code}"
|
||||
printf "%s❌ CISS.debian.installer Script failed. Most probably cause of unbound variable. %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}" "${var_code}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Line : %s %s%s" "${RED}" "${var_line}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Script : %s %s%s" "${RED}" "${var_scrt}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Function : %s %s%s" "${RED}" "${var_func}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Command : %s %s%s" "${RED}" "${var_cmmd}" "${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}" "${VAR_PARAM_STRNG}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Arguments Sanitized : %s %s%s" "${RED}" "${VAR_ARG_SANITIZED}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ CISS.debian.installer Script failed. Most probably cause of unbound variable. %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ GIT Commit : %s %b%b" "${RED}" "${VAR_GIT_HEAD}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Version : %s %b%b" "${RED}" "${VAR_VERSION}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Epoch : %s %b%b" "${RED}" "${EPOCHREALTIME}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash MAJ Release : %s %b%b" "${RED}" "${BASH_VERSINFO[0]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash MIN Version : %s %b%b" "${RED}" "${BASH_VERSINFO[1]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Bash Patch Level : %s %b%b" "${RED}" "${BASH_VERSINFO[2]}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ UID : %s %b%b" "${RED}" "${UID}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ EUID : %s %b%b" "${RED}" "${EUID}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Hostname : %s %b%b" "${RED}" "${HOSTNAME}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Hostsystem : %s %b%b" "${RED}" "${VAR_SYSTEM}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Error : %s %b%b" "${RED}" "${var_code}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Line : %s %b%b" "${RED}" "${var_line}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script : %s %b%b" "${RED}" "${var_scrt}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Function : %s %b%b" "${RED}" "${var_func}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Command : %s %b%b" "${RED}" "${var_cmmd}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script PID : %s %b%b" "${RED}" "${$}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Script Runtime : %s %b%b" "${RED}" "${SECONDS}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Counter : %s %b%b" "${RED}" "${VAR_PARAM_COUNT}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Original : %s %b%b" "${RED}" "${VAR_PARAM_STRNG}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Arguments Sanitized : %s %b%b" "${RED}" "${VAR_ARG_SANITIZED}" "${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
|
||||
printf "%b❌ Vars Dump saved at : %s %b%b" "${RED}" "${LOG_VAR}" "${RES}" "${NL}" >&2
|
||||
fi
|
||||
if [[ "${VAR_DEBUG_TRAP}" == "true" ]]; 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
|
||||
printf "%b❌ Debug Log saved at : %s %b%b" "${RED}" "${LOG_DBG}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ cat %s %b%b" "${RED}" "${LOG_DBG}" "${RES}" "${NL}" >&2
|
||||
fi
|
||||
if [[ "${VAR_DEBUG_TRACE}" == "true" ]]; 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
|
||||
printf "%b❌ Debug Log saved at : %s %b%b" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ cat %s %b%b" "${RED}" "${LOG_TRC}" "${RES}" "${NL}" >&2
|
||||
fi
|
||||
print_stacktrace
|
||||
fi
|
||||
|
||||
@@ -34,6 +34,10 @@ restart_dialog() {
|
||||
# Trap function to be called on 'SIGINT'.
|
||||
# Globals:
|
||||
# ERR_TRAPPED_SIG_INT
|
||||
# GRE
|
||||
# NL
|
||||
# RED
|
||||
# RES
|
||||
# VAR_IN_DIALOG_WR
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -51,11 +55,11 @@ trap_int() {
|
||||
|
||||
declare answer
|
||||
if ! read -r -t 16 -p $'\n\e[93mCISS.debian.installer caught an INT.\e[0m \e[92mDo you want to abort the Installer? (y/N) \e[0m' answer; then
|
||||
printf "\e[92mCISS.debian.installer caught an INT. No User confirmation after 16 seconds. Proceeding with Installer. \e[0m\n" >&2
|
||||
if [[ "${var_helper_dialog}" == box ]]; then
|
||||
printf "%bCISS.debian.installer caught an INT. No User confirmation after 16 seconds. Proceeding with Installer. %b%b" "${GRE}" "${RES}" "${NL}" >&2
|
||||
if [[ "${var_helper_dialog}" == "box" ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
elif [[ "${var_helper_dialog}" == gauge ]]; then
|
||||
elif [[ "${var_helper_dialog}" == "gauge" ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
else
|
||||
@@ -66,11 +70,11 @@ trap_int() {
|
||||
|
||||
case "${answer,,}" in
|
||||
y|yes)
|
||||
printf "\e[91mCISS.debian.installer caught an INT. SIGINT confirmed by User, exiting Installer. \e[0m\n" >&2
|
||||
printf "%bCISS.debian.installer caught an INT. SIGINT confirmed by User, exiting Installer. %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
exit "${ERR_TRAPPED_SIG_INT}"
|
||||
;;
|
||||
*)
|
||||
printf "\e[92mCISS.debian.installer caught an INT. SIGINT NOT confirmed by User, proceeding with Installer. \e[0m\n" >&2
|
||||
printf "%bCISS.debian.installer caught an INT. SIGINT NOT confirmed by User, proceeding with Installer. %b%b" "${GRE}" "${RES}" "${NL}" >&2
|
||||
if [[ "${var_helper_dialog}" == box ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
|
||||
@@ -22,6 +22,8 @@ guard_sourcing
|
||||
# VAR_NOTES
|
||||
# Arguments:
|
||||
# 1: ${var_trap_on_exit_code} of trap_exit()
|
||||
# Returns:
|
||||
# 0: On success
|
||||
#######################################
|
||||
clean_up() {
|
||||
declare var_clean_exit_code="$1"
|
||||
@@ -36,5 +38,6 @@ clean_up() {
|
||||
### Remove the lockfile artifact.
|
||||
rm -f /run/lock/ciss_debian_installer.lock
|
||||
if (( var_clean_exit_code == 0 )); then rm -f -- "${LOG_ERR}"; fi
|
||||
return 0
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -32,7 +32,7 @@ arg_mismatch() {
|
||||
box|gauge) "dialog_${VAR_IN_DIALOG_WR}_cleaner" ;;
|
||||
esac
|
||||
fi
|
||||
printf "%s❌ Error: '%s'. %s%s" "${RED}" "${1}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Error: '%s'. %b%b" "${RED}" "${1}" "${RES}" "${NL}" >&2
|
||||
read -pr $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m'
|
||||
exit "${ERR_ARG_MISMATCH}"
|
||||
}
|
||||
|
||||
@@ -47,18 +47,20 @@ sanitize_arg() {
|
||||
disallowed_ctrl=$(printf '%s' "${input}" | sed -n 's/[^[:cntrl:]]//gp' | sed $'s/./&\\n/g' \
|
||||
| while read -r c; do printf "%02X " "'${c}"; done)
|
||||
{
|
||||
printf "❌ Control character : '%s'. %s" "${disallowed_ctrl}" "${NL}"
|
||||
printf "❌ in argument : '%s'. %s" "${input}" "${NL}"
|
||||
printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %s" "${NL}"
|
||||
printf "%s" "${NL}"
|
||||
printf "❌ Control character : '%s'. %b" "${disallowed_ctrl}" "${NL}"
|
||||
printf "❌ in argument : '%s'. %b" "${input}" "${NL}"
|
||||
printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %b" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
} >> "${LOG_ERR}"
|
||||
|
||||
case "${VAR_IN_DIALOG_WR}" in
|
||||
box ) dialog_box_cleaner ;;
|
||||
gauge ) dialog_gauge_cleaner ;;
|
||||
esac
|
||||
printf "%s❌ Control character : '%s'. %s%s" "${RED}" "${disallowed_ctrl}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ in argument : '%s'. %s%s" "${RED}" "${input}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %s%s" "${RED}" "${RES}" "${NL}" >&2
|
||||
|
||||
printf "%b❌ Control character : '%s'. %b%b" "${RED}" "${disallowed_ctrl}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ in argument : '%s'. %b%b" "${RED}" "${input}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
# shellcheck disable=SC2162
|
||||
read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m'
|
||||
exit "${ERR_UNSAFE_CHARACTER}"
|
||||
@@ -71,18 +73,18 @@ sanitize_arg() {
|
||||
disallowed=$(printf '%s' "${input}" | tr -d "${allowed}")
|
||||
if [[ -n ${disallowed} ]]; then
|
||||
{
|
||||
printf "❌ Invalid character : '%s'. %s" "${disallowed//?/& }" "${NL}"
|
||||
printf "❌ in argument : '%s'. %s" "${input}" "${NL}"
|
||||
printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %s" "${NL}"
|
||||
printf "%s" "${NL}"
|
||||
printf "❌ Invalid character : '%s'. %b" "${disallowed//?/& }" "${NL}"
|
||||
printf "❌ in argument : '%s'. %b" "${input}" "${NL}"
|
||||
printf "❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %b" "${NL}"
|
||||
printf "%b" "${NL}"
|
||||
} >> "${LOG_ERR}"
|
||||
case "${VAR_IN_DIALOG_WR}" in
|
||||
box ) dialog_box_cleaner ;;
|
||||
gauge ) dialog_gauge_cleaner ;;
|
||||
esac
|
||||
printf "%s❌ Invalid character : '%s'. %s%s" "${RED}" "${disallowed//?/& }" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ in argument : '%s'. %s%s" "${RED}" "${input}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %s%s" "${RED}" "${RES}" "${NL}" >&2
|
||||
printf "%s❌ Invalid character : '%s'. %b%b" "${RED}" "${disallowed//?/& }" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ in argument : '%s'. %b%b" "${RED}" "${input}" "${RES}" "${NL}" >&2
|
||||
printf "%b❌ Allowed Characters : 'a-z A-Z 0-9 . _ / = [ ] : \" - + space' %b%b" "${RED}" "${RES}" "${NL}" >&2
|
||||
# shellcheck disable=SC2162
|
||||
read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m'
|
||||
exit "${ERR_UNSAFE_CHARACTER}"
|
||||
|
||||
@@ -30,14 +30,14 @@ arg_priority_check() {
|
||||
if [[ -n "${VAR_PRIORITY}" ]]; then
|
||||
renice "${VAR_PRIORITY}" -p "$$" > /dev/null 2>&1
|
||||
var=$(ps -o ni= -p $$) > /dev/null 2>&1
|
||||
do_log "info" "file_only" "New renice value: '${var}'."
|
||||
do_log "info" "tty" "New renice value: '${var}'."
|
||||
fi
|
||||
|
||||
### Check if ionice PRIORITY is set and adjust ionice priority.
|
||||
if [[ -n "${VAR_REIONICE_CLASS}" ]]; then
|
||||
ionice -c"${VAR_REIONICE_CLASS}" -n"${VAR_REIONICE_PRIORITY}" -p "$$"
|
||||
var=$(ionice -p $$) > /dev/null 2>&1
|
||||
do_log "info" "file_only" "New ionice value: '${var}'."
|
||||
do_log "info" "tty" "New ionice value: '${var}'."
|
||||
fi
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
@@ -37,6 +37,7 @@ nuke_passphrase() {
|
||||
### Turn on tracing again
|
||||
[[ "${VAR_DEBUG_TRACE,,}" == "true" ]] && set -x
|
||||
|
||||
# shellcheck disable=SC2312
|
||||
var_salt=$(tr -dc 'A-Za-z0-9' < /dev/random | head -c 16)
|
||||
|
||||
### No tracing for security reasons
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
# SPDX-PackageName: CISS.debian.installer
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
guard_sourcing
|
||||
|
||||
#######################################
|
||||
# Terminal cleaner for Dialog Wrappers.
|
||||
# Arguments:
|
||||
|
||||
Reference in New Issue
Block a user