Update nodemgmt-scripts.sh
This commit is contained in:
@@ -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;;
|
||||
|
||||
Reference in New Issue
Block a user