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

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-10-07 17:27:17 +01:00
parent 914539f166
commit 72dcf355d9
17 changed files with 100 additions and 45 deletions

View File

@@ -15,7 +15,6 @@ guard_sourcing
#######################################
# 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
@@ -24,6 +23,7 @@ guard_sourcing
# 4: MOUNT_FILESYSTEM
# Returns:
# 0: on success
# ERR_MOUNTING_DEV: on failure
#######################################
mount_with_dir() {
declare var_mount_path="${1}" var_mount_device="${2}" var_mount_options="${3:-}" var_mount_fs="${4:-}"
@@ -60,7 +60,7 @@ mount_with_dir() {
### Already absolute path.
elif [[ "${var_mount_device}" == /dev/* ]]; then
: ### Do nothing
: ### Do nothing.
### Alternative checks for LABEL and PARTUUID.
else
@@ -104,16 +104,23 @@ mount_with_dir() {
return 0
}
### Prevents accidental 'unset -f'.
# shellcheck disable=SC2034
readonly -f mount_with_dir
#######################################
# Device Path Resolver.
# Outputs '/dev/mapper/<encryption_label>'
# Outputs '/dev/<dev><partition>'
# Globals:
# none
# Arguments:
# 1: Device
# 2: Partition
# 3: Boolean Encryption
# 4: Encryption Label
# Returns:
# 0: on success
#######################################
resolve_device() {
declare local_var_dev="$1" local_var_partition="$2" local_var_enc_boolean="$3" local_var_enc_label="$4"
@@ -130,15 +137,20 @@ resolve_device() {
return 0
}
### Prevents accidental 'unset -f'.
# shellcheck disable=SC2034
readonly -f resolve_device
#######################################
# Validates btrfs compression algo and level.
# Globals:
# none
# Arguments:
# 1: var_fs_btrfs_compress
# 2: var_fs_btrfs_level
# Returns:
# 0: Valid combination.
# 1: Invalid combination.
# ERR_BTRFS_OPTION: on failure
#######################################
validate_btrfs_compression() {
declare var_algo="$1" var_level="$2"
@@ -151,19 +163,20 @@ validate_btrfs_compression() {
esac
}
### Prevents accidental 'unset -f'.
# shellcheck disable=SC2034
readonly -f validate_btrfs_compression
#######################################
# Function for mounting all partitions for debootstrap, including the generation of btrfs subvolumes.
# Globals:
# ARY_CRYPT_MOUNT_PATHS
# 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
# HMP_PATH_PARTUUID
# NL
# TARGET
# VAR_RECIPE_STRING
@@ -173,11 +186,10 @@ validate_btrfs_compression() {
# None
# Returns:
# 0: on success
# ERR_BTRFS_INITPH
# ERR_BTRFS_OPTION
# ERR_BTRFS_SUBVOL
# ERR_MOUNTING_DEV
# ERR_MOUNTING_ROOT
# ERR_BTRFS_INITPH: on failure
# ERR_BTRFS_OPTION: on failure
# ERR_BTRFS_SUBVOL: on failure
# ERR_MOUNTING_DEV: on failure
#######################################
mount_partition() {
### Declare Arrays, HashMaps, and Variables.
@@ -212,22 +224,13 @@ mount_partition() {
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
fi
var_partuuid="${HMP_PATH_PARTUUID["${var_mount_path}"]}"
#if [[ -z "${var_fs_uuid}" ]]; then
# do_log "error" "file_only" "3280() FS-UUID for mount path: '${var_mount_path}' not found in: 'HMP_PATH_FSUUID'."
# return "${ERR_MOUNTING_DEV}"
#fi
### 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
#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}"
var_partuuid="${HMP_PATH_PARTUUID["${var_mount_path}"]}"
cryptsetup open --type plain --hash=plain \
--key-file /dev/random --keyfile-size 256 \
--key-file /dev/random --keyfile-size 64 \
--cipher aes-xts-plain64 --key-size 512 \
"/dev/disk/by-partuuid/${var_partuuid}" "${var_encryption_label}"
@@ -244,12 +247,10 @@ mount_partition() {
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}"
var_partuuid="${HMP_PATH_PARTUUID["${var_mount_path}"]}"
cryptsetup open --type plain --hash=plain \
--key-file /dev/random --keyfile-size 256 \
--key-file /dev/random --keyfile-size 64 \
--cipher aes-xts-plain64 --key-size 512 \
"/dev/disk/by-partuuid/${var_partuuid}" "${var_encryption_label}"
@@ -378,4 +379,7 @@ mount_partition() {
guard_dir && return 0
}
### Prevents accidental 'unset -f'.
# shellcheck disable=SC2034
readonly -f mount_partition
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh