Update nodemgmt-scripts.sh

This commit is contained in:
2019-03-27 00:48:10 -05:00
parent 64a5556559
commit a112e4d333

View File

@@ -162,11 +162,18 @@ STATUS(){
if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then
if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then
if [ "${srvc}" == "gitea" ]; then
else
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
fi fi
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; 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 touch ${FOLDER}/${nip}-${srvc}.down
fi
else else
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
if [ $errtime -gt ${RENOTIFY} ]; then if [ $errtime -gt ${RENOTIFY} ]; then
@@ -1189,6 +1196,7 @@ SERVICES(){
} }
SERVICE(){ SERVICE(){
if [ "${3}" != "q"]; then
if [ "${NM_SERVICES[${1}]}" = "" ]; then if [ "${NM_SERVICES[${1}]}" = "" ]; then
echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}" echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}"
exit 1 exit 1
@@ -1206,6 +1214,7 @@ SERVICE(){
echo echo
echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}" echo -e "${idsCL[LightGreen]}[[${NM_SERVICES[${1}]} ${NM_SRVCOPTS[${2}]}ing]]${idsCL[Default]}"
echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}" echo -e "${idsCL[LightGreen]}-------------------------------------------${idsCL[Default]}"
fi
for NTYPE in "${NODE_TYPES[@]}"; do for NTYPE in "${NODE_TYPES[@]}"; do
@@ -1220,8 +1229,11 @@ SERVICE(){
else else
NCMD="ssh root@${nip}" NCMD="ssh root@${nip}"
fi fi
if [ "${3}" != "q"]; then
echo -en "${NM_SRVCOPTS[${2}]}ing on ${NM_NODETYPES[$NTYPE]}-Node${nid} ($nip)... ${idsCL[Default]}" echo -en "${NM_SRVCOPTS[${2}]}ing on ${NM_NODETYPES[$NTYPE]}-Node${nid} ($nip)... ${idsCL[Default]}"
fi
$NCMD systemctl $2 $1 $NCMD systemctl $2 $1
if [ "${3}" != "q"]; then
if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then
echo -e "${idsCL[Green]}OK${idsCL[Default]}" echo -e "${idsCL[Green]}OK${idsCL[Default]}"
elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then
@@ -1231,15 +1243,17 @@ SERVICE(){
else else
echo -e "${idsCL[Red]}ERROR${idsCL[Default]}" echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"
fi fi
fi
nid=`expr $nid + 1` nid=`expr $nid + 1`
done done
fi fi
done done
if [ "${3}" != "q"]; then
echo "" echo
echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}" echo -e "${idsCL[Green]}${NM_SERVICES[${1}]} has been ${NM_SRVCOPTS[${2}]}ed${idsCL[Default]}"
echo "" echo
fi
} }
HAPROXY-CONFIG() { HAPROXY-CONFIG() {
@@ -1470,7 +1484,7 @@ if [ ${action-x} ]; then
SET-PERMISSIONS gitea SET-PERMISSIONS gitea
SERVICE gitea start SERVICE gitea start
else else
SERVICE ${2} ${3} SERVICE ${2} ${3} ${4}
fi;; fi;;
services) SERVICES;; services) SERVICES;;
haproxy-config) HAPROXY-CONFIG;; haproxy-config) HAPROXY-CONFIG;;