From 4a6e8672d6e583bee49a74a7747aa13e4ec4b435 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 27 Jan 2019 21:57:48 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 1282da08..9bfeba6e 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -79,31 +79,17 @@ case "$1" in STA="$(tr '[:lower:]' '[:upper:]' <<< ${3:0:1})${3:1}" echo -e "${idsCL[LightGreen]}[[${SER} ${STA}ing]]${idsCL[Default]}" - for i in "${node_hosts[@]}" + nid=1 + for nip in "${node_hosts[@]}" do - echo "Here: ${i}" + echo -en "${idsCL[Cyan]}${STA}ing Node ${nid}...${idsCL[Default]}" + ssh root@${nip} systemctl $3 $2 + if [[ $(ssh root@${nip} ps -ef | grep -c ${2}) -ne 1 ]]; then + echo -e "${idsCL[Green]}OK${idsCL[Default]}" + else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" + fi + nid=`expr $nid + 1` done - - echo -en "${idsCL[Cyan]}${STA}ing Node 1...${idsCL[Default]}" - ssh root@10.5.10.51 systemctl $3 $2 - if [[ $(ssh root@10.5.10.51 ps -ef | grep -c ${2}) -ne 1 ]]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi - - echo -en "${idsCL[Cyan]}${STA}ing Node 2...${idsCL[Default]}" - ssh root@10.5.10.52 systemctl $3 $2 - if [[ $(ssh root@10.5.10.52 ps -ef | grep -c ${2}) -ne 1 ]]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi - - echo -en "${idsCL[Cyan]}${STA}ing Node 3...${idsCL[Default]}" - ssh root@10.5.10.53 systemctl $3 $2 - if [[ $(ssh root@10.5.10.53 ps -ef | grep -c ${2}) -ne 1 ]]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi echo "" echo -e "${idsCL[Green]}${SER} has been ${STA}ed${idsCL[Default]}"