V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 53s

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-09-05 21:35:38 +02:00
parent 72a84b7925
commit d0b363d7d4
19 changed files with 237 additions and 123 deletions

View File

@@ -13,54 +13,64 @@
guard_sourcing
#######################################
# Check for required Deb Packages to run the script.
# Check for required deb packages to run the script.
# Globals:
# VAR_AUTO_INSTALL
# Arguments:
# None
#######################################
check_pkgs() {
apt-get update -y > /dev/null 2>&1
# TODO: Only activate in case CISS.debian.live.builder does not include the following packages as per default.
### Define HashMap: command -> package
### Declare Arrays, HashMaps, and Variables.
# shellcheck disable=SC2154
#declare -A hmp_command_packages=(
# [apt-transport-https]=apt-transport-https
# [bzip2]=bzip2
# [ca-certificates]=ca-certificates
# [curl]=curl
# [expect]=expect
# [fdisk]=fdisk
# [gdisk]=gdisk
# [git]=git
# [gpg]=gnupg
# [lsb_release]=lsb-release
# [mkfs.btrfs]=btrfs-progs
# [mkfs.ext4]=e2fsprogs
# [mkfs.fat]=dosfstools
# [mkswap]=util-linux
# [mkfs.xfs]=xfsprogs
# [parted]=parted
# [pwgen]=pwgen
# [tar]=tar
# [wget]=wget
# [whois]=whois
# [xz]=xz-utils
# [yq]=yq
#)
declare -A hmp_command_packages=(
[apt-transport-https]=apt-transport-https
[bzip2]=bzip2
[ca-certificates]=ca-certificates
[curl]=curl
[expect]=expect
[fdisk]=fdisk
[gdisk]=gdisk
[git]=git
[gpg]=gnupg
[lsb_release]=lsb-release
[mkfs.btrfs]=btrfs-progs
[mkfs.ext4]=e2fsprogs
[mkfs.fat]=dosfstools
[mkswap]=util-linux
[mkfs.xfs]=xfsprogs
[parted]=parted
[pwgen]=pwgen
[tar]=tar
[wget]=wget
[whois]=whois
[xz]=xz-utils
[yq]=yq
)
declare -a ary_missing_pkgs=() ary_unique_pkgs=()
declare var_cmd=""
### Iterate over HashMap
#declare var_cmd var_pkg
#for var_cmd in "${!hmp_command_packages[@]}"; do
# var_pkg="${hmp_command_packages[${var_cmd}]}"
# if ! command -v "${var_cmd}" &>/dev/null; then
# apt-get install -y --no-install-recommends "${var_pkg}"
# do_log "info" "file_only" "Installing ${var_pkg} done."
# else
# do_log "info" "file_only" "${var_cmd} already installed."
# fi
#done
### Collecting missing binaries.
for var_cmd in "${!hmp_command_packages[@]}"; do
if ! command -v "${var_cmd}" &>/dev/null; then
ary_missing_pkgs+=("${hmp_command_packages[${var_cmd}]}")
fi
done
do_log "debug" "file_only" "0030() [ary_missing_pkgs]='${ary_missing_pkgs[*]}'."
### Installing unique list of packages.
apt-get update > /dev/null 2>&1
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" "0030() [ary_unique_pkgs]='${ary_unique_pkgs[*]}'."
apt-get install -y --no-install-recommends --no-install-suggests "${ary_unique_pkgs[*]}" 2>&1
fi
if [[ -z "$(command -v debootstrap || true)" ]]; then
if grep -RqsE '^[[:space:]]*deb .*backports' /etc/apt/sources.list /etc/apt/sources.list.d; then
@@ -76,6 +86,6 @@ check_pkgs() {
if ! "${VAR_AUTO_INSTALL}"; then apt-get install -y --no-install-recommends dialog; fi
fi
return 0
guard_dir && return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh

View File

@@ -228,7 +228,7 @@ trap_err() {
case "${VAR_IN_DIALOG_WR}" in
box ) dialog_box_cleaner ;;
gauge ) dialog_gauge_cleaner ;;
text ) dialog_text_cleaner ;;
text ) dialog_text_cleaner ;;
esac
calculate_runtime

View File

@@ -54,9 +54,8 @@ generate_salt() {
read_password_file() {
declare -r var_input_file="${1}"
declare -n var_output_file="${2}"
declare -a lines=()
declare -a ary_lines=()
### TODO: PASSWORD REMINDER START
guard_trace on
if [[ ! -f "${var_input_file}" ]]; then
@@ -66,16 +65,16 @@ read_password_file() {
fi
mapfile -t lines < "${var_input_file}"
mapfile -t ary_lines < "${var_input_file}"
if (( ${#lines[@]} != 1 )); then
if (( ${#ary_lines[@]} != 1 )); then
do_log "fatal" "file_only" "0104() Password file '${var_input_file}' MUST contain exactly one line."
return "${ERR_READ_PASS_FILE}"
fi
var_output_file="${lines[0]}"
var_output_file="${ary_lines[0]}"
### Trim leading and trailing whitespace.
var_output_file="${var_output_file#"${var_output_file%%[![:space:]]*}"}" ### leading
var_output_file="${var_output_file%"${var_output_file##*[![:space:]]}"}" ### trailing
@@ -87,7 +86,6 @@ read_password_file() {
fi
### TODO: PASSWORD REMINDER STOP
guard_trace off
sync
@@ -104,7 +102,7 @@ read_password_file() {
sync
unset lines
unset ary_lines
return 0
}