V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m28s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m28s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -24,46 +24,47 @@ guard_sourcing
|
||||
setup_filesystem() {
|
||||
### Declare Arrays and Variables.
|
||||
declare -Ag HMP_MOUNTPATH_DEV
|
||||
declare var_dev var_part var_encryption_enable var_encryption_label var_mount_enable var_mount_path
|
||||
declare var_dev var_part var_encryption_enable var_encryption_label var_mount_enable var_mount_path var_node
|
||||
declare -a ary_devs ary_parts
|
||||
|
||||
### Iterate over all devices in the recipe.
|
||||
for var_dev in $(yq e ".recipe.${VAR_RECIPE_STRING}.dev | keys | .[]" "${VAR_SETUP_PART}"); do
|
||||
readarray -t ary_devs < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev | keys | .[]" "${VAR_SETUP_PART}")
|
||||
for var_dev in "${ary_devs[@]}"; do
|
||||
|
||||
### Iterate over all partitions for this device.
|
||||
for var_part in $(yq e ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev} | keys | .[]" "${VAR_SETUP_PART}"); do
|
||||
readarray -t ary_parts < <(yq e -r ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev} | keys | .[]" "${VAR_SETUP_PART}")
|
||||
for var_part in "${ary_parts[@]}"; do
|
||||
|
||||
### Extract parameters from YAML.
|
||||
var_encryption_enable=$(yq e ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
|
||||
var_encryption_label=$(yq e ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.label" "${VAR_SETUP_PART}")
|
||||
var_mount_enable=$(yq e ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.enable" "${VAR_SETUP_PART}")
|
||||
var_mount_path=$(yq e ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.path" "${VAR_SETUP_PART}")
|
||||
var_encryption_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.enable" "${VAR_SETUP_PART}")
|
||||
var_encryption_label=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.encryption.label" "${VAR_SETUP_PART}")
|
||||
var_mount_enable=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.enable" "${VAR_SETUP_PART}")
|
||||
var_mount_path=$(yq_val ".recipe.${VAR_RECIPE_STRING}.dev.${var_dev}.${var_part}.mount.path" "${VAR_SETUP_PART}")
|
||||
|
||||
if [[ "${var_mount_enable,,}" == "true" ]]; then
|
||||
[[ -z "${var_mount_path}" ]] && continue
|
||||
|
||||
if [[ -n "${var_mount_path}" ]]; then
|
||||
[[ "${var_mount_enable,,}" != "true" ]] && continue
|
||||
|
||||
if [[ "${var_encryption_enable,,}" == "true" && "${var_mount_path}" != "SWAP" && "${var_mount_path}" != "/tmp" ]]; then
|
||||
[[ "${var_mount_path,,}" == "swap" || "${var_mount_path,,}" == "/tmp" ]] && continue
|
||||
|
||||
### Encrypted partition
|
||||
HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/mapper/${var_encryption_label}"
|
||||
do_log "info" "false" "Saved in HashMap MAP_MOUNTPATH_DEV: '${var_mount_path}' -> '${HMP_MOUNTPATH_DEV["${var_mount_path}"]}'"
|
||||
if [[ "${var_encryption_enable}" == "true" ]]; then
|
||||
|
||||
elif [[ "${var_encryption_enable,,}" == "false" && "${var_mount_path}" != "SWAP" && "${var_mount_path}" != "/tmp" ]]; then
|
||||
var_node="/dev/mapper/${var_encryption_label}"
|
||||
|
||||
### Unencrypted partition
|
||||
HMP_MOUNTPATH_DEV["${var_mount_path}"]="/dev/${var_dev}${var_part}"
|
||||
do_log "info" "false" "Saved in HashMap MAP_MOUNTPATH_DEV: '${var_mount_path}' -> '${HMP_MOUNTPATH_DEV["${var_mount_path}"]}'"
|
||||
elif [[ "${var_encryption_enable}" == "false" ]]; then
|
||||
|
||||
else
|
||||
var_node="/dev/${var_dev}${var_part}"
|
||||
|
||||
do_log "error" "false" "Invalid value for encryption_enable: '${var_encryption_enable}', should be either true or false."
|
||||
else
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
do_log "error" "false" "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}"]}'"
|
||||
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user