V8.00.000.2025.06.17

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-29 16:04:46 +02:00
parent 855af7f0be
commit c483e008f4
14 changed files with 526 additions and 191 deletions

View File

@@ -0,0 +1,323 @@
#!/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
#######################################
# Validates var_mount_path to be processed.
# Arguments:
# 1 var_mount_path
# Returns:
# 0: Skip mounting
# 1: Process mount
#######################################
skip_path() {
declare -a ary_skip=( "/" "/boot" "/boot/efi" "/recovery" )
declare p=""
for p in "${ary_skip[@]}"; do [[ "$1" == "${p}" ]] && return 0; done
return 1
}
#######################################
# Function to create the mount command, incl. mount path and options, and mount the respective device.
# Globals:
# ERR_MOUNTING_DEV
# TARGET
# Arguments:
# 1: MOUNT_PATH
# 2: MOUNT_DEVICE
# 3: MOUNT_OPTIONS
# Returns:
# 0: on success
#######################################
mount_with_dir() {
declare var_mount_path="$1" var_mount_device="$2" var_mount_options="${3:-}"
declare -a ary_cmd=(mount)
if [[ "${var_mount_device}" =~ ^[0-9a-fA-F-]{8,}$ ]]; then
if [[ -e "/dev/disk/by-uuid/${var_mount_device}" ]]; then
var_mount_device="/dev/disk/by-uuid/${var_mount_device}"
else
do_log "error" "file_only" "3280() FS-UUID for mount path: '${var_mount_device}' not found by '/dev/disk/by-uuid/${var_mount_device}'."
return "${ERR_MOUNTING_DEV}"
fi
fi
[[ "${var_mount_path}" != "/" ]] && mkdir -p "${TARGET}${var_mount_path}"
### Build the command in an array to keep word boundaries intact.
[[ -n "${var_mount_options}" ]] && ary_cmd+=("-o" "${var_mount_options}")
ary_cmd+=("${var_mount_device}" "${TARGET}${var_mount_path}")
safe_exec "${ary_cmd[@]}" "${ERR_MOUNTING_DEV}" || return
do_log "debug" "file_only" "3280() [safe_exec ${ary_cmd[*]} ${ERR_MOUNTING_DEV}]."
do_log "info" "file_only" "3280() Mounted: '${var_mount_device}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
return 0
}
#######################################
# Device Path Resolver.
# Outputs '/dev/mapper/<encryption_label>'
# Outputs '/dev/<dev><partition>'
# Arguments:
# 1: Device
# 2: Partition
# 3: Boolean Encryption
# 4: Encryption Label
#######################################
resolve_device() {
declare local_var_dev="$1" local_var_partition="$2" local_var_enc_boolean="$3" local_var_enc_label="$4"
if [[ "${local_var_enc_boolean,,}" == "true" ]]; then
printf '/dev/mapper/%s' "${local_var_enc_label}"
else
printf '/dev/%s%s' "${local_var_dev}" "${local_var_partition}"
fi
}
#######################################
# Validates btrfs compression algo and level.
# Arguments:
# 1 var_fs_btrfs_compress
# 2 var_fs_btrfs_level
# Returns:
# 0: Valid combination.
# 1: Invalid combination.
#######################################
validate_btrfs_compression() {
declare var_algo="$1" var_level="$2"
case "${var_algo}:${var_level}" in
zstd:|zstd:[0-9]|zstd:1[0-9]|zstd:2[0-2]|lzo:) return 0 ;;
*) do_log "error" "file_only" "3280() Invalid btrfs compression: '${var_algo}:${var_level}'"; return "${ERR_BTRFS_OPTION}" ;;
esac
}
#######################################
# Function for mounting all partitions for debootstrap, including the generation of btrfs subvolumes.
# Globals:
# HMP_MOUNTPATH_DEV
# TARGET
# VAR_RECIPE_STRING
# VAR_SAFE_MNT_BASE
# VAR_SETUP_PART
# Arguments:
# None
# Returns:
# 0: on success
# ERR_BTRFS_INITPH
# ERR_BTRFS_OPTION
# ERR_BTRFS_SUBVOL
# ERR_MOUNTING_DEV
# ERR_MOUNTING_ROOT
#######################################
mount_partition() {
### Declare Arrays, HashMaps, and Variables.
declare -Ag HMP_FSTAB_MOUNT_OPTS # Used in: 4040() - [Mount Path:Mount Options].
declare -r var_mount_path_root="/"
declare var_path="" var_dev="" var_part="" \
var_fs_btrfs_compress="" var_fs_btrfs_level="" var_fs_btrfs_subvolume="" var_fs_btrfs_snapshot="" \
var_encryption_enable="" var_encryption_label="" var_fs_options="" var_fs_version="" var_mount_path="" \
var_mount_options="" var_snapshot="" var_mount_optsnap="" var_fs_uuid=""
declare -a ary_devs=() ary_parts=()
### Mount "/"-filesystem
if [[ -n "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" ]]; then
mount_with_dir "${var_mount_path_root}" "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" || return "${ERR_MOUNTING_DEV}"
else
do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_PATH_FSUUID'."
return "${ERR_MOUNTING_ROOT}"
fi
#if [[ -n "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" ]]; then
# mount_with_dir "${var_mount_path_root}" "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" || return "${ERR_MOUNTING_DEV}"
#else
# do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
# return "${ERR_MOUNTING_ROOT}"
#fi
### Ensure order of "/boot" and "/boot/efi"
for var_path in "/boot" "/boot/efi"; do
if [[ -n "${HMP_PATH_FSUUID["${var_path}"]}" ]]; then
mount_with_dir "${var_path}" "${HMP_PATH_FSUUID["${var_path}"]}" || return "${ERR_MOUNTING_DEV}"
else
do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_PATH_FSUUID'."
fi
done
#for var_path in "/boot" "/boot/efi"; do
# if [[ -n "${HMP_MOUNTPATH_DEV[${var_path}]}" ]]; then
# mount_with_dir "${var_path}" "${HMP_MOUNTPATH_DEV[${var_path}]}" || return "${ERR_MOUNTING_DEV}"
# else
# do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
# fi
#done
### Iterate over all devices in the recipe.
# shellcheck disable=SC2312
readarray -t ary_devs < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev | keys | .[]" "${VAR_SETUP_PART}")
for var_dev in "${ary_devs[@]}"; do
### Iterate over all partitions for this device.
# shellcheck disable=SC2312
readarray -t ary_parts < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev} | keys | .[]" "${VAR_SETUP_PART}")
for var_part in "${ary_parts[@]}"; do
### Extract parameters from YAML.
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
var_fs_btrfs_level=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.level" "${VAR_SETUP_PART}")
var_fs_btrfs_snapshot=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.snapshot" "${VAR_SETUP_PART}")
var_encryption_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
var_fs_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.options" "${VAR_SETUP_PART}")
var_fs_version=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.version" "${VAR_SETUP_PART}")
var_mount_path=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.path" "${VAR_SETUP_PART}")
var_mount_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.options" "${VAR_SETUP_PART}")
var_mount_optsnap=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.optsnap" "${VAR_SETUP_PART}")
### Skip already mounted paths ("/", "/boot", "/boot/efi") and skip ("/recovery")
skip_path "${var_mount_path}" && continue
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
var_fs_uuid="${HMP_PATH_FSUUID["${var_path}"]}"
if [[ "${var_mount_path,,}" == "swap" ]]; then
#var_fs_label=$(get_label "${var_mount_path}" "${var_fs_version}" "file")
cryptsetup open --type plain --key-file /dev/random \
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
#--sector-size 4096 "/dev/disk/by-label/${var_fs_label}" "${var_encryption_label}"
mkswap "/dev/mapper/${var_encryption_label}"
do_log "debug" "file_only" "3280() [mkswap /dev/mapper/${var_encryption_label}]."
swapon "/dev/mapper/${var_encryption_label}"
do_log "debug" "file_only" "3280() [swapon /dev/mapper/${var_encryption_label}]."
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
continue
elif [[ "${var_mount_path,,}" == "/tmp" ]]; then
cryptsetup open --type plain --key-file /dev/random \
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
mkdir -p "${TARGET}/tmp"
echo "safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 /dev/mapper/${var_encryption_label} ${ERR_MOUNTING_DEV}"
safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 "/dev/mapper/${var_encryption_label}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
### Build the command in an array to keep word boundaries intact
declare -a ary_cmd2=(mount)
ary_cmd2+=("/dev/mapper/${var_encryption_label}" "${TARGET}${var_mount_path}")
safe_exec "${ary_cmd2[@]}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
continue
fi
#var_resolved_dev=$(resolve_device "${var_dev}" "${var_part}" "${var_encryption_enable}" "${var_encryption_label}")
if [[ "${var_fs_version,,}" == "btrfs" ]]; then
var_fs_btrfs_subvolume=$(get_label "${var_mount_path}" "${var_fs_version}" "sub")
### Mount toplevel (subvolid=0) without extra options.
declare -a ary_cmd_mount=(mount -o "subvolid=0" "${var_fs_uuid}" "${VAR_SAFE_MNT_BASE}")
safe_exec "${ary_cmd_mount[@]}" "${ERR_BTRFS_INITPH}" || return "${ERR_BTRFS_INITPH}"
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}"
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}]."
do_log "info" "file_only" "3280() btrfs subvolid=0 created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
var_snapshot=$(get_label "${var_mount_path}" "${var_fs_version}" "snap")
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_snapshot}" || return "${ERR_BTRFS_SUBVOL}"
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_snapshot}]."
do_log "info" "file_only" "3280() btrfs subvolid=${var_snapshot} created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
fi
umount "${VAR_SAFE_MNT_BASE}"
do_log "info" "file_only" "3280() btrfs subvolume umount: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
fi
case "${var_fs_version,,}:${var_encryption_enable,,}" in
btrfs:*)
validate_btrfs_compression "${var_fs_btrfs_compress}" "${var_fs_btrfs_level}" || return "${ERR_BTRFS_OPTION}"
declare var_btrfs_compression_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
[[ -n "${var_mount_options}" ]] && var_btrfs_compression_options+=",${var_mount_options},subvol=${var_fs_btrfs_subvolume}"
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_compression_options[*]}"
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_compression_options}" || return "${ERR_MOUNTING_DEV}"
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
### Preparing "/.snapshot"-directory
mkdir -p "${TARGET}${var_mount_path}/.snapshots"
do_log "info" "file_only" "3280() Created: '${TARGET}${var_mount_path}/.snapshots'."
var_mount_optsnap="${var_mount_optsnap},subvol=${var_snapshot}"
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap[*]}"
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
mount_with_dir "${var_mount_path}/.snapshots" "${var_fs_uuid}" "${var_mount_optsnap}"
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' (Options='${var_mount_optsnap}')."
fi
;;
ext4:*)
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
;;
*) do_log "error" "file_only" "3280() Unsupported fs/encryption combination."
return "${ERR_MOUNTING_DEV}" ;;
esac
done
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_full.log"
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
done
return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh

