From a112e4d3330c1b7e3a6f3c320c49ef48d095d5dc Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 27 Mar 2019 00:48:10 -0500 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 82 ++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 55799ba5..55719ba2 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -162,11 +162,18 @@ STATUS(){ if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then - if [ "${ST_ACTION}" != "check" ]; then - echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" + if [ "${srvc}" == "gitea" ]; then + + + + else + + if [ "${ST_ACTION}" != "check" ]; then + echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" + fi + if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi + touch ${FOLDER}/${nip}-${srvc}.down fi - if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi - touch ${FOLDER}/${nip}-${srvc}.down else errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) if [ $errtime -gt ${RENOTIFY} ]; then @@ -1189,23 +1196,25 @@ SERVICES(){ } SERVICE(){ - if [ "${NM_SERVICES[${1}]}" = "" ]; then - echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}" - exit 1 - fi - if [ "${NM_SRVCOPTS[${2}]}" = "" ]; then - echo -e "${idsCL[Red]}(${2}) is not an allowed service action.${idsCL[Default]}" - exit 1 - fi - if [ "$2" = "start" ] && [ "$1" = "haproxy" ]; then - TACT='restart' - else - TACT="${2}" - fi + if [ "${3}" != "q"]; then + if [ "${NM_SERVICES[${1}]}" = "" ]; then + echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}" + exit 1 + fi + if [ "${NM_SRVCOPTS[${2}]}" = "" ]; then + echo -e "${idsCL[Red]}(${2}) is not an allowed service action.${idsCL[Default]}" + exit 1 + fi + if [ "$2" = "start" ] && [ "$1" = "haproxy" ]; then + TACT='restart' + else + TACT="${2}" + fi - echo - echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}" - echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}" + echo + echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}" + echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}" + fi for NTYPE in "${NODE_TYPES[@]}"; do @@ -1220,26 +1229,31 @@ SERVICE(){ else NCMD="ssh root@${nip}" fi - echo -en "${NM_SRVCOPTS[${2}]}ing on ${NM_NODETYPES[$NTYPE]}-Node${nid} ($nip)... ${idsCL[Default]}" + if [ "${3}" != "q"]; then + echo -en "${NM_SRVCOPTS[${2}]}ing on ${NM_NODETYPES[$NTYPE]}-Node${nid} ($nip)... ${idsCL[Default]}" + fi $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]}" + if [ "${3}" != "q"]; then + 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 fi nid=`expr $nid + 1` done fi done - - echo "" - echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}" - echo "" + if [ "${3}" != "q"]; then + echo + echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}" + echo + fi } HAPROXY-CONFIG() { @@ -1470,7 +1484,7 @@ if [ ${action-x} ]; then SET-PERMISSIONS gitea SERVICE gitea start else - SERVICE ${2} ${3} + SERVICE ${2} ${3} ${4} fi;; services) SERVICES;; haproxy-config) HAPROXY-CONFIG;;