Update nodemgmt-scripts.sh
This commit is contained in:
@@ -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 [ "${ST_ACTION}" != "check" ]; then
|
if [ "${srvc}" == "gitea" ]; then
|
||||||
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
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
|
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,23 +1196,25 @@ SERVICES(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
SERVICE(){
|
SERVICE(){
|
||||||
if [ "${NM_SERVICES[${1}]}" = "" ]; then
|
if [ "${3}" != "q"]; then
|
||||||
echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}"
|
if [ "${NM_SERVICES[${1}]}" = "" ]; then
|
||||||
exit 1
|
echo -e "${idsCL[Red]}(${1}) is not an allowed service.${idsCL[Default]}"
|
||||||
fi
|
exit 1
|
||||||
if [ "${NM_SRVCOPTS[${2}]}" = "" ]; then
|
fi
|
||||||
echo -e "${idsCL[Red]}(${2}) is not an allowed service action.${idsCL[Default]}"
|
if [ "${NM_SRVCOPTS[${2}]}" = "" ]; then
|
||||||
exit 1
|
echo -e "${idsCL[Red]}(${2}) is not an allowed service action.${idsCL[Default]}"
|
||||||
fi
|
exit 1
|
||||||
if [ "$2" = "start" ] && [ "$1" = "haproxy" ]; then
|
fi
|
||||||
TACT='restart'
|
if [ "$2" = "start" ] && [ "$1" = "haproxy" ]; then
|
||||||
else
|
TACT='restart'
|
||||||
TACT="${2}"
|
else
|
||||||
fi
|
TACT="${2}"
|
||||||
|
fi
|
||||||
|
|
||||||
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,26 +1229,31 @@ SERVICE(){
|
|||||||
else
|
else
|
||||||
NCMD="ssh root@${nip}"
|
NCMD="ssh root@${nip}"
|
||||||
fi
|
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
|
$NCMD systemctl $2 $1
|
||||||
if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then
|
if [ "${3}" != "q"]; then
|
||||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
if [[ "enable,disable" = *"${2}"* ]] || [ "${1}" = "daemon-reload" ]; then
|
||||||
elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then
|
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||||
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
elif [ "$(${NCMD} systemctl is-active ${1})" = "active" ]; then
|
||||||
elif [ "$2" = "stop" ]; then
|
echo -e "${idsCL[Green]}OK${idsCL[Default]}"
|
||||||
echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}"
|
elif [ "$2" = "stop" ]; then
|
||||||
else
|
echo -e "${idsCL[Red]}STOPPED${idsCL[Default]}"
|
||||||
echo -e "${idsCL[Red]}ERROR${idsCL[Default]}"
|
else
|
||||||
|
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;;
|
||||||
|
|||||||
Reference in New Issue
Block a user