V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 43s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 43s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -23,7 +23,7 @@ guard_sourcing
|
||||
#######################################
|
||||
validation_array() {
|
||||
declare var_element
|
||||
declare var_string=$1; shift
|
||||
declare var_string="$1"; shift
|
||||
for var_element in "$@"; do
|
||||
if [[ "${var_element}" == "${var_string}" ]]; then
|
||||
return 0
|
||||
|
||||
@@ -39,7 +39,7 @@ yaml_parser() {
|
||||
|
||||
yq -o=shell "${DIR_TMP}/combined.yaml" >| "${VAR_PRESEED}"
|
||||
|
||||
### Generate Arrays for Grub Parameter, NTPSec Server FQDN, Software Packages
|
||||
### Generate Arrays for [Grub Parameter], [NTPSec Server FQDN], [Software Packages].
|
||||
while IFS='=' read -r var_key var_value; do
|
||||
var_value=${var_value#\'}
|
||||
var_value=${var_value%\'}
|
||||
|
||||
@@ -36,7 +36,7 @@ yaml_reader() {
|
||||
declare -gx VAR_RECIPE_STRING="" VAR_RECIPE_HIGHEST_DEVICE="" VAR_ARCHITECTURE="" VAR_RECIPE_FIRMWARE="" VAR_NUKE="" \
|
||||
VAR_RECIPE_TABLE=""
|
||||
|
||||
### Declare and substitute input files
|
||||
### Declare and substitute input files.
|
||||
declare -r var_if="${VAR_PRESEED}"
|
||||
### Search pattern for variables (recipe_<string>_active='true')
|
||||
declare -r var_search_pattern="^recipe_.*_active='true'"
|
||||
@@ -67,65 +67,6 @@ yaml_reader() {
|
||||
exit "${ERR_NO_VALID_RECIPE}"
|
||||
fi
|
||||
|
||||
### Search "${var_if}" for matching recipe_${VAR_RECIPE_STRING}_dev_* entries and find the highest dev letter.
|
||||
# shellcheck disable=SC2312
|
||||
var_highest_dev=$(grep -E "^recipe_${VAR_RECIPE_STRING}_dev_" "${var_if}" | awk -F'_' '
|
||||
{
|
||||
if (NF >= 4) {
|
||||
### Extract 4th position (e.g., "recipe_${VAR_RECIPE_STRING}_dev_sda" or "recipe_${VAR_RECIPE_STRING}_dev_vda")
|
||||
device_field = $4
|
||||
### Check, if field is at least 3 char wide and last char contains a letter
|
||||
if (length(device_field) >= 3) {
|
||||
last_char = substr(device_field, length(device_field), 1) ### Extract last letter of respective field
|
||||
if (last_char ~ /^[a-z]$/ && last_char > max) {
|
||||
max = last_char
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
END { print max }
|
||||
')
|
||||
|
||||
### Save the result in VAR_RECIPE_HIGHEST_DEVICE.
|
||||
VAR_RECIPE_HIGHEST_DEVICE="${var_highest_dev}"
|
||||
|
||||
if [[ -n "${VAR_RECIPE_HIGHEST_DEVICE}" ]]; then
|
||||
do_log "info" "file_only" "1251() Found highest recipe device: '${VAR_RECIPE_HIGHEST_DEVICE}'."
|
||||
else
|
||||
do_log "fatal" "file_only" "1251() Found NO highest recipe device: '${VAR_RECIPE_HIGHEST_DEVICE}'."
|
||||
exit "${ERR_NO_VALID_RECIPE}"
|
||||
fi
|
||||
|
||||
### Read var_if and iterate through all matching entries without executing in a subshell
|
||||
# shellcheck disable=SC2312
|
||||
while read -r var_line; do
|
||||
### Extract fields of line
|
||||
IFS='_' read -ra var_fields <<< "${var_line}"
|
||||
|
||||
### Check that enough fields are available
|
||||
if [[ "${#var_fields[@]}" -ge 5 ]]; then
|
||||
var_device="${var_fields[3]}" ### The fourth position includes the device (e.g., sda, vda, xvda)
|
||||
var_partition="${var_fields[4]}" ### The fifth position includes the partition (e.g., 13)
|
||||
|
||||
### Check, if the partition is a number and higher than the current value
|
||||
if [[ "${var_partition}" =~ ^[0-9]+$ ]]; then
|
||||
declare -i cur="${HMP_RECIPE_DEV_PARTITIONS[${var_device}]:-0}"
|
||||
if (( var_partition > cur )); then
|
||||
|
||||
#if [[ -z "${HMP_RECIPE_DEV_PARTITIONS[${var_device}]:-}" || "${var_partition}" -gt ${HMP_RECIPE_DEV_PARTITIONS[${var_device}]:-0} ]]; then
|
||||
# shellcheck disable=SC2004
|
||||
HMP_RECIPE_DEV_PARTITIONS[${var_device}]="${var_partition}"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
done < <(grep -E "^recipe_${VAR_RECIPE_STRING}_dev_" "${var_if}")
|
||||
|
||||
for var_device in "${!HMP_RECIPE_DEV_PARTITIONS[@]}"; do
|
||||
do_log "info" "file_only" "1251() Highest number of partitions: [${var_device}:${HMP_RECIPE_DEV_PARTITIONS[${var_device}]}]."
|
||||
done
|
||||
|
||||
### Extract architecture.
|
||||
VAR_ARCHITECTURE="${architecture}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user