diff options
| author | luisgulo <luisgulo@gmail.com> | 2025-10-24 18:01:10 +0200 |
|---|---|---|
| committer | luisgulo <luisgulo@gmail.com> | 2025-10-24 18:01:10 +0200 |
| commit | 533e79ba959143f0459431a486bfb85c56c72ddc (patch) | |
| tree | 91974de1bbbdc4c51c76ed591fc5c6e02a3342b6 /community_modules/winremote/winremote_check.sh | |
| parent | 45019c81cfd0fc1d18dce18cdfd5f127c6d61073 (diff) | |
Releasing code version 1.8.0
Diffstat (limited to 'community_modules/winremote/winremote_check.sh')
| -rw-r--r-- | community_modules/winremote/winremote_check.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/community_modules/winremote/winremote_check.sh b/community_modules/winremote/winremote_check.sh new file mode 100644 index 0000000..4f0d608 --- /dev/null +++ b/community_modules/winremote/winremote_check.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Module: winremote_check +# Description: Verifica conectividad y ejecución remota básica en equipos Windows mediante SSH y PowerShell +# License: GPLv3 +# Author: Luis GuLo +# Version: 1.2.0 +# Dependencies: ssh, powershell (en el host remoto) + +winremote_check_task() { + local host="$1"; shift + declare -A args + for arg in "$@"; do key="${arg%%=*}"; value="${arg#*=}"; args["$key"]="$value"; done + + local winuser="${args[winuser]}" + local winpassword="${args[winpassword]}" + local port="${args[port]:-22}" + local command="Write-Output 'Conexión establecida desde ShFlow'" + + # 🌐 Cargar traducciones + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_check.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if [[ -z "$host" || -z "$winuser" || -z "$winpassword" ]]; then + echo "${tr[missing_args]:-❌ [winremote_check] Parámetros incompletos. Se requiere host, winuser y winpassword.}" + return 1 + fi + + [[ "$host" == *@* ]] && host=$(echo "$host" | awk -F '@' '{print $2}') + + echo "$(render_msg "${tr[start]}" "host=$host")" + + if sshpass -p "$winpassword" ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no -p "$port" "$winuser@$host" powershell -Command "\"$command\"" &>/dev/null; then + echo "$(render_msg "${tr[success]}" "host=$host")" + return 0 + else + echo "$(render_msg "${tr[fail]}" "host=$host")" + return 1 + fi +} + +check_dependencies_winremote_check() { + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/winremote_check.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if ! command -v ssh &> /dev/null; then + echo "${tr[missing_ssh]:-❌ [winremote_check] ssh no está disponible.}" + return 1 + fi + echo "${tr[ssh_ok]:-✅ [winremote_check] ssh disponible.}" + return 0 +} |