View File

@@ -201,8 +201,8 @@ echo "MAIN PROGRAM SEQUENCE: partition_encryption()"
partition_encryption
echo "MAIN PROGRAM SEQUENCE: partition_formatting()"
partition_formatting
echo "MAIN PROGRAM SEQUENCE: setup_filesystem()"
setup_filesystem
#echo "MAIN PROGRAM SEQUENCE: setup_filesystem()"
#setup_filesystem
echo "MAIN PROGRAM SEQUENCE: mount_partition()"
mount_partition
echo "MAIN PROGRAM SEQUENCE: uuid_logger()"

View File

@@ -45,6 +45,7 @@ guard_sourcing
#######################################
partitioning() {
### Declare Arrays, HashMaps, and Variables.
# shellcheck disable=SC2034
declare -Ag HMP_PATH_PARTUUID # Used in: 3290() - [Mount Path:Partition UUID].
declare -Ag HMP_FSTAB_MOUNT_FTYPE # Used in: 4040() - [Mount Path:Filesystem type].
declare -Ag HMP_PATH_DEV_PART # Used in: 3220() - [Mount Path:DEV.PARTITION].
@@ -55,8 +56,8 @@ partitioning() {
declare -ag ARY_PATHS_SORTED=() # Used in: - All entries [/paths] in a mount ordering scheme.
declare var_dev="" var_part="" \
var_begin="" var_boot="" var_encryption="" var_end="" var_end_arg="" var_end_mib="" var_format="" var_fs="" var_label="" \
var_mount_path="" var_mount_true="" var_pri="" var_uuid=""
var_begin="" var_boot="" var_encryption="" var_end="" var_end_arg="" var_end_mib="" var_format="" var_fs="" \
var_label="" var_mount_path="" var_mount_true="" var_pri="" var_uuid=""
declare -a ary_devs=() ary_parts=() ary_paths_unsorted=()
@@ -181,17 +182,23 @@ partitioning() {
declare typecode="8300" # Default: Linux FS
case "${var_fs,,}" in
fat32)
typecode="EF00" ;; ### EFI System Partition
swap)
typecode="8200" ;; ### Linux SWAP
bios)
typecode="EF02" ;; ### BIOS Boot Partition
ext4|btrfs)
typecode="8300" ;; ### Linux native FS
*)
do_log "warn" "file_only" "3200() Partition: '/dev/${var_dev}${var_part}' unknown FS type: '${var_fs}', using default GPT FS '8300'."
;;
esac
if sgdisk --typecode="${var_part}:${typecode}" "/dev/${var_dev}" &>/dev/null; then
@@ -228,6 +235,7 @@ partitioning() {
### Store PARTUUID of the partition.
udevadm settle
for i in {1..10}; do
var_uuid=$(blkid -s PARTUUID -o value "/dev/${var_dev}${var_part}") && [[ -n "${var_uuid}" ]] && break
sleep 0.25
@@ -255,7 +263,6 @@ partitioning() {
fi
### Gathering information for mounting module 3280().
HMP_PATH_DEV_PART["${var_mount_path}"]="${var_dev}.${var_part}"
ary_paths_unsorted+=("${var_mount_path}")
### Gathering information for '/etc/fstab'-generation in 4040().

View File

@@ -50,14 +50,17 @@ partition_encryption() {
declare -gx VAR_CRYPT_RECOVERY="" # LUKS UUID of '/recovery'.
declare var_encryption_path="" var_dev_part="" \
var_encryption_ephemeral="" var_encryption_integrity="" var_encryption_cipher="" \
var_encryption_hash="" var_encryption_key="" var_encryption_label="" var_encryption_meta="" var_encryption_slot="" \
var_encryption_ephemeral="" var_encryption_integrity="" var_encryption_cipher="" var_encryption_hash="" \
var_encryption_key="" var_encryption_label="" var_encryption_meta="" var_encryption_slot="" \
var_encryption_pbkdf="" var_encryption_rng="" var_filesystem_label="" var_mount_path="" var_uuid="" var_fs=""
declare -a ary_luks_opts=()
for var_encryption_path in "${ARY_CRYPT_MOUNT_PATHS[@]}"; do
### Initialize Arrays and Variables
ary_luks_opts=()
### Generates physical device location.
var_dev_part="${HMP_PATH_DEV_PART["${var_encryption_path}"]}"

View File

@@ -39,6 +39,9 @@ partition_formatting() {
for var_format_path in "${ARY_FORMT_MOUNT_PATHS[@]}"; do
### Initialize Arrays and Variables
ary_opts=(); ary_fmt_opts=()
### Generates physical device location.
var_dev_part="${HMP_PATH_DEV_PART["${var_format_path}"]}"
@@ -123,9 +126,9 @@ partition_formatting() {
var_dev="${HMP_PATH_DEV_PART["${var_format_path}"]}"
var_dev="${var_dev%.*}"
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview.log"
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview.log"
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview.log"
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_3240.log"
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_3240.log"
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_3240.log"
done

View File

@@ -12,21 +12,6 @@
guard_sourcing
#######################################
# Validates var_mount_path to be processed.
# Arguments:
# 1 var_mount_path
# Returns:
# 0: Skip mounting
# 1: Process mount
#######################################
skip_path() {
declare -a ary_skip=( "/" "/boot" "/boot/efi" "/recovery" )
declare p=""
for p in "${ary_skip[@]}"; do [[ "$1" == "${p}" ]] && return 0; done
return 1
}
#######################################
# Function to create the mount command, incl. mount path and options, and mount the respective device.
# Globals:
@@ -110,7 +95,16 @@ validate_btrfs_compression() {
#######################################
# Function for mounting all partitions for debootstrap, including the generation of btrfs subvolumes.
# Globals:
# HMP_MOUNTPATH_DEV
# ARY_PATHS_SORTED
# DIR_LOG
# ERR_BTRFS_INITPH
# ERR_BTRFS_OPTION
# ERR_BTRFS_SUBVOL
# ERR_MOUNTING_DEV
# HMP_FSTAB_MOUNT_OPTS
# HMP_PATH_DEV_PART
# HMP_PATH_FSUUID
# NL
# TARGET
# VAR_RECIPE_STRING
# VAR_SAFE_MNT_BASE
@@ -128,90 +122,49 @@ validate_btrfs_compression() {
mount_partition() {
### Declare Arrays, HashMaps, and Variables.
declare -Ag HMP_FSTAB_MOUNT_OPTS # Used in: 4040() - [Mount Path:Mount Options].
declare -r var_mount_path_root="/"
declare var_path="" var_dev="" var_part="" \
var_fs_btrfs_compress="" var_fs_btrfs_level="" var_fs_btrfs_subvolume="" var_fs_btrfs_snapshot="" \
var_encryption_enable="" var_encryption_label="" var_fs_options="" var_fs_version="" var_mount_path="" \
var_mount_options="" var_snapshot="" var_mount_optsnap="" var_fs_uuid=""
declare var_mount_path="" var_dev_part="" var_dev="" var_btrfs_options="" \
var_encryption_label="" var_fs_btrfs_compress="" var_fs_btrfs_level="" var_fs_btrfs_snapshot="" \
var_fs_btrfs_subvolume="" var_fs_version="" var_mount_options="" var_mount_optsnap="" var_mount_path="" \
var_snapshot="" var_fs_uuid=""
declare -a ary_devs=() ary_parts=()
declare -a ary_cmd=() ary_cmd_mount=()
### Mount "/"-filesystem
if [[ -n "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" ]]; then
mount_with_dir "${var_mount_path_root}" "${HMP_PATH_FSUUID["${var_mount_path_root}"]}" || return "${ERR_MOUNTING_DEV}"
else
do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_PATH_FSUUID'."
return "${ERR_MOUNTING_ROOT}"
fi
for var_mount_path in "${ARY_PATHS_SORTED[@]}"; do
#if [[ -n "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" ]]; then
# mount_with_dir "${var_mount_path_root}" "${HMP_MOUNTPATH_DEV[${var_mount_path_root}]}" || return "${ERR_MOUNTING_DEV}"
#else
# do_log "error" "file_only" "3280() Root-filesystem '${var_mount_path_root}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
# return "${ERR_MOUNTING_ROOT}"
#fi
### Initialize Arrays and Variables
ary_cmd=(); ary_cmd_mount=(); var_btrfs_options=""
### Ensure order of "/boot" and "/boot/efi"
for var_path in "/boot" "/boot/efi"; do
if [[ -n "${HMP_PATH_FSUUID["${var_path}"]}" ]]; then
mount_with_dir "${var_path}" "${HMP_PATH_FSUUID["${var_path}"]}" || return "${ERR_MOUNTING_DEV}"
else
do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_PATH_FSUUID'."
fi
done
#for var_path in "/boot" "/boot/efi"; do
# if [[ -n "${HMP_MOUNTPATH_DEV[${var_path}]}" ]]; then
# mount_with_dir "${var_path}" "${HMP_MOUNTPATH_DEV[${var_path}]}" || return "${ERR_MOUNTING_DEV}"
# else
# do_log "info" "file_only" "3280() Entry '${var_path}' not found in Hashmap: 'HMP_MOUNTPATH_DEV'."
# fi
#done
### Iterate over all devices in the recipe.
# shellcheck disable=SC2312
readarray -t ary_devs < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev | keys | .[]" "${VAR_SETUP_PART}")
for var_dev in "${ary_devs[@]}"; do
### Iterate over all partitions for this device.
# shellcheck disable=SC2312
readarray -t ary_parts < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev} | keys | .[]" "${VAR_SETUP_PART}")
for var_part in "${ary_parts[@]}"; do
### Generates physical device location.
var_dev_part="${HMP_PATH_DEV_PART["${var_mount_path}"]}"
### Extract parameters from YAML.
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
var_fs_btrfs_level=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.level" "${VAR_SETUP_PART}")
var_fs_btrfs_snapshot=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.snapshot" "${VAR_SETUP_PART}")
var_encryption_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
var_fs_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.options" "${VAR_SETUP_PART}")
var_fs_version=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.version" "${VAR_SETUP_PART}")
var_mount_path=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.path" "${VAR_SETUP_PART}")
var_mount_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.options" "${VAR_SETUP_PART}")
var_mount_optsnap=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.optsnap" "${VAR_SETUP_PART}")
### Skip already mounted paths ("/", "/boot", "/boot/efi") and skip ("/recovery")
skip_path "${var_mount_path}" && continue
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
var_fs_btrfs_level=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.level" "${VAR_SETUP_PART}")
var_fs_btrfs_snapshot=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.btrfs.snapshot" "${VAR_SETUP_PART}")
var_fs_version=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.filesystem.version" "${VAR_SETUP_PART}")
var_mount_options=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.mount.options" "${VAR_SETUP_PART}")
var_mount_optsnap=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev_part}.mount.optsnap" "${VAR_SETUP_PART}")
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
var_fs_uuid="${HMP_PATH_FSUUID["${var_path}"]}"
var_fs_uuid="${HMP_PATH_FSUUID["${var_mount_path}"]}"
### Mounting of Ephemeral 'SWAP' and '/tmp' as per https://wiki.archlinux.org/title/Dm-crypt/Swap_encryption#UUID_and_LABEL
if [[ "${var_mount_path,,}" == "swap" ]]; then
#var_fs_label=$(get_label "${var_mount_path}" "${var_fs_version}" "file")
cryptsetup open --type plain --key-file /dev/random \
--offset 2048 --cipher aes-xts-plain64 --key-size 512 \
--sector-size 4096 "/dev/disk/by-uuid/${var_fs_uuid}" "${var_encryption_label}"
#--sector-size 4096 "/dev/disk/by-label/${var_fs_label}" "${var_encryption_label}"
mkswap "/dev/mapper/${var_encryption_label}"
do_log "debug" "file_only" "3280() [mkswap /dev/mapper/${var_encryption_label}]."
swapon "/dev/mapper/${var_encryption_label}"
do_log "debug" "file_only" "3280() [swapon /dev/mapper/${var_encryption_label}]."
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
### Ephemeral 'SWAP' finally mounted. Skip all other steps.
continue
elif [[ "${var_mount_path,,}" == "/tmp" ]]; then
@@ -222,29 +175,29 @@ mount_partition() {
mkdir -p "${TARGET}/tmp"
echo "safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 /dev/mapper/${var_encryption_label} ${ERR_MOUNTING_DEV}"
safe_exec mkfs.ext4 -E nodiscard,lazy_itable_init=1,lazy_journal_init=1 "/dev/mapper/${var_encryption_label}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
### Build the command in an array to keep word boundaries intact
declare -a ary_cmd2=(mount)
ary_cmd=( mount )
ary_cmd+=( "/dev/mapper/${var_encryption_label}" "${TARGET}${var_mount_path}" )
ary_cmd2+=("/dev/mapper/${var_encryption_label}" "${TARGET}${var_mount_path}")
safe_exec "${ary_cmd2[@]}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
safe_exec "${ary_cmd[@]}" "${ERR_MOUNTING_DEV}" || return "${ERR_MOUNTING_DEV}"
do_log "info" "file_only" "3280() Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
### Ephemeral '/tmp' finally mounted. Skip all other steps.
continue
fi
#var_resolved_dev=$(resolve_device "${var_dev}" "${var_part}" "${var_encryption_enable}" "${var_encryption_label}")
if [[ "${var_fs_version,,}" == "btrfs" ]]; then
var_fs_btrfs_subvolume=$(get_label "${var_mount_path}" "${var_fs_version}" "sub")
### Mount toplevel (subvolid=0) without extra options.
declare -a ary_cmd_mount=(mount -o "subvolid=0" "${var_fs_uuid}" "${VAR_SAFE_MNT_BASE}")
ary_cmd_mount=( mount -o "subvolid=0" "${var_fs_uuid}" "${VAR_SAFE_MNT_BASE}" )
safe_exec "${ary_cmd_mount[@]}" "${ERR_BTRFS_INITPH}" || return "${ERR_BTRFS_INITPH}"
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_fs_btrfs_subvolume}"
@@ -258,6 +211,7 @@ mount_partition() {
btrfs subvolume create "${VAR_SAFE_MNT_BASE}/${var_snapshot}" || return "${ERR_BTRFS_SUBVOL}"
do_log "debug" "file_only" "3280() [btrfs subvolume create ${VAR_SAFE_MNT_BASE}/${var_snapshot}]."
do_log "info" "file_only" "3280() btrfs subvolid=${var_snapshot} created: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
fi
umount "${VAR_SAFE_MNT_BASE}"
@@ -265,21 +219,23 @@ mount_partition() {
fi
case "${var_fs_version,,}:${var_encryption_enable,,}" in
case "${var_fs_version,,}" in
btrfs:*)
btrfs)
validate_btrfs_compression "${var_fs_btrfs_compress}" "${var_fs_btrfs_level}" || return "${ERR_BTRFS_OPTION}"
declare var_btrfs_compression_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
var_btrfs_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
[[ -n "${var_mount_options}" ]] && var_btrfs_compression_options+=",${var_mount_options},subvol=${var_fs_btrfs_subvolume}"
[[ -n "${var_mount_options}" ]] && var_btrfs_options+="${var_mount_options},${var_btrfs_options},subvol=${var_fs_btrfs_subvolume}"
[[ -z "${var_mount_options}" ]] && var_btrfs_options+="${var_btrfs_options},subvol=${var_fs_btrfs_subvolume}"
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_compression_options[*]}"
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_options}"
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_compression_options}" || return "${ERR_MOUNTING_DEV}"
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_btrfs_options}" || return "${ERR_MOUNTING_DEV}"
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_btrfs_options}')."
if [[ "${var_fs_btrfs_snapshot}" == "true" ]]; then
@@ -290,31 +246,43 @@ mount_partition() {
var_mount_optsnap="${var_mount_optsnap},subvol=${var_snapshot}"
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap[*]}"
do_log "debug" "file_only" "3280() Stored in HashMap [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap}"
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}/.snapshots' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]}'."
mount_with_dir "${var_mount_path}/.snapshots" "${var_fs_uuid}" "${var_mount_optsnap}"
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}/.snapshots' (Options='${var_mount_optsnap}')."
fi
;;
ext4:*)
ext4)
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
;;
*) do_log "error" "file_only" "3280() Unsupported fs/encryption combination."
return "${ERR_MOUNTING_DEV}" ;;
fat32)
### Gathering information for '/etc/fstab'-generation in 4040().
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_mount_options}"
do_log "debug" "file_only" "3280() [HMP_FSTAB_MOUNT_OPTS] : '${var_mount_path}' -> '${HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]}'."
mount_with_dir "${var_mount_path}" "${var_fs_uuid}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
do_log "info" "file_only" "3280() Mounted: '${var_fs_uuid}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
;;
esac
done
var_dev="${HMP_PATH_DEV_PART["${var_mount_path}"]}"
var_dev="${var_dev%.*}"
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_full.log"
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_full.log"
lsblk -o NAME,MAJ:MIN,FSTYPE,FSVER,SIZE,UUID,MOUNTPOINT,PATH "/dev/${var_dev}" >| "${DIR_LOG}/${var_dev}_overview_3280.log"
printf "%b" "${NL}" >> "${DIR_LOG}/${var_dev}_overview_3280.log"
lsblk "/dev/${var_dev}" >> "${DIR_LOG}/${var_dev}_overview_3280.log"
done

View File

@@ -27,10 +27,10 @@ guard_sourcing
func_debootstrap() {
# shellcheck disable=SC2312
if debootstrap --arch="${architecture}" "${distribution}" "${TARGET}" https://deb.debian.org/debian | tee "${LOG_DBS}"; then
do_log "info" "file_only" "4000() Command: [debootstrap --arch=${architecture} ${distribution} '${TARGET}' https://deb.debian.org/debian] successful."
do_log "info" "file_only" "4000() [debootstrap --arch=${architecture} ${distribution} '${TARGET}' https://deb.debian.org/debian] successful."
return 0
else
do_log "emergency" "file_only" "4000() Command: [debootstrap --arch=${architecture} ${distribution} '${TARGET}' https://deb.debian.org/debian] failed."
do_log "emergency" "file_only" "4000() [debootstrap --arch=${architecture} ${distribution} '${TARGET}' https://deb.debian.org/debian] failed."
return "${ERR_DEBOOTSTRAP}"
fi
}

View File

@@ -24,7 +24,8 @@ guard_sourcing
# PWD
# SHELLOPTS
# UID
# VAR_GIT_HEAD
# VAR_GIT_REL
# VAR_RESOURCES
# VAR_SYSTEM
# VAR_VERSION
# Arguments:
@@ -51,6 +52,7 @@ debug_trace_header() {
printf "\e[97m+\e[0m\e[92m%s: Hostname : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${HOSTNAME}"
printf "\e[97m+\e[0m\e[92m%s: Hostsystem : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_SYSTEM}"
printf "\e[97m+\e[0m\e[92m%s: Script name : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$0"
printf "\e[97m+\e[0m\e[92m%s: System Resources : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_RESOURCES}"
printf "\e[97m+\e[0m\e[92m%s: Argument Counter : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_counter}"
printf "\e[97m+\e[0m\e[92m%s: Argument String Original : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_string}"
printf "\e[97m+\e[0m\e[92m%s: Script PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$$"

View File

@@ -25,7 +25,8 @@ guard_sourcing
# PWD
# SHELLOPTS
# UID
# VAR_GIT_HEAD
# VAR_GIT_REL
# VAR_RESOURCES
# VAR_SYSTEM
# VAR_VERSION
# Arguments:
@@ -52,6 +53,7 @@ debug_trap_header() {
printf "\e[97m+\e[0m\e[92m%s: Hostname : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${HOSTNAME}"
printf "\e[97m+\e[0m\e[92m%s: Hostsystem : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_SYSTEM}"
printf "\e[97m+\e[0m\e[92m%s: Script name : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$0"
printf "\e[97m+\e[0m\e[92m%s: System Resources : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${VAR_RESOURCES}"
printf "\e[97m+\e[0m\e[92m%s: Argument Counter : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_counter}"
printf "\e[97m+\e[0m\e[92m%s: Argument String Original : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "${arg_string}"
printf "\e[97m+\e[0m\e[92m%s: Script PID : %s \e[0m\n" "$(date -u +%Y-%m-%dT%H:%M:%S.%4N%z)" "$$"

View File

@@ -15,6 +15,7 @@ guard_sourcing
#######################################
# Print Error Message for Trap on 'ERR' in '${ERROR_LOG}'.
# Globals:
# BASHOPTS
# BASH_VERSINFO
# EPOCHREALTIME
# ERRCMMD
@@ -30,13 +31,15 @@ guard_sourcing
# LOG_VAR
# NL
# SECONDS
# SHELLOPTS
# UID
# VAR_ARG_SANITIZED
# VAR_DEBUG_TRACE
# VAR_DEBUG_TRAP
# VAR_GIT_HEAD
# VAR_GIT_REL
# VAR_PARAM_COUNT
# VAR_PARAM_STRNG
# VAR_RESOURCES
# VAR_SYSTEM
# VAR_VERSION
# Arguments:
@@ -64,9 +67,12 @@ print_file_err() {
printf "❌ Command : %s %b" "${ERRCMMD}" "${NL}"
printf "❌ Script PID : %s %b" "${$}" "${NL}"
printf "❌ Script Runtime : %s %b" "${SECONDS}" "${NL}"
printf "❌ System Resources : %s %b" "${VAR_RESOURCES}" "${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}"
printf "❌ BASHOPTS : %s %b" "${BASHOPTS}" "${NL}"
printf "❌ SHELLOPTS : %s %b" "${SHELLOPTS}" "${NL}"
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
printf "❌ Vars Dump saved at : %s %b" "${LOG_VAR}" "${NL}"
printf "❌ less -R %s %b" "${LOG_VAR}" "${NL}"
@@ -86,6 +92,7 @@ print_file_err() {
#######################################
# Print Error Message for Trap on 'ERR' on Terminal.
# Globals:
# BASHOPTS
# BASH_VERSINFO
# EPOCHREALTIME
# ERRCMMD
@@ -100,14 +107,18 @@ print_file_err() {
# LOG_TRC
# LOG_VAR
# NL
# RED
# RES
# SECONDS
# SHELLOPTS
# UID
# VAR_ARG_SANITIZED
# VAR_DEBUG_TRACE
# VAR_DEBUG_TRAP
# VAR_GIT_HEAD
# VAR_GIT_REL
# VAR_PARAM_COUNT
# VAR_PARAM_STRNG
# VAR_RESOURCES
# VAR_SYSTEM
# VAR_VERSION
# Arguments:
@@ -134,9 +145,12 @@ print_scr_err() {
printf "%b❌ Command : %s %b%b" "${RED}" "${ERRCMMD}" "${RES}" "${NL}"
printf "%b❌ Script PID : %s %b%b" "${RED}" "${$}" "${RES}" "${NL}"
printf "%b❌ Script Runtime : %s %b%b" "${RED}" "${SECONDS}" "${RES}" "${NL}"
printf "%b❌ System Resources : %s %b%b" "${RED}" "${VAR_RESOURCES}" "${RES}" "${NL}"
printf "%b❌ Arguments Counter : %s %b%b" "${RED}" "${VAR_PARAM_COUNT}" "${RES}" "${NL}"
printf "%b❌ Arguments Original : %s %b%b" "${RED}" "${VAR_PARAM_STRNG}" "${RES}" "${NL}"
printf "%b❌ Arguments Sanitized : %s %b%b" "${RED}" "${VAR_ARG_SANITIZED}" "${RES}" "${NL}"
printf "%b❌ BASHOPTS : %s %b%b" "${RED}" "${BASHOPTS}" "${RES}" "${NL}"
printf "%b❌ SHELLOPTS : %s %b%b" "${RED}" "${SHELLOPTS}" "${RES}" "${NL}"
printf "%b❌ Error Log saved at : %s %b%b" "${RED}" "${LOG_ERR}" "${RES}" "${NL}"
printf "%b❌ cat %s %b%b" "${RED}" "${LOG_ERR}" "${RES}" "${NL}"
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then
@@ -206,6 +220,7 @@ trap_err() {
declare -g ERRLINE="$3"
declare -g ERRFUNC="$4"
declare -g ERRCMMD="$5"
# shellcheck disable=SC2034
declare -g ERRTRAP="true"
trap - DEBUG ERR INT TERM

View File

@@ -99,21 +99,30 @@ trap_exit_zero() {
#######################################
# Trap on Exit Handler for 'Non-0' Exit-Code.
# Globals:
# ARG_STR_ORG_INPUT
# BASHOPTS
# BASH_VERSINFO
# EPOCHREALTIME
# ERRTRAP
# EUID
# HOSTNAME
# LOG_DBG
# LOG_EXT
# LOG_TRC
# LOG_VAR
# NL
# RED
# RES
# SECONDS
# SHELLOPTS
# UID
# VAR_ARG_SANITIZED
# VAR_DEBUG_TRACE
# VAR_DEBUG_TRAP
# VAR_GIT_HEAD
# VAR_GIT_REL
# VAR_IN_DIALOG_WR
# VAR_PARAM_COUNT
# VAR_PARAM_STRNG
# VAR_RESOURCES
# VAR_SYSTEM
# VAR_VERSION
# Arguments:
@@ -160,9 +169,12 @@ trap_exit_non_zero() {
printf "%b❌ Command : %s %b%b" "${RED}" "${var_cmmd}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Script PID : %s %b%b" "${RED}" "${$}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Script Runtime : %s %b%b" "${RED}" "${SECONDS}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ System Resources : %s %b%b" "${RED}" "${VAR_RESOURCES}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Arguments Counter : %s %b%b" "${RED}" "${VAR_PARAM_COUNT}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Arguments Original : %s %b%b" "${RED}" "${VAR_PARAM_STRNG}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Arguments Sanitized : %s %b%b" "${RED}" "${VAR_ARG_SANITIZED}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ BASHOPTS : %s %b%b" "${RED}" "${BASHOPTS}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ SHELLOPTS : %s %b%b" "${RED}" "${SHELLOPTS}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ Error Log saved at : %s %b%b" "${RED}" "${LOG_EXT}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
printf "%b❌ cat %s %b%b" "${RED}" "${LOG_EXT}" "${RES}" "${NL}" | tee -a "${LOG_EXT}"
if [[ "${VAR_DEBUG_TRACE}" == "true" || "${VAR_DEBUG_TRAP}" == "true" ]]; then

View File

@@ -27,7 +27,6 @@ source_guard "./func/partitioning/3200_partitioning.sh"
source_guard "./func/partitioning/3210_benchmarking_encryption.sh"
source_guard "./func/partitioning/3220_partition_encryption.sh"
source_guard "./func/partitioning/3240_partition_formatting.sh"
source_guard "./func/partitioning/3260_setup_filesystem.sh"
source_guard "./func/partitioning/3280_mount_partition.sh"
source_guard "./func/partitioning/3290_uuid_logger.sh"
source_guard "./func/partitioning/3295_get_label.sh"

View File

@@ -22,7 +22,8 @@ declare -grx VAR_KERNEL_TMP=$(mktemp var_kernel_tmp.XXXXXXXX)
declare -grx VAR_KERNEL_SRT=$(mktemp var_kernel_srt.XXXXXXXX)
# shellcheck disable=SC2155
declare -grx VAR_NOTES=$(mktemp var_notes.XXXXXXXX)
# shellcheck disable=SC2155
declare -grx VAR_RESOURCES=$(ulimit)
### Initialize variables of different directories.
declare -grx DIR_BAK="/tmp/.ciss/backup"