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

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-24 23:01:23 +02:00
parent 1983e0229f
commit c026d9a324
48 changed files with 269 additions and 284 deletions

View File

@@ -42,11 +42,11 @@ partitioning() {
### All current data for the respective device will be deleted.
if ! blkdiscard "/dev/${var_dev}"; then
do_log "fatal" "false" "Partition table deletion '/dev/${var_dev}' failed."
do_log "fatal" "file_only" "Partition table deletion '/dev/${var_dev}' failed."
return "${ERR_TABLE_DELETE}"
fi
do_log "info" "false" "Partition table of '/dev/${var_dev}' discarded."
do_log "info" "file_only" "Partition table of '/dev/${var_dev}' discarded."
case "${VAR_RECIPE_TABLE,,}" in
@@ -55,10 +55,10 @@ partitioning() {
do_log "fatal" "false" "Partition table creation '/dev/${var_dev}' failed."
return "${ERR_TABLE_CREATE}"
fi
do_log "info" "false" "Partition table '${VAR_RECIPE_TABLE}' of '/dev/${var_dev}' generated."
do_log "info" "file_only" "Partition table '${VAR_RECIPE_TABLE}' of '/dev/${var_dev}' generated."
;;
*)
do_log "fatal" "false" "No valid partition table chosen. String was '${VAR_RECIPE_TABLE}'."
do_log "fatal" "file_only" "No valid partition table chosen. String was '${VAR_RECIPE_TABLE}'."
return "${ERR_PARTITIONTBL}"
;;
@@ -85,22 +85,22 @@ partitioning() {
fi
if ! parted -s "/dev/${var_dev}" mkpart "${var_pri}" "${var_fs}" "${var_begin}" "${var_end_arg}"; then
do_log "fatal" "false" "Partition creation '/dev/${var_dev}${var_part}' failed."
do_log "fatal" "file_only" "Partition creation '/dev/${var_dev}${var_part}' failed."
return "${ERR_PART_CREATE}"
fi
do_log "info" "false" "Partition generated: '${var_part}' | on device '/dev/${var_dev}' | begin: '${var_begin}' | end: '${var_end_arg}'."
do_log "info" "file_only" "Partition generated: '${var_part}' | on device '/dev/${var_dev}' | begin: '${var_begin}' | end: '${var_end_arg}'."
### Set the bootable flag if necessary.
if [[ "${var_boot,,}" == "true" ]]; then
parted -s "/dev/${var_dev}" set "${var_part}" boot on
do_log "info" "false" "Partition: '/dev/${var_dev}${var_part}' marked as bootable."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' marked as bootable."
fi
### Store UUID of the partition.
var_uuid=$(blkid -s UUID -o value "/dev/${var_dev}${var_part}")
if [[ -z "${var_uuid}" ]]; then
do_log "fatal" "false" "WARNING: could not read UUID for '/dev/${var_dev}${var_part}'."
do_log "fatal" "file_only" "WARNING: could not read UUID for '/dev/${var_dev}${var_part}'."
return "${ERR_PART_READ}"
else
HMP_PATH_PARTUUID["UUID_${var_mount_path}"]="${var_uuid}"

View File

@@ -96,18 +96,18 @@ partition_encryption() {
SWAP|/tmp)
mkfs.ext4 -L "${var_filesystem_label}" "/dev/${var_dev}${var_part}" 1M
do_log "info" "true" "Ephemeral: '${var_mount_path}' prepared on: '/dev/${var_dev}${var_part}'."
do_log "info" "file_only" "Ephemeral: '${var_mount_path}' prepared on: '/dev/${var_dev}${var_part}'."
HMP_EPHEMERAL_DEV["${var_mount_path}"]="/dev/${var_dev}${var_part}"
HMP_EPHEMERAL_ENCLABEL["${var_mount_path}"]="${var_encryption_label}"
HMP_EPHEMERAL_FS_LABEL["${var_mount_path}"]="${var_filesystem_label}"
do_log "info" "true" "Stored in HashMap [HMP_EPHEMERAL_DEV] : '${var_mount_path}' -> '${HMP_EPHEMERAL_DEV["${var_mount_path}"]}'"
do_log "info" "true" "Stored in HashMap [HMP_EPHEMERAL_ENCLABEL]: '${var_mount_path}' -> '${HMP_EPHEMERAL_ENCLABEL["${var_mount_path}"]}'"
do_log "info" "file_only" "Stored in HashMap [HMP_EPHEMERAL_DEV] : '${var_mount_path}' -> '${HMP_EPHEMERAL_DEV["${var_mount_path}"]}'"
do_log "info" "file_only" "Stored in HashMap [HMP_EPHEMERAL_ENCLABEL]: '${var_mount_path}' -> '${HMP_EPHEMERAL_ENCLABEL["${var_mount_path}"]}'"
continue
;;
*)
do_log "error" "true" "Invalid mount path: '${var_mount_path}' for partition: '/dev/${var_dev}${var_part}'."
do_log "error" "file_only" "Invalid mount path: '${var_mount_path}' for partition: '/dev/${var_dev}${var_part}'."
continue
;;
@@ -119,16 +119,16 @@ partition_encryption() {
if [[ "${var_encryption_integrity,,}" == "true" ]]; then
do_log "info" "true" "Partition: '/dev/${var_dev}${var_part}' dm-integrity encrypted."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' dm-integrity encrypted."
else
do_log "info" "true" "Partition: '/dev/${var_dev}${var_part}' encrypted."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' encrypted."
fi
cryptsetup luksHeaderBackup --header-backup-file="${DIR_BAK}/luks_header_${var_dev}${var_part}.bak" "/dev/${var_dev}${var_part}"
do_log "info" "true" "Partition: '/dev/${var_dev}${var_part}' LUKS Header saved: '${DIR_BAK}/luks_header_${var_dev}${var_part}.bak'."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' LUKS Header saved: '${DIR_BAK}/luks_header_${var_dev}${var_part}.bak'."
### Opening encrypted container.
if [[ "${var_mount_path,,}" == "/boot" ]]; then
@@ -140,7 +140,7 @@ partition_encryption() {
--key-file="${DIR_CNF}/password_luks_common.txt" \
"${var_encryption_label}"
fi
do_log "info" "true" "Partition: '/dev/${var_dev}${var_part}' opened as '/dev/mapper/${var_encryption_label}'."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' opened as '/dev/mapper/${var_encryption_label}'."
### Store UUID of the LUKS container.
var_uuid=$(blkid -s UUID -o value "/dev/mapper/${var_encryption_label}")

View File

@@ -60,7 +60,7 @@ partition_formatting() {
case "${var_mount_path,,}" in
swap|/tmp)
mkfs.ext4 -L "${var_fs_label}" "/dev/${var_dev}${var_part}" 1M
do_log "info" "false" "Partition: '/dev/${var_dev}${var_part}' ephemeral encryption prepared for: '${var_mount_path}'."
do_log "info" "file_only" "Partition: '/dev/${var_dev}${var_part}' ephemeral encryption prepared for: '${var_mount_path}'."
continue
;;
esac
@@ -77,7 +77,7 @@ partition_formatting() {
ary_opts=( -L "${var_fs_label}" -f --csum "${var_fs_btrfs_checksum}" -O compress="${var_fs_btrfs_compress}" )
[[ "${var_fs_btrfs_dedup,,}" == "true" ]] && ary_opts+=( -m dup )
mkfs.btrfs "${ary_opts[@]}" "${var_node}"
do_log "info" "false" "Partition: '${var_node}' formatted: btrfs."
do_log "info" "file_only" "Partition: '${var_node}' formatted: btrfs."
echo "Partition: '${var_node}':" >> "${DIR_LOG}/btrfs.log"
btrfs filesystem show "${var_node}" >> "${DIR_LOG}/btrfs.log"
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
@@ -87,7 +87,7 @@ partition_formatting() {
ext4)
read -r -a ary_fmt_opts <<< "${var_fs_options}"
mkfs.ext4 -L "${var_fs_label}" "${ary_fmt_opts[@]}" "${var_node}"
do_log "info" "false" "Partition: '${var_node}' formatted: ext4."
do_log "info" "file_only" "Partition: '${var_node}' formatted: ext4."
echo "Partition: '${var_node}':" >> "${DIR_LOG}/ext4.log"
tune2fs -l "${var_node}" >> "${DIR_LOG}/ext4.log"
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
@@ -96,13 +96,13 @@ partition_formatting() {
fat32)
mkfs.fat -F 32 -n "${var_fs_label}" "${var_node}"
do_log "info" "false" "Partition: '${var_node}' formatted: FAT32."
do_log "info" "file_only" "Partition: '${var_node}' formatted: FAT32."
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
HMP_PATH_FSUUID["UUID_${var_mount_path}"]="${var_fs_uuid}"
;;
*)
do_log "error" "false" "Unsupported filesystem format: '${var_fs_version}'."
do_log "error" "file_only" "Unsupported filesystem format: '${var_fs_version}'."
;;
esac

View File

@@ -61,13 +61,13 @@ setup_filesystem() {
else
do_log "error" "false" "Invalid value for encryption_enable: '${var_encryption_enable}', should be true or false."
do_log "error" "file_only" "Invalid value for encryption_enable: '${var_encryption_enable}', should be true or false."
continue
fi
HMP_MOUNTPATH_DEV["${var_mount_path}"]="${var_node}"
do_log "info" "false" "Saved in HashMap HMP_MOUNTPATH_DEV: '${var_mount_path}' -> '${HMP_MOUNTPATH_DEV["${var_mount_path}"]}'"
do_log "info" "file_only" "Saved in HashMap HMP_MOUNTPATH_DEV: '${var_mount_path}' -> '${HMP_MOUNTPATH_DEV["${var_mount_path}"]}'"
done

View File

@@ -48,7 +48,7 @@ mount_with_dir() {
ary_cmd+=("${var_mount_device}" "${TARGET}${var_mount_path}")
safe_exec "${ary_cmd[@]}" "${ERR_MOUNTING_DEV}" || return
do_log "info" "false" "Mounted: '${var_mount_device}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
do_log "info" "file_only" "Mounted: '${var_mount_device}' on: '${TARGET}${var_mount_path}' (Options='${var_mount_options}')."
}
#######################################
@@ -81,7 +81,7 @@ 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" "false" "Invalid btrfs compression '${var_algo}:${var_level}'"; return "${ERR_BTRFS_OPTION}" ;;
*) do_log "error" "file_only" "Invalid btrfs compression '${var_algo}:${var_level}'"; return "${ERR_BTRFS_OPTION}" ;;
esac
}
@@ -113,7 +113,7 @@ mount_partition() {
else
do_log "error" "false" "Root-filesystem '${var_mount_path_root}' not found in Hashmap."
do_log "error" "file_only" "Root-filesystem '${var_mount_path_root}' not found in Hashmap."
return "${ERR_MOUNTING_ROOT}"
fi
@@ -129,7 +129,7 @@ mount_partition() {
else
do_log "info" "false" "Entry '${var_path}' not found in Hashmap."
do_log "info" "file_only" "Entry '${var_path}' not found in Hashmap."
fi
@@ -175,7 +175,7 @@ mount_partition() {
--sector-size 4096 "/dev/disk/by-label/${var_fs_label}" "${var_encryption_label}"
mkswap "/dev/mapper/${var_encryption_label}"
swapon "/dev/mapper/${var_encryption_label}"
do_log "info" "false" "Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
do_log "info" "file_only" "Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
continue
elif [[ "${var_mount_path}" == "/tmp" ]]; then
@@ -192,7 +192,7 @@ mount_partition() {
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" "false" "Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
do_log "info" "file_only" "Mounted: '${var_mount_path}' on: '/dev/mapper/${var_encryption_label}'."
continue
fi
@@ -230,7 +230,7 @@ mount_partition() {
ext4:*)
mount_with_dir "${var_mount_path}" "${var_resolved_dev}" "${var_mount_options}" || return "${ERR_MOUNTING_DEV}"
;;
*) do_log "error" "false" "Unsupported fs/encryption combination."
*) do_log "error" "file_only" "Unsupported fs/encryption combination."
return "${ERR_MOUNTING_DEV}" ;;
esac