V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m21s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m21s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -1,67 +1,63 @@
|
||||
#!/bin/bash
|
||||
# SPDX-Version: 3.0
|
||||
# SPDX-CreationInfo: 2025-02-13; WEIDNER, Marc S.; <cendev@coresecret.eu>
|
||||
# SPDX-ExternalRef: GIT https://cendev.eu/marc.weidner/CISS.2025.debian.installer.git
|
||||
# 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.; <cendev@coresecret.eu>
|
||||
# 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.2025.hardened.installer framework.
|
||||
# SPDX-PackageName: CISS.2025.hardened.installer
|
||||
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
|
||||
# SPDX-PackageName: CISS.debian.installer
|
||||
# SPDX-Security-Contact: security@coresecret.eu
|
||||
|
||||
###########################################################################################
|
||||
# 3.6.1. Functions - installation - mount partition #
|
||||
###########################################################################################
|
||||
guard_sourcing
|
||||
|
||||
###########################################################################################
|
||||
#######################################
|
||||
# Function to generate btrfs-subvolumes.
|
||||
# Globals:
|
||||
# ERR_CREAT_SUB_VOL
|
||||
# ERR_BTRFS_SUBVOL
|
||||
# TARGET
|
||||
# Arguments:
|
||||
# 1: MOUNT_PATH
|
||||
# 2: SUBVOLUME
|
||||
###########################################################################################
|
||||
# $1: MOUNT_PATH
|
||||
# $2: SUBVOLUME
|
||||
#######################################
|
||||
create_btrfs_subvolume() {
|
||||
declare MOUNT_PATH="$1"
|
||||
declare SUBVOLUME="$2"
|
||||
declare var_mount_path="$1"
|
||||
declare var_subvolume="$2"
|
||||
|
||||
btrfs subvolume create "${TARGET}${MOUNT_PATH}/${SUBVOLUME}" || {
|
||||
do_log "error" "false" "Error occurred at creation of subvolume: '${SUBVOLUME}' in: '${TARGET}${MOUNT_PATH}'."
|
||||
exit "${ERR_CREAT_SUB_VOL}"
|
||||
btrfs subvolume create "${TARGET}${var_mount_path}/${var_subvolume}" || {
|
||||
do_log "error" "false" "Error occurred at creation of subvolume: '${var_subvolume}' in: '${TARGET}${var_mount_path}'."
|
||||
exit "${ERR_BTRFS_SUBVOL}"
|
||||
}
|
||||
do_log "info" "false" "Created: '${SUBVOLUME}' at: '${TARGET}${MOUNT_PATH}'."
|
||||
do_log "info" "false" "Created: '${var_subvolume}' at: '${TARGET}${var_mount_path}'."
|
||||
}
|
||||
|
||||
###########################################################################################
|
||||
#######################################
|
||||
# Function to create the mount path and mount the respective device on it.
|
||||
# Globals:
|
||||
# ERR_MOUNTING_PATH
|
||||
# ERR_MOUNTING_DEV
|
||||
# TARGET
|
||||
# Arguments:
|
||||
# $1: MOUNT_PATH
|
||||
# $2: MOUNT_DEVICE
|
||||
# $3: MOUNT_OPTIONS
|
||||
###########################################################################################
|
||||
#######################################
|
||||
mount_with_dir() {
|
||||
declare MOUNT_PATH="$1"
|
||||
declare MOUNT_DEVICE="$2"
|
||||
declare MOUNT_OPTIONS="$3"
|
||||
declare var_mount_path="$1"
|
||||
declare var_mount_device="$2"
|
||||
declare var_mount_options="$3"
|
||||
|
||||
if [[ ${MOUNT_PATH} == "/" ]]; then
|
||||
MOUNT_PATH=""
|
||||
if [[ "${var_mount_path}" == "/" ]]; then
|
||||
var_mount_path=""
|
||||
fi
|
||||
|
||||
# Create directory
|
||||
mkdir -p "${TARGET}${MOUNT_PATH}"
|
||||
mkdir -p "${TARGET}${var_mount_path}"
|
||||
|
||||
# Mount routine
|
||||
mount "${MOUNT_OPTIONS:+-o $MOUNT_OPTIONS}" "${MOUNT_DEVICE}" "${TARGET}${MOUNT_PATH}" || {
|
||||
do_log "error" "false" "Error occurred at mounting '${MOUNT_DEVICE}' on: '${TARGET}${MOUNT_PATH}'."
|
||||
exit "${ERR_MOUNTING_PATH}"
|
||||
mount "${var_mount_options:+-o $var_mount_options}" "${var_mount_device}" "${TARGET}${var_mount_path}" || {
|
||||
do_log "error" "false" "Error occurred at mounting '${var_mount_device}' on: '${TARGET}${var_mount_path}'."
|
||||
exit "${ERR_MOUNTING_DEV}"
|
||||
}
|
||||
do_log "info" "false" "Mounted: '${MOUNT_DEVICE}' on: '${TARGET}${MOUNT_PATH}' with: '${MOUNT_OPTIONS}'."
|
||||
do_log "info" "false" "Mounted: '${var_mount_device}' on: '${TARGET}${var_mount_path}' incl. options: '${var_mount_options}'."
|
||||
}
|
||||
|
||||
###########################################################################################
|
||||
@@ -79,25 +75,26 @@ mount_with_dir() {
|
||||
# Arguments:
|
||||
# None
|
||||
###########################################################################################
|
||||
3_6_1_functions_installation_mount_partition() {
|
||||
declare -g -x MODULE_ERR="3_6_1_functions_installation_mount_partition"
|
||||
declare -g -x MODULE_TXT="Mounting all partitions for debootstrap incl. generating btrfs subvolumes"
|
||||
do_show_header "${MODULE_TXT}"
|
||||
mount_partition() {
|
||||
### 3260_setup_filesystem.sh
|
||||
### Assoziative Array (HashMap) to store Crypt Mapper OR Device for each Mount Path
|
||||
### HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/mapper/${var_encryption_label}"
|
||||
### HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/${var_dev}${var_part}"
|
||||
|
||||
# Mount "/"-filesystem
|
||||
declare -r MOUNT_PATH_ROOT="/"
|
||||
if [[ -n ${MAP_MOUNTPATH_DEV[$MOUNT_PATH_ROOT]} ]]; then
|
||||
mount_with_dir "${MOUNT_PATH_ROOT}" "${MAP_MOUNTPATH_DEV[$MOUNT_PATH_ROOT]}"
|
||||
### Mount "/"-filesystem
|
||||
declare -r var_mount_path_root="/"
|
||||
if [[ -n ${MAP_MOUNTPATH_DEV[$var_mount_path_root]} ]]; then
|
||||
mount_with_dir "${var_mount_path_root}" "${MAP_MOUNTPATH_DEV[$var_mount_path_root]}"
|
||||
else
|
||||
do_log "error" "false" "Root-filesystem '${MOUNT_PATH_ROOT}' not found in Hashmap."
|
||||
do_log "error" "false" "Root-filesystem '${var_mount_path_root}' not found in Hashmap."
|
||||
exit "${ERR_MOUNTING_ROOT}"
|
||||
fi
|
||||
|
||||
# Ensure order of "/boot" and "/boot/efi"
|
||||
declare PATH
|
||||
for PATH in "/boot" "/boot/efi"; do
|
||||
if [[ -n ${MAP_MOUNTPATH_DEV[$PATH]} ]]; then
|
||||
mount_with_dir "${PATH}" "${MAP_MOUNTPATH_DEV[$PATH]}"
|
||||
### Ensure order of "/boot" and "/boot/efi"
|
||||
declare var_path
|
||||
for var_path in "/boot" "/boot/efi"; do
|
||||
if [[ -n ${MAP_MOUNTPATH_DEV[${var_path}]} ]]; then
|
||||
mount_with_dir "${var_path}" "${MAP_MOUNTPATH_DEV[${var_path}]}"
|
||||
else
|
||||
do_log "info" "false" "Entry '${PATH}' not found in Hashmap."
|
||||
fi
|
||||
@@ -261,7 +258,5 @@ mount_with_dir() {
|
||||
done
|
||||
|
||||
do_log "info" "false" "All devices of 'MAP_MOUNTPATH_DEV' and 'MAP_EPHEMERALLABEL_DEV' successfully mounted."
|
||||
|
||||
do_show_footer "${MODULE_TXT}"
|
||||
}
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh:
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
@@ -27,7 +27,9 @@ declare -girx ERR_INVALID_PORT=243 # Port validation failure.
|
||||
declare -girx ERR_ARG_MISMATCH=242 # The wrong number of optional arguments has been provided.
|
||||
declare -girx ERR_PARTITIONTBL=241 # The partition table is not allowed.
|
||||
declare -girx ERR_READ_PARTTBL=240 # The partition could not be deleted, created, or the UUID of the partition could not be read.
|
||||
|
||||
declare -girx ERR_BTRFS_SUBVOL=239 # The btrfs subvolume could not be created.
|
||||
declare -girx ERR_MOUNTING_DEV=238 # The Device could not be mounted.
|
||||
declare -girx ERR_MOUNTING_ROOT=237 # The / Volume could not be mounted.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -87,8 +87,9 @@ declare -Ag HMP_ENCRYPTIONLABEL_UUID
|
||||
declare -Ag HMP_MOUNTPATH_ENCRYPTIONLABEL
|
||||
|
||||
### 3260_setup_filesystem.sh
|
||||
### Assoziative Array (HashMap) to store Crypt Mapper for each Mount Path
|
||||
### Assoziative Array (HashMap) to store Crypt Mapper OR Device for each Mount Path
|
||||
### HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/mapper/${var_encryption_label}"
|
||||
### HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/${var_dev}${var_part}"
|
||||
declare -Ag HMP_MOUNTPATH_DEV
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user