V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m36s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m36s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
82
lib/0080_trap_int.sh
Normal file
82
lib/0080_trap_int.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/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
|
||||
|
||||
#######################################
|
||||
# Restart Dialog Wrapper in case of unintentional SIGINT.
|
||||
# Arguments:
|
||||
# $1: Dialog Wrapper in use.
|
||||
#######################################
|
||||
restart_dialog() {
|
||||
trap 'trap_int' INT
|
||||
trap 'trap_err "$?" "${BASH_SOURCE[0]}" "${LINENO}" "${FUNCNAME[0]:-main}" "${BASH_COMMAND}"' ERR
|
||||
case "$1" in
|
||||
box ) dialog_box ;;
|
||||
gauge ) dialog_gauge ;;
|
||||
* ) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
#######################################
|
||||
# Trap function to be called on 'SIGINT'.
|
||||
# Globals:
|
||||
# ERR_TRAPPED_SIG_INT
|
||||
# VAR_IN_DIALOG_WR
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# 0: In case of unintentional SIGINT.
|
||||
#######################################
|
||||
trap_int() {
|
||||
case "${VAR_IN_DIALOG_WR}" in
|
||||
box ) dialog_box_cleaner; declare var_helper_dialog=box ;;
|
||||
gauge ) dialog_gauge_cleaner; declare var_helper_dialog=gauge ;;
|
||||
* ) declare var_helper_dialog=false ;;
|
||||
esac
|
||||
|
||||
trap '' ERR 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
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
elif [[ "${var_helper_dialog}" == gauge ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
else
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
case "${answer,,}" in
|
||||
y|yes)
|
||||
printf "\e[91mCISS.debian.installer caught an INT. SIGINT confirmed by User, exiting Installer. \e[0m\n" >&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
|
||||
if [[ "${var_helper_dialog}" == box ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
elif [[ "${var_helper_dialog}" == gauge ]]; then
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
else
|
||||
restart_dialog "${var_helper_dialog}"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
Reference in New Issue
Block a user