Files
CISS.debian.installer/lib/cdi_0110_interactive/0110_check_kernel.sh
Marc S. Weidner 053a06d7e1
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 54s
V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
2025-08-05 20:32:52 +02:00

88 lines
3.1 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
#######################################
# Kernel Image Selector.
# Globals:
# VAR_KERNEL
# VAR_KERNEL_SRT
# VAR_KERNEL_TMP
# Arguments:
# None
# Returns:
# 0: on success
# 42: On sorting Error.
#######################################
check_kernel() {
declare -i counter=1
declare first_string="" line="" name="" options="" var_cpu_vendor=""
# shellcheck disable=SC2312
var_cpu_vendor=$(</proc/cpuinfo grep 'vendor_id' | head -n1 | cut -d: -f2 | xargs)
case "${var_cpu_vendor}" in
*AuthenticAMD*)
# shellcheck disable=SC2312
apt-cache search linux-image | grep linux-image | grep amd64 | grep -v "meta-package" | grep -v "dbg" | grep -v "template" >> "${VAR_KERNEL_TMP}"
;;
*GenuineIntel*)
# shellcheck disable=SC2312
apt-cache search linux-image | grep linux-image | grep arm64 | grep -v "meta-package" | grep -v "dbg" | grep -v "template" >> "${VAR_KERNEL_TMP}"
;;
*) do_log "info" "file_only" "4140() Unknown or unsupported CPU vendor: '${var_cpu_vendor}', skipping." ;;
esac
sort --output="${VAR_KERNEL_SRT}" "${VAR_KERNEL_TMP}" || {
printf "❌ Error 0110_check_kernel.sh Line 52 sort failed\n" >&2
# shellcheck disable=SC2162
read -p $'\e[92m✅ Press \'ENTER\' to exit the script ... \e[0m'
return 42
}
while IFS= read -r line; do
first_string=${line%% *}
name=${first_string#linux-image-}
options+=("${name}" "${counter}" off)
((counter++))
done < "${VAR_KERNEL_SRT}"
export NCURSES_NO_ALTSCREEN=1
# shellcheck disable=SC2034
if VAR_KERNEL=$(dialog \
--no-collapse \
--ascii-lines \
--clear \
--help-button \
--backtitle "CISS.debian.installer" \
--title "Select the Kernel for the CISS.debian.installer" \
--radiolist "Kernel available \n *+bpo* : Debian Backported Kernel \n *cloud* : Special lightweight images for KVM \n *unsigned* : Unsigned Kernel \n *preempt_rt* : Special Kernel for real-time-computing \n Not unsigned marked are MS signed Kernel for Secure Boot \n" 0 0 "${options[@]}" 3>&1 1>&2 2>&3 3>&-); then
clear
[[ "${VAR_KERNEL}" != linux-image-* ]] && VAR_KERNEL="linux-image-${VAR_KERNEL}"
do_log "info" "file_only" "0110() Kernel image selected interactively: '${VAR_KERNEL}'."
else
clear
VAR_KERNEL=""
fi
return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh