From b55b7845bcd4bead8c86261898cd52e773840197 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 28 Jan 2019 11:46:25 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 02c56dfb..d2d1b016 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -34,9 +34,15 @@ case "$1" in nid=1 for nip in "${NODE_HOSTS[@]}" do + if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then + nip='localhost' + NCMD='' + else + NCMD="ssh root@${nip}" + fi echo -en "${ADISP}ing Node ${nid} ($nip)...${idsCL[Default]}" - ssh root@${nip} systemctl $3 $2 - if [[ $(is_service_running ${nip} ${2}) -gt "1" ]]; then + $NCMD systemctl $3 $2 + if [[ $(${NCMD} pgrep mysql | wc -l) -gt "1" ]]; then echo -e "${idsCL[Green]}OK${idsCL[Default]}" elif [ "$3" = "Stop" ]; then echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}" else echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"