summaryrefslogtreecommitdiff
path: root/core/utils/shflow-check.sh
diff options
context:
space:
mode:
authorluisgulo <luisgulo@gmail.com>2025-10-24 18:01:10 +0200
committerluisgulo <luisgulo@gmail.com>2025-10-24 18:01:10 +0200
commit533e79ba959143f0459431a486bfb85c56c72ddc (patch)
tree91974de1bbbdc4c51c76ed591fc5c6e02a3342b6 /core/utils/shflow-check.sh
parent45019c81cfd0fc1d18dce18cdfd5f127c6d61073 (diff)
Releasing code version 1.8.0
Diffstat (limited to 'core/utils/shflow-check.sh')
-rwxr-xr-xcore/utils/shflow-check.sh100
1 files changed, 100 insertions, 0 deletions
diff --git a/core/utils/shflow-check.sh b/core/utils/shflow-check.sh
new file mode 100755
index 0000000..130eca0
--- /dev/null
+++ b/core/utils/shflow-check.sh
@@ -0,0 +1,100 @@
+#!/usr/bin/env bash
+# ShFlow Environment Checker
+# License: GPLv3
+# Author: Luis GuLo
+# Version: 1.5.0
+
+set -e
+
+PROJECT_ROOT="${SHFLOW_HOME:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
+
+MODULE_PATHS=(
+ "$PROJECT_ROOT/core/modules"
+ "$PROJECT_ROOT/user_modules"
+ "$PROJECT_ROOT/community_modules"
+)
+
+# 🧩 Cargar funciones comunes si no están disponibles
+COMMON_LIB="$PROJECT_ROOT/core/lib/translate_msg.sh"
+if ! declare -f render_msg &>/dev/null; then
+ [[ -f "$COMMON_LIB" ]] && source "$COMMON_LIB"
+fi
+
+GLOBAL_TOOLS=("bash" "ssh" "scp" "git" "curl" "jq" "yq" "gpg")
+
+REQUIRED_PATHS=(
+ "$PROJECT_ROOT/core/modules"
+ "$PROJECT_ROOT/core/utils"
+ "$PROJECT_ROOT/core/inventory"
+ "$PROJECT_ROOT/examples"
+ "$PROJECT_ROOT/user_modules"
+ "$PROJECT_ROOT/community_modules"
+ "$PROJECT_ROOT/shflow.sh"
+ "$PROJECT_ROOT/vault.sh"
+)
+
+# 🌐 Cargar traducciones
+lang="${shflow_vars[language]:-es}"
+trfile="$PROJECT_ROOT/core/utils/shflow-check.tr.${lang}"
+declare -A tr
+if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi
+
+check_global_tools() {
+ echo "${tr[tools_header]:-🔍 Verificando herramientas globales...}"
+ local missing=0
+ for tool in "${GLOBAL_TOOLS[@]}"; do
+ if ! command -v "$tool" &> /dev/null; then
+ echo "$(render_msg "${tr[tool_missing]}" "tool=$tool")"
+ missing=1
+ else
+ echo "$(render_msg "${tr[tool_ok]}" "tool=$tool")"
+ fi
+ done
+ return $missing
+}
+
+check_structure() {
+ echo ""
+ echo "${tr[structure_header]:-📁 Verificando estructura de ShFlow...}"
+ local missing=0
+ for path in "${REQUIRED_PATHS[@]}"; do
+ if [ ! -e "$path" ]; then
+ echo "$(render_msg "${tr[path_missing]}" "path=$path")"
+ missing=1
+ else
+ echo "$(render_msg "${tr[path_ok]}" "path=$path")"
+ fi
+ done
+ return $missing
+}
+
+load_and_check_modules() {
+ echo ""
+ echo "${tr[modules_header]:-🔍 Verificando módulos ShFlow...}"
+ for dir in "${MODULE_PATHS[@]}"; do
+ [ -d "$dir" ] || continue
+ while IFS= read -r -d '' mod; do
+ source "$mod"
+ done < <(find "$dir" -type f -name "*.sh" -print0)
+ done
+
+ for func in $(declare -F | awk '{print $3}' | grep '^check_dependencies_'); do
+ echo ""
+ echo "$(render_msg "${tr[checking_func]}" "func=$func")"
+ $func || echo "$(render_msg "${tr[func_warn]}" "func=$func")"
+ done
+}
+
+main() {
+ echo "${tr[title]:-🧪 ShFlow Environment Check}"
+ echo "${tr[separator]:-=============================}"
+
+ check_global_tools
+ check_structure
+ load_and_check_modules
+
+ echo ""
+ echo "${tr[done]:-✅ Verificación completada.}"
+}
+
+main "$@"