#!/bin/bash # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # 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.; # 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 and set up the minimum required tools for the next installation steps. # Globals: # TARGET # Arguments: # None # Returns: # 0: on success ####################################### minimal_toolset() { ### Declare Arrays, HashMaps, and Variables. # shellcheck disable=SC2154 declare -A hmp_tool_pkg=( [awk]="gawk" [busybox]="busybox" [cat]="coreutils" [chmod]="coreutils" [chown]="coreutils" [chpasswd]="passwd" [chsh]="passwd" [cp]="coreutils" [cryptsetup]="cryptsetup-initramfs" [echo]="coreutils" [grep]="grep" [ip]="iproute2" [ln]="coreutils" [mkdir]="coreutils" [ping]="iputils-ping" [sed]="sed" [sudo]="sudo" [update-initramfs]="initramfs-tools" [zsh]="zsh" [lsblk]="util-linux" [blkid]="util-linux" [mount]="util-linux" [umount]="util-linux" [findmnt]="util-linux" [parted]="parted" [fdisk]="fdisk" [tar]="tar" [gzip]="gzip" [curl]="curl" [wget]="wget" [tree]="tree" [lsb_release]="lsb-release" [btrfs]="btrfs-progs" [e2label]="e2fsprogs" [tune2fs]="e2fsprogs" [fsck]="e2fsprogs" [base64]="coreutils" [xxd]="vim-common" [jq]="jq" [zstd]="zstd" ) declare -a ary_missing_pkgs=() ary_unique_pkgs=() declare -r var_logfile="${DIR_LOG}/4090_minimal_toolset_install.log" declare var_bin="" var_bin="" ### Installation most basic packages. do_in_target "${TARGET}" apt-get install -y --no-install-recommends locales tzdata debconf ### Collecting missing binaries. for var_bin in "${!hmp_tool_pkg[@]}"; do if ! do_in_target_script "${TARGET}" "command -v ${var_bin} >/dev/null"; then ary_missing_pkgs+=("${hmp_tool_pkg[${var_bin}]}") fi done do_log "debug" "file_only" "4090() [ary_missing_pkgs]='${ary_missing_pkgs[*]}'." ### Installing unique list of packages if ((${#ary_missing_pkgs[@]})); then # shellcheck disable=SC2312 mapfile -t ary_unique_pkgs < <(printf '%s\n' "${ary_missing_pkgs[@]}" | sort -u) do_log "debug" "file_only" "4090() [ary_unique_pkgs]='${ary_unique_pkgs[*]}'." # shellcheck disable=SC2312 # do_in_target "${TARGET}" apt-get install -y --no-install-recommends "${ary_unique_pkgs[@]}" 2>&1 | tee -a "${var_logfile}" do_in_target "${TARGET}" script -q -c "apt-get install -y --no-install-recommends ${ary_unique_pkgs[*]}" /dev/null 2>&1 | tee -a "${var_logfile}" fi ### Ensure systemd and machine-id are in place if ! do_in_target_script "${TARGET}" "command -v systemctl >/dev/null"; then do_log "info" "file_only" "4090() 'systemctl' NOT found, installing 'systemd' and dependencies." do_in_target "${TARGET}" apt-get install -y --no-install-recommends systemd systemd-sysv dbus else do_log "info" "file_only" "4090() 'systemctl' found, skipping installation of systemd." fi ### Generate machine-id if missing if ! do_in_target_script "${TARGET}" "[[ -s /etc/machine-id ]]"; then do_log "info" "file_only" "4090() Generating /etc/machine-id via systemd-machine-id-setup." do_in_target "${TARGET}" systemd-machine-id-setup else do_log "info" "file_only" "4090() Existing 'machine-id' found, no action needed." fi return 0 } # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh