V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 45s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 45s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -47,13 +47,21 @@ partitioning() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
# shellcheck disable=SC2034
|
||||
declare -Ag HMP_PATH_PARTUUID # Used in: 3290() - [Mount Path:Partition UUID].
|
||||
# shellcheck disable=SC2034
|
||||
declare -Ag HMP_FSTAB_MOUNT_FTYPE # Used in: 4040() - [Mount Path:Filesystem type].
|
||||
# shellcheck disable=SC2034
|
||||
declare -Ag HMP_PATH_DEV_PART # Used in: 3220() - [Mount Path:DEV.PARTITION].
|
||||
# Used in: 3240() - [Mount Path:DEV.PARTITION].
|
||||
# Used in: 3280() - [Mount Path:DEV.PARTITION].
|
||||
# shellcheck disable=SC2034
|
||||
declare -ag ARY_CRYPT_MOUNT_PATHS=() # Used in: 3220() - Only entries [/paths] for encryption.
|
||||
# shellcheck disable=SC2034
|
||||
declare -ag ARY_FORMT_MOUNT_PATHS=() # Used in: 3240() - Only entries [/paths] for filesystem generation.
|
||||
# shellcheck disable=SC2034
|
||||
declare -ag ARY_FSTAB_MOUNT_PATHS=() # Used in: 4040() - Only entries [/paths] for '/etc/fstab' generation.
|
||||
declare -ag ARY_PATHS_SORTED=() # Used in: - All entries [/paths] in a mount ordering scheme.
|
||||
# shellcheck disable=SC2034
|
||||
declare -ag ARY_PATHS_SORTED=() # Used in: 3280() - All entries [/paths] in a mount ordering scheme.
|
||||
# Used in: 4040() - 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="" \
|
||||
@@ -250,15 +258,18 @@ partitioning() {
|
||||
fi
|
||||
|
||||
### Gathering information for forthcoming modules 32n0().
|
||||
# shellcheck disable=SC2034
|
||||
HMP_PATH_DEV_PART["${var_mount_path}"]="${var_dev}.${var_part}"
|
||||
|
||||
### Gathering information for encryption module 3220().
|
||||
if [[ "${var_encryption}" == "true" ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
ARY_CRYPT_MOUNT_PATHS+=("${var_mount_path}")
|
||||
fi
|
||||
|
||||
### Gathering information for filesystem module 3240().
|
||||
if [[ "${var_format}" == "true" ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
ARY_FORMT_MOUNT_PATHS+=("${var_mount_path}")
|
||||
fi
|
||||
|
||||
@@ -267,6 +278,7 @@ partitioning() {
|
||||
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
if [[ "${var_mount_true}" == "true" ]]; then
|
||||
# shellcheck disable=SC2034
|
||||
ARY_FSTAB_MOUNT_PATHS+=("${var_mount_path}")
|
||||
do_log "debug" "file_only" "3200() Stored in Array [ARY_FSTAB_MOUNT_PATHS] : '${var_mount_path}'."
|
||||
HMP_FSTAB_MOUNT_FTYPE["${var_mount_path}"]="${var_fs}"
|
||||
|
||||
@@ -41,10 +41,10 @@ partition_encryption() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -Ag HMP_PATH_LUKSUUID # Used in: 3290() - [Mount Path:LUKS UUID].
|
||||
# Used in: 4060() - [Mount Path:LUKS UUID].
|
||||
declare -Ag HMP_EPHEMERAL_ENCLABEL
|
||||
declare -Ag HMP_EPHEMERAL_FS_LABEL
|
||||
declare -Ag HMP_EPHEMERAL_ENCLABEL # Used in: 4040() - [Mount Path:LUKS Encryption Label].
|
||||
declare -Ag HMP_EPHEMERAL_FS_LABEL # Used in: 4060() - [Mount Path:Ephemeral Host FS Label]. Substituted by FS-UUID
|
||||
|
||||
declare -Ag HMP_PATH_ENCLABEL
|
||||
declare -Ag HMP_PATH_ENCLABEL # Used in: 4060() - [Mount Path:LUKS Encryption Label].
|
||||
|
||||
declare -gx VAR_CRYPT_ROOT="" # LUKS UUID of '/'.
|
||||
declare -gx VAR_CRYPT_RECOVERY="" # LUKS UUID of '/recovery'.
|
||||
@@ -121,12 +121,17 @@ partition_encryption() {
|
||||
mkfs.ext4 -L "${var_filesystem_label}" "/dev/${var_dev_part}" 1M
|
||||
do_log "info" "file_only" "3220() Ephemeral: '${var_encryption_path}' prepared on: '/dev/${var_dev_part}'."
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_dev_part}")
|
||||
### Gathering information for '/etc/fstab'-generation in 4040() and '/etc/crypttab'-generation in 4060().
|
||||
# shellcheck disable=SC2034
|
||||
HMP_PATH_FSUUID["${var_encryption_path}"]="${var_fs_uuid}"
|
||||
do_log "debug" "file_only" "3220() [HMP_PATH_FSUUID] : '${var_encryption_path}' -> '${HMP_PATH_FSUUID["${var_encryption_path}"]}'"
|
||||
|
||||
HMP_EPHEMERAL_ENCLABEL["${var_encryption_path}"]="${var_encryption_label}"
|
||||
HMP_EPHEMERAL_FS_LABEL["${var_encryption_path}"]="${var_filesystem_label}"
|
||||
|
||||
do_log "debug" "file_only" "3220() Stored in HashMap [HMP_EPHEMERAL_ENCLABEL]: '${var_encryption_path}' -> '${HMP_EPHEMERAL_ENCLABEL["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() Stored in HashMap [HMP_EPHEMERAL_FS_LABEL]: '${var_encryption_path}' -> '${HMP_EPHEMERAL_FS_LABEL["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() [HMP_EPHEMERAL_ENCLABEL]: '${var_encryption_path}' -> '${HMP_EPHEMERAL_ENCLABEL["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() [HMP_EPHEMERAL_FS_LABEL]: '${var_encryption_path}' -> '${HMP_EPHEMERAL_FS_LABEL["${var_encryption_path}"]}'"
|
||||
|
||||
### The setup of ephemeral devices MUST stop here.
|
||||
continue
|
||||
@@ -184,8 +189,8 @@ partition_encryption() {
|
||||
HMP_PATH_LUKSUUID["${var_encryption_path}"]="${var_uuid}"
|
||||
HMP_PATH_ENCLABEL["${var_encryption_path}"]="${var_encryption_label}"
|
||||
|
||||
do_log "debug" "file_only" "3220() [HMP_PATH_LUKSUUID] : '${var_encryption_path}' -> '${HMP_PATH_LUKSUUID["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() [HMP_PATH_ENCLABEL] : '${var_encryption_path}' -> '${HMP_PATH_ENCLABEL["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() [HMP_PATH_LUKSUUID]: '${var_encryption_path}' -> '${HMP_PATH_LUKSUUID["${var_encryption_path}"]}'"
|
||||
do_log "debug" "file_only" "3220() [HMP_PATH_ENCLABEL]: '${var_encryption_path}' -> '${HMP_PATH_ENCLABEL["${var_encryption_path}"]}'"
|
||||
|
||||
done
|
||||
|
||||
|
||||
@@ -29,13 +29,16 @@ guard_sourcing
|
||||
#######################################
|
||||
partition_formatting() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
# shellcheck disable=SC2034
|
||||
declare -Ag HMP_PATH_FSUUID # Used in: 3290() - [Mount Path:Filesystem UUID].
|
||||
# Used in: 4040() - [Mount Path:Filesystem UUID].
|
||||
# Used in: 4060() - [Mount Path:Filesystem UUID].
|
||||
declare var_dev="" var_dev_part="" \
|
||||
var_encryption_enable="" var_encryption_label="" var_format_path="" var_fs_btrfs_checksum="" var_fs_btrfs_compress="" \
|
||||
var_fs_btrfs_mdup="" var_fs_label="" var_fs_options="" var_fs_version="" var_node="" var_fs_uuid=""
|
||||
declare var_dev="" var_dev_part="" \
|
||||
var_encryption_enable="" var_encryption_label="" var_format_path="" var_fs_btrfs_checksum="" \
|
||||
var_fs_btrfs_compress="" var_fs_btrfs_mdup="" var_fs_label="" var_fs_options="" var_fs_version="" \
|
||||
var_node="" var_fs_uuid=""
|
||||
|
||||
declare -a ary_opts=() ary_fmt_opts=()
|
||||
declare -a ary_opts=() ary_fmt_opts=()
|
||||
|
||||
for var_format_path in "${ARY_FORMT_MOUNT_PATHS[@]}"; do
|
||||
|
||||
@@ -85,7 +88,8 @@ partition_formatting() {
|
||||
btrfs filesystem show "${var_node}" >> "${DIR_LOG}/btrfs.log"
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
### Gathering information for '/etc/fstab'-generation in 4040() and '/etc/crypttab'-generation in 4060().
|
||||
# shellcheck disable=SC2034
|
||||
HMP_PATH_FSUUID["${var_format_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
@@ -101,7 +105,8 @@ partition_formatting() {
|
||||
tune2fs -l "${var_node}" >> "${DIR_LOG}/ext4.log"
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
### Gathering information for '/etc/fstab'-generation in 4040() and '/etc/crypttab'-generation in 4060().
|
||||
# shellcheck disable=SC2034
|
||||
HMP_PATH_FSUUID["${var_format_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
@@ -112,7 +117,8 @@ partition_formatting() {
|
||||
do_log "info" "file_only" "3240() Partition: '${var_node}' formatted: 'FAT32'."
|
||||
|
||||
var_fs_uuid=$(blkid -s UUID -o value "${var_node}")
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
### Gathering information for '/etc/fstab'-generation in 4040() and '/etc/crypttab'-generation in 4060().
|
||||
# shellcheck disable=SC2034
|
||||
HMP_PATH_FSUUID["${var_format_path}"]="${var_fs_uuid}"
|
||||
;;
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ guard_sourcing
|
||||
#######################################
|
||||
mount_with_dir() {
|
||||
declare var_mount_path="$1" var_mount_device="$2" var_mount_options="${3:-}"
|
||||
declare -a ary_cmd=(mount)
|
||||
declare -a ary_cmd=( mount )
|
||||
|
||||
if [[ "${var_mount_device}" =~ ^[0-9a-fA-F-]{8,}$ ]]; then
|
||||
if [[ "${var_mount_device}" =~ ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}$ ]] || [[ "${var_mount_device}" =~ ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ ]]; then
|
||||
|
||||
if [[ -e "/dev/disk/by-uuid/${var_mount_device}" ]]; then
|
||||
|
||||
@@ -149,6 +149,11 @@ mount_partition() {
|
||||
var_encryption_label=$(get_label "${var_mount_path}" "${var_fs_version}" "luks")
|
||||
var_fs_uuid="${HMP_PATH_FSUUID["${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
|
||||
|
||||
@@ -175,7 +180,7 @@ mount_partition() {
|
||||
|
||||
mkdir -p "${TARGET}/tmp"
|
||||
|
||||
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}"
|
||||
safe_exec mkfs.ext4 -E 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}"
|
||||
@@ -225,10 +230,11 @@ mount_partition() {
|
||||
|
||||
validate_btrfs_compression "${var_fs_btrfs_compress}" "${var_fs_btrfs_level}" || return "${ERR_BTRFS_OPTION}"
|
||||
|
||||
var_btrfs_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
||||
|
||||
[[ -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}"
|
||||
if [[ -n "${var_mount_options}" ]]; then
|
||||
var_btrfs_options="${var_mount_options},compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level},subvol=${var_fs_btrfs_subvolume}"
|
||||
else
|
||||
var_btrfs_options="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level},subvol=${var_fs_btrfs_subvolume}"
|
||||
fi
|
||||
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}"]="${var_btrfs_options}"
|
||||
@@ -243,7 +249,11 @@ mount_partition() {
|
||||
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}"
|
||||
if [[ -n "${var_mount_optsnap}" ]]; then
|
||||
var_mount_optsnap+=",subvol=${var_snapshot}"
|
||||
else
|
||||
var_mount_optsnap="subvol=${var_snapshot}"
|
||||
fi
|
||||
|
||||
### Gathering information for '/etc/fstab'-generation in 4040().
|
||||
HMP_FSTAB_MOUNT_OPTS["${var_mount_path}/.snapshots"]="${var_mount_optsnap}"
|
||||
|
||||
Reference in New Issue
Block a user