From 6ef99ef2eaf307ee7d029906c4edbfbf6f49c1fb Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 9 Mar 2024 12:05:55 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 53ef43b8..54182631 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -332,28 +332,27 @@ NODEUPDATES() { if [[ ${RUN_NODE_IP} == *"${nip}"* ]]; then nip='localhost ' fi - echo "HERE: ${nip} - ${2}" - NODEUPDATE "${nip}" "${2}" "${NMCMD}" ###& + NODEUPDATE "${nip}" "${2}" "${NMCMD}" & ((ncount++)) done done - # nc_count=0; completed=false - # until [ "${completed}" == "true" ]; do - # for nodecmd in /tmp/.nodeupdate.*.done; do - # if [[ "${nodecmd}" != *"*"* ]]; then - # nodecmd_output=$(cat ${nodecmd}) - # [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}" - # rm -f ${nodecmd} - # ((nc_count++)) - # fi - # done - # if [ ${nc_count} -eq ${ncount} ]; then - # completed=true - # break - # fi - # sleep 2s - # done + nc_count=0; completed=false + until [ "${completed}" == "true" ]; do + for nodecmd in /tmp/.nodeupdate.*.done; do + if [[ "${nodecmd}" != *"*"* ]]; then + nodecmd_output=$(cat ${nodecmd}) + [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}" + rm -f ${nodecmd} + ((nc_count++)) + fi + done + if [ ${nc_count} -eq ${ncount} ]; then + completed=true + break + fi + sleep 2s + done echo -e "${idsCL[Green]}All Nodes have been Updated.${idsCL[Default]}" echo @@ -403,9 +402,9 @@ NODEUPDATE(){ ${NCMD} "nodemgmt update q" >> ${tmpfile}.running fi else - echo -en " ~ ${idsCL[LightCyan]}Sync Shared Nodemgmt Defaults${idsCL[Default]} : " ###>> ${tmpfile}.running - ${NMCMD} rsync -az ${NM_FOLDER}/conf/*.inc ${NM_FOLDER}/conf/*.conf root@${nip}:${NM_FOLDER}/conf/ ###& >/dev/null 2>&1 - echo -e "${idsCL[Green]}Files Synced${idsCL[Default]}" ###>> ${tmpfile}.running + echo -en " ~ ${idsCL[LightCyan]}Sync Shared Nodemgmt Defaults${idsCL[Default]} : " >> ${tmpfile}.running + ${NMCMD} rsync -az ${NM_FOLDER}/conf/*.inc ${NM_FOLDER}/conf/*.conf root@${nip}:${NM_FOLDER}/conf/ >/dev/null 2>&1 + echo -e "${idsCL[Green]}Files Synced${idsCL[Default]}" >> ${tmpfile}.running fi else echo -e " ~ ${idsCL[LightCyan]}NodeMGMT${idsCL[Default]} : Skipping BETA Update" >> ${tmpfile}.running @@ -415,7 +414,7 @@ NODEUPDATE(){ else echo -e " ~ ${idsCL[LightCyan]}Skipping${idsCL[Default]}" >> ${tmpfile}.running fi - mv ${tmpfile}.running ${tmpfile}.done + [ -f ${tmpfile}.running ] && mv ${tmpfile}.running ${tmpfile}.done || touch ${tmpfile}.done } ADD_LOGROTATE_CRONTAB(){ @@ -1215,7 +1214,7 @@ GUI(){ if [ "${2}" == "report" ]; then [ "${3}" == "sync" ] && ufile=update-nodes-sync.lastrun || ufile=update-nodes.lastrun rm -f ${NM_LOGFOLDER}/${ufile} - NODEUPDATES ${2} ${3} ###> ${NM_LOGFOLDER}/${ufile} + NODEUPDATES ${2} ${3} > ${NM_LOGFOLDER}/${ufile} else NODEUPDATES ${2} ${3} fi