V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m43s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m43s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -84,10 +84,8 @@ do_log() {
|
|||||||
declare var_log_only="$2"; shift
|
declare var_log_only="$2"; shift
|
||||||
declare ary_message=("$@")
|
declare ary_message=("$@")
|
||||||
declare var_msg_string="${ary_message[*]}"
|
declare var_msg_string="${ary_message[*]}"
|
||||||
# shellcheck disable=SC2155
|
declare var_color; var_color=$(do_get_log_color "${var_log_level}")
|
||||||
declare var_color=$(do_get_log_color "${var_log_level}")
|
declare var_ts; var_ts="$(date -u '+%Y-%m-%dT%H:%M:%S.%4N%z')"
|
||||||
# shellcheck disable=SC2155
|
|
||||||
declare var_ts="$(date -u '+%Y-%m-%dT%H:%M:%S.%4N%z')"
|
|
||||||
declare var_log_entry=("${var_ts} [${var_log_level}]: ${ary_message[*]}")
|
declare var_log_entry=("${var_ts} [${var_log_level}]: ${ary_message[*]}")
|
||||||
|
|
||||||
if do_should_log "${var_log_level}"; then
|
if do_should_log "${var_log_level}"; then
|
||||||
|
|||||||
@@ -12,6 +12,26 @@
|
|||||||
|
|
||||||
guard_sourcing
|
guard_sourcing
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# /etc/fstab entry writer and logger.
|
||||||
|
# Globals:
|
||||||
|
# TARGET
|
||||||
|
# Arguments:
|
||||||
|
# 1: UUID
|
||||||
|
# 2: Mount Path
|
||||||
|
# 3: Filesystem
|
||||||
|
# 4: Mount Options
|
||||||
|
# 5: Dump and Pass Value combined by one <space>, e.g., "0 1"
|
||||||
|
# Returns:
|
||||||
|
# 0: Successfully executed commands.
|
||||||
|
#######################################
|
||||||
|
write_fstab() {
|
||||||
|
declare _uuid="$1" _path="$2" _fs="$3" _opts="$4" _dp="$5"
|
||||||
|
printf "UUID=%s %s %s %s %s\n" "${_uuid}" "${_path}" "${_fs}" "${_opts}" "${_dp}" >> "${TARGET}/etc/fstab"
|
||||||
|
do_log "info" "true" "fstab entry generated: 'UUID=${_uuid} ${_path} ${_fs} ${_opts} ${_dp}'."
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Generate target '/etc/fstab' entries.
|
# Generate target '/etc/fstab' entries.
|
||||||
# Globals:
|
# Globals:
|
||||||
@@ -23,10 +43,12 @@ guard_sourcing
|
|||||||
# VAR_SETUP_PART
|
# VAR_SETUP_PART
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# None
|
# None
|
||||||
|
# Returns:
|
||||||
|
# 0: Successfully executed commands.
|
||||||
#######################################
|
#######################################
|
||||||
generate_fstab() {
|
generate_fstab() {
|
||||||
### Generate '${TARGET}/etc/fstab' header
|
### Generate '${TARGET}/etc/fstab' header.
|
||||||
touch "${TARGET}/etc/fstab"
|
: >| "${TARGET}/etc/fstab"
|
||||||
chmod 0644 "${TARGET}/etc/fstab"
|
chmod 0644 "${TARGET}/etc/fstab"
|
||||||
|
|
||||||
cat << 'EOF' >> "${TARGET}/etc/fstab"
|
cat << 'EOF' >> "${TARGET}/etc/fstab"
|
||||||
@@ -71,7 +93,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
var_part=$(echo "${var_entry}" | yq e 'path | .[-2]' -)
|
var_part=$(echo "${var_entry}" | yq e 'path | .[-2]' -)
|
||||||
var_dev=$(yq e '.recipe.*.dev | keys[0]' "${VAR_SETUP_PART}")
|
var_dev=$(echo "${var_entry}" | yq e 'path | .[-3]' -)
|
||||||
var_key="UUID_${var_path}"
|
var_key="UUID_${var_path}"
|
||||||
var_uuid="${HMP_PATH_FSUUID[${var_key}]}"
|
var_uuid="${HMP_PATH_FSUUID[${var_key}]}"
|
||||||
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
||||||
@@ -83,53 +105,44 @@ EOF
|
|||||||
|
|
||||||
if [[ "${var_fs_version,,}" == btrfs ]]; then
|
if [[ "${var_fs_version,,}" == btrfs ]]; then
|
||||||
|
|
||||||
if [[ "${var_fs_btrfs_level}" -eq 0 ]]; then
|
if [[ "${var_fs_btrfs_level:-0}" == 0 ]]; then
|
||||||
var_btrfs_compression="compress=no"
|
var_btrfs_compression="compress=no"
|
||||||
else
|
else
|
||||||
var_btrfs_compression="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
var_btrfs_compression="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options},${var_btrfs_compression} 0 1" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "${var_path}" "${var_fs_version}" "${var_mount_options},${var_btrfs_compression}" "0 1"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options},${var_btrfs_compression} 0 1'."
|
|
||||||
|
|
||||||
if [[ -n "${var_fs_btrfs_subvolume}" ]]; then
|
if [[ -n "${var_fs_btrfs_subvolume}" ]]; then
|
||||||
|
|
||||||
if [[ "${var_path}" == "/" ]]; then
|
if [[ "${var_path}" == "/" ]]; then
|
||||||
|
|
||||||
echo "UUID=${var_uuid} /.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "/.snapshots" "${var_fs_version}" "${var_mount_optsnap}" "0 0"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} /.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0'."
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path}/.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "${var_path}/.snapshots" "${var_fs_version}" "${var_mount_optsnap}" "0 0"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path}/.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0'."
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [[ "${var_fs_version,,}" == ext4 ]]; then
|
elif [[ "${var_fs_version,,}" == ext4 ]]; then
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options} 0 1" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "${var_path}" "${var_fs_version}" "${var_mount_options}" "0 1"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options} 0 1'."
|
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [[ "${var_fs_version,,}" == fat32 ]]; then
|
elif [[ "${var_fs_version,,}" == fat32 ]]; then
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} vfat ${var_mount_options} 0 2" >> "${TARGET}"/etc/fstab
|
write_fstab "${var_uuid}" "${var_path}" "vfat" "${var_mount_options}" "0 2"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} vfat ${var_mount_options} 0 2'."
|
|
||||||
echo "" >> "${TARGET}"/etc/fstab
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
### Generate '${TARGET}/etc/fstab' remaining entries
|
### Generate '${TARGET}/etc/fstab' remaining entries.
|
||||||
for var_path in "${!MAP_MOUNTPATH_DEV[@]}"; do
|
for var_path in "${!MAP_MOUNTPATH_DEV[@]}"; do
|
||||||
|
|
||||||
if validation_array "${var_path}" "${ary_skip[@]}"; then
|
if validation_array "${var_path}" "${ary_skip[@]}"; then
|
||||||
@@ -143,7 +156,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
var_part=$(echo "${var_entry}" | yq e 'path | .[-2]' -)
|
var_part=$(echo "${var_entry}" | yq e 'path | .[-2]' -)
|
||||||
var_dev=$(yq e '.recipe.*.dev | keys[0]' "${VAR_SETUP_PART}")
|
var_dev=$(echo "${var_entry}" | yq e 'path | .[-3]' -)
|
||||||
var_key="UUID_${var_path}"
|
var_key="UUID_${var_path}"
|
||||||
var_uuid="${HMP_PATH_FSUUID[${var_key}]}"
|
var_uuid="${HMP_PATH_FSUUID[${var_key}]}"
|
||||||
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
var_fs_btrfs_compress=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.filesystem.btrfs.compress" "${VAR_SETUP_PART}")
|
||||||
@@ -155,37 +168,27 @@ EOF
|
|||||||
|
|
||||||
if [[ "${var_fs_version,,}" == btrfs ]]; then
|
if [[ "${var_fs_version,,}" == btrfs ]]; then
|
||||||
|
|
||||||
if [[ "${var_fs_btrfs_level}" -eq 0 ]]; then
|
if [[ "${var_fs_btrfs_level:-0}" == 0 ]]; then
|
||||||
var_btrfs_compression="compress=no"
|
var_btrfs_compression="compress=no"
|
||||||
else
|
else
|
||||||
var_btrfs_compression="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
var_btrfs_compression="compress=${var_fs_btrfs_compress}:${var_fs_btrfs_level}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options},${var_btrfs_compression} 0 2" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "${var_path}" "${var_fs_version}" "${var_mount_options},${var_btrfs_compression}" "0 2"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options},${var_btrfs_compression} 0 2'."
|
|
||||||
|
|
||||||
if [[ -n "${var_fs_btrfs_subvolume}" ]]; then
|
if [[ -n "${var_fs_btrfs_subvolume}" ]]; then
|
||||||
|
write_fstab "${var_uuid}" "${var_path}/.snapshots" "${var_fs_version}" "${var_mount_optsnap}" "0 0"
|
||||||
echo "UUID=${var_uuid} ${var_path}/.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0" >> "${TARGET}/etc/fstab"
|
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path}/.snapshots ${var_fs_version} ${var_mount_optsnap} 0 0'."
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [[ "${var_fs_version,,}" == ext4 ]]; then
|
elif [[ "${var_fs_version,,}" == ext4 ]]; then
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options} 0 2" >> "${TARGET}/etc/fstab"
|
write_fstab "${var_uuid}" "${var_path}" "${var_fs_version}" "${var_mount_options}" "0 2"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} ${var_fs_version} ${var_mount_options} 0 2'."
|
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif [[ "${var_fs_version,,}" == fat32 ]]; then
|
elif [[ "${var_fs_version,,}" == fat32 ]]; then
|
||||||
|
|
||||||
echo "UUID=${var_uuid} ${var_path} vfat ${var_mount_options} 0 2" >> "${TARGET}"/etc/fstab
|
write_fstab "${var_uuid}" "${var_path}" "vfat" "${var_mount_options}" "0 2"
|
||||||
do_log "info" "false" "fstab entry generated: 'UUID=${var_uuid} ${var_path} vfat ${var_mount_options} 0 2'."
|
|
||||||
echo "" >> "${TARGET}"/etc/fstab
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -193,22 +196,19 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
cat << 'EOF' >> "${TARGET}/etc/fstab"
|
cat << 'EOF' >> "${TARGET}/etc/fstab"
|
||||||
|
|
||||||
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
|
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
do_log "info" "false" "fstab entry generated: '/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0'."
|
do_log "info" "true" "fstab entry generated: '/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0'."
|
||||||
|
|
||||||
### Add entry for 'SWAP' device.
|
### Add entry for 'SWAP' device.
|
||||||
var_path="SWAP"
|
var_path="SWAP"
|
||||||
echo "/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]} none swap defaults 0 0" >> "${TARGET}/etc/fstab"
|
write_fstab "/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]}" "none" "swap" "defaults" "0 0"
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
do_log "info" "false" "fstab entry generated: '/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]} none swap defaults 0 0'."
|
|
||||||
|
|
||||||
### Add entry for '/tmp' device.
|
### Add entry for '/tmp' device.
|
||||||
var_path="/tmp"
|
var_path="/tmp"
|
||||||
echo "/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]} /tmp ext4 defaults,rw,nodev,nosuid,relatime 0 0" >> "${TARGET}/etc/fstab"
|
write_fstab "/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]}" "/tmp" "ext4" "defaults,rw,nodev,nosuid,relatime" "0 0"
|
||||||
echo "" >> "${TARGET}/etc/fstab"
|
|
||||||
do_log "info" "false" "fstab entry generated: '/dev/mapper/${HMP_EPHEMERAL_ENCLABEL["${var_path}"]} /tmp ext4 defaults,rw,nodev,nosuid,relatime 0 0'."
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# SPDX-Version: 3.0
|
# SPDX-Version: 3.0
|
||||||
# SPDX-CreationInfo: 2025-02-13; WEIDNER, Marc S.; <cendev@coresecret.eu>
|
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||||
# SPDX-ExternalRef: GIT https://cendev.eu/marc.weidner/CISS.2025.debian.installer.git
|
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
|
||||||
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
|
||||||
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <cendev@coresecret.eu>
|
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
|
||||||
# SPDX-FileType: SOURCE
|
# SPDX-FileType: SOURCE
|
||||||
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
|
||||||
# SPDX-LicenseComment: This file is part of the CISS.2025.hardened.installer framework.
|
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
||||||
# SPDX-PackageName: CISS.2025.hardened.installer
|
# SPDX-PackageName: CISS.debian.installer
|
||||||
# SPDX-Security-Contact: security@coresecret.eu
|
# SPDX-Security-Contact: security@coresecret.eu
|
||||||
|
|
||||||
###########################################################################################
|
guard_sourcing
|
||||||
# 3.7.3. Functions - installation - generate crypttab #
|
|
||||||
###########################################################################################
|
|
||||||
|
|
||||||
###########################################################################################
|
###########################################################################################
|
||||||
# Generate "${TARGET}" /etc/crypttab entries.
|
# Generate "${TARGET}" /etc/crypttab entries.
|
||||||
Reference in New Issue
Block a user