From 32bb943ec6e96c59eb6c3e580e34d232fe5a7429 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 1 Dec 2024 18:25:38 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 60 +++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 76c8f548..a5eaa04d 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -771,41 +771,43 @@ BACKUP_UNIFINVR(){ } RUN_COMMAND(){ - RUNCMD='' while [ $# -gt 0 ]; do case "${1}" in -nt|-nodetype) nodetype=${2^^};; - *) RUNCMD="${RUNCMD}${1} ";; + -cmd) RUNCMD="${2}";; esac shift done - echo "NODETYPE= '${nodetype}'" - echo "RUNCMD= '${RUNCMD}'" - - # for NTYPE in "${NM_NODE_TYPES[@]}"; do - # echo -e "${idsST[Bold]}"; DIVIDER - # RUNCMD='' - # for i in {1..14}; do - # [ "${i}" != "1" ] && [ "${!i}" != "" ] && RUNCMD="${RUNCMD} " - # [ "${!i}" != "" ] && RUNCMD="${RUNCMD}${!i}" - # done - # echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Nodes to run command { \`${RUNCMD}\` }${idsCL[Default]}" - # DIVIDER; echo -e "${idsST[Reset]}" - # - # var=${NTYPE}_HOSTS[@] - # for nip in "${!var}"; do - # if [[ ${RUN_NODE_IP} == *"${nip}"* ]]; then NCMD=''; LH='- localhost' - # else NCMD="ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${nip}"; LH='' - # fi - # echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_HOSTNAMES[${nip}]}[${nip}]${idsST[Reset]}${idsCL[LightCyan]} ${idsCL[LightYellow]}${LH}${idsCL[Default]}" - # DIVIDER false green - # #echo "Running command: ${NCMD} ${RUNCMD}" - # ${NCMD} "${RUNCMD}" - # DIVIDER false green - # echo - # done - # echo - # done + if [ "${nodetype}" == "ALL" ] || ; then + NT_HOSTS=ALL_HOSTS[@] + NTS=(${NM_NODE_TYPES[*]}) + elif [ "${nodetype}" != "" ]; then + if [ "${NM_HOSTS[${nodetype}]}" != "" ]; then + NT_HOSTS=${nodetype}_HOSTS[@] + NTS=("${nodetype}"); + else + echo -e "${idsCL[Red]}"${nodetype}" is an unknown NodeType.${idsCL[Default]}" + exit 1 + fi + fi + for NTYPE in "${NTS[@]}"; do + echo -e "${idsST[Bold]}"; DIVIDER + echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Nodes to run command { \`${RUNCMD}\` }${idsCL[Default]}" + DIVIDER; echo -e "${idsST[Reset]}" + + for nip in "${!NT_HOSTS}"; do + if [[ ${RUN_NODE_IP} == *"${nip}"* ]]; then NCMD=''; LH='- localhost' + else NCMD="ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${nip}"; LH='' + fi + echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_HOSTNAMES[${nip}]}[${nip}]${idsST[Reset]}${idsCL[LightCyan]} ${idsCL[LightYellow]}${LH}${idsCL[Default]}" + DIVIDER false green + echo "Running command: ${NCMD} ${RUNCMD}" + #${NCMD} "${RUNCMD}" + DIVIDER false green + echo + done + echo + done } DOWNLIST(){