summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rwxr-xr-xcore/utils/shflow-check.sh67
-rw-r--r--core/utils/shflow-check.tr.en5
-rw-r--r--core/utils/shflow-check.tr.es5
3 files changed, 76 insertions, 1 deletions
diff --git a/core/utils/shflow-check.sh b/core/utils/shflow-check.sh
index d026875..6906868 100755
--- a/core/utils/shflow-check.sh
+++ b/core/utils/shflow-check.sh
@@ -2,7 +2,7 @@
# ShFlow Environment Checker
# License: GPLv3
# Author: Luis GuLo
-# Version: 1.5.0
+# Version: 1.5.1
set -e
@@ -43,6 +43,10 @@ REQUIRED_PATHS=(
"$PROJECT_ROOT/vault.sh"
)
+# 📦 Variables Globales
+declare -A shflow_vars
+GLOBAL_VARS="$PROJECT_ROOT/core/inventory/vars/all.yaml"
+
# 🌐 Cargar traducciones
lang="${shflow_vars[language]:-es}"
trfile="$PROJECT_ROOT/core/utils/shflow-check.tr.${lang}"
@@ -96,13 +100,74 @@ load_and_check_modules() {
done
}
+# 📦 Carga las variables globales de all.yaml
+load_global_vars() {
+ if [[ -f "$GLOBAL_VARS" ]]; then
+ echo "${tr[vars_loading]:-📦 Cargando variables globales de all.yaml...}"
+
+ # Carga todas las claves del YAML
+ GLOBAL_KEYS=$("$YQ_BIN" eval 'keys[]' "$GLOBAL_VARS" -r 2>/dev/null || true)
+
+ for key in $GLOBAL_KEYS; do
+ # Carga el valor en modo raw para Bash
+ raw_value=$("$YQ_BIN" eval ".\"$key\"" "$GLOBAL_VARS" -r 2>/dev/null || true)
+
+ # Si el valor es una lista o multilínea, yq lo habrá cargado con saltos de línea, lo almacenamos tal cual.
+ # Si es un valor simple, lo almacenamos.
+ shflow_vars["$key"]="$raw_value"
+ done
+
+ echo "$(render_msg "${tr[vars_loaded]:-✅ Variables cargadas: {count}}" "count=${#shflow_vars[@]}")"
+
+ # Si la variable 'language' se ha cargado, actualizamos las traducciones del check.
+ local new_lang="${shflow_vars[language]:-es}"
+ if [[ "$new_lang" != "$lang" ]]; then
+ lang="$new_lang"
+ trfile="$PROJECT_ROOT/core/utils/shflow-check.tr.${lang}"
+ if [[ -f "$trfile" ]]; then
+ declare -A tr # Reset array
+ while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"
+ fi
+ fi
+ else
+ echo "$(render_msg "${tr[vars_missing]:-⚠️ all.yaml no encontrado en {path}}" "path=$GLOBAL_VARS")"
+ fi
+}
+
+# 🧠 Mostrar variables cargadas
+show_global_vars() {
+ echo ""
+ echo "${tr[debug_vars_header]:-🌐 VARIABLES GLOBALES CARGADAS:}"
+ echo "====================================="
+ local count=0
+ for key in "${!shflow_vars[@]}"; do
+ local display_value="${shflow_vars[$key]}"
+
+ # Formateo básico para listas para una mejor lectura en la consola
+ if [[ "$key" == "ntp_servers" || "$key" == "default_packages" ]]; then
+ # Reemplaza los saltos de línea por comas y espacio
+ display_value=$(echo "$display_value" | tr '\n' ' ' | xargs | sed 's/ /\//g')
+ fi
+
+ echo "- $key: $display_value"
+ count=$((count + 1))
+ done
+ echo "-------------------------------------"
+ echo "$(render_msg "${tr[debug_vars_count]:-Total de variables: {count}" "count=$count")"
+}
+
+
main() {
echo "${tr[title]:-🧪 ShFlow Environment Check}"
echo "${tr[separator]:-=============================}"
+ load_global_vars
+
check_global_tools
check_structure
load_and_check_modules
+
+ show_global_vars
echo ""
echo "${tr[done]:-✅ Verificación completada.}"
diff --git a/core/utils/shflow-check.tr.en b/core/utils/shflow-check.tr.en
index 6430ffd..9957f4e 100644
--- a/core/utils/shflow-check.tr.en
+++ b/core/utils/shflow-check.tr.en
@@ -10,3 +10,8 @@ modules_header=🔍 Checking ShFlow modules...
checking_func=🔧 Running {func}...
func_warn=⚠️ Incomplete dependencies in {func}
done=✅ Check completed.
+vars_loading=📦 Loading global variables from all.yaml...
+vars_loaded=✅ Variables loaded: {count}
+vars_missing=⚠️ all.yaml not found in {path}
+debug_vars_header=🌐 LOADED GLOBAL VARIABLES:
+debug_vars_count=Total variables: {count}
diff --git a/core/utils/shflow-check.tr.es b/core/utils/shflow-check.tr.es
index 983f318..53443ca 100644
--- a/core/utils/shflow-check.tr.es
+++ b/core/utils/shflow-check.tr.es
@@ -10,3 +10,8 @@ modules_header=🔍 Verificando módulos ShFlow...
checking_func=🔧 Ejecutando {func}...
func_warn=⚠️ Dependencias incompletas en {func}
done=✅ Verificación completada.
+vars_loading=📦 Cargando variables globales de all.yaml...
+vars_loaded=✅ Variables cargadas: {count}
+vars_missing=⚠️ all.yaml no encontrado en {path}
+debug_vars_header=🌐 VARIABLES GLOBALES CARGADAS:
+debug_vars_count=Total de variables: {count}