From 0974ef3f15787a442a97da8bbad385212764ab39 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 27 Mar 2019 00:27:22 -0500 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 111 ++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 75 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index f1bf83f7..a8f89e96 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -1205,81 +1205,35 @@ SERVICE(){ echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}" echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}" - if [[ "${MYSQLSERVICES_CHECK}" = *"${1}"* ]]; then - nid=1 - for nip in "${MYSQL_HOSTS[@]}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then - nip='localhost ' - NCMD='' - else - NCMD="ssh root@${nip}" - fi - echo -en "${NM_SRVCOPTS[${2}]}ing on MySQL-Node${nid} ($nip)... ${idsCL[Default]}" - if [ "$1" = "gitea" ] && [ "$2" = "restart" ]; then - $NCMD systemctl stop $1 - SET-PERMISSIONS gitea - $NCMD systemctl start $1 - else + + for NTYPE in "${NODE_TYPES[@]}"; do + var1=${NTYPE}SERVICES_CHECK + if [[ "${!var}" = *"${1}"* ]]; then + nid=1 + var=${NTYPE}_HOSTS[@] + for nip in "${!var}"; do + if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then + nip='localhost ' + NCMD='' + else + NCMD="ssh root@${nip}" + fi + echo -en "${NM_SRVCOPTS[${2}]}ing on ${NM_NODETYPES[$NTYPE]}-Node${nid} ($nip)... ${idsCL[Default]}" $NCMD systemctl $2 $1 - fi - if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$2" = "stop" ]; then - echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}" - else - echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi - nid=`expr $nid + 1` - done - fi - if [[ "${WEBSERVICES_CHECK}" = *"${1}"* ]]; then - nid=1 - for nip in "${WEB_HOSTS[@]}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then - nip='localhost ' - NCMD='' - else - NCMD="ssh root@${nip}" - fi - echo -en "${NM_SRVCOPTS[${2}]}ing on Webserver-Node${nid} ($nip)... ${idsCL[Default]}" - $NCMD systemctl $2 $1 - if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$2" = "stop" ]; then - echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}" - else - echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi - nid=`expr $nid + 1` - done - fi - if [[ "${LBSERVICES_CHECK}" = *"${1}"* ]]; then - nid=1 - for nip in "${LB_HOSTS[@]}"; do - if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then - nip='localhost ' - NCMD='' - else - NCMD="ssh root@${nip}" - fi - echo -en "${NM_SRVCOPTS[${2}]}ing on LB-Node${nid} ($nip)... ${idsCL[Default]}" - $NCMD systemctl $2 $1 - if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - elif [ "$2" = "stop" ]; then - echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}" - else - echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" - fi - nid=`expr $nid + 1` - done - fi + if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then + echo -e "${idsCL[Green]}OK${idsCL[Default]}" + elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then + echo -e "${idsCL[Green]}OK${idsCL[Default]}" + elif [ "$2" = "stop" ]; then + echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}" + else + echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" + fi + nid=`expr $nid + 1` + done + fi + done + echo "" echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}" @@ -1508,7 +1462,14 @@ if [ ${action-x} ]; then status) STATUS ${2};; status-check) STATUS-CHECK ${2};; set-permissions) SET-PERMISSIONS ${2};; - service) SERVICE ${2} ${3};; + service) + if [ "$2" = "gitea" ] && [ "$3" = "restart" ]; then + SERVICE gitea stop + SET-PERMISSIONS gitea + SERVICE gitea start + else + SERVICE ${2} ${3} + fi;; services) SERVICES;; haproxy-config) HAPROXY-CONFIG;; keepalive-config) KEEPALIVE-CONFIG;;