From 1d0cd9a797cb3c5e49f4181ec6dd960c3269f537 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 27 Mar 2019 01:00:13 -0500 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index de58fe36..f228f6b8 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -163,9 +163,27 @@ STATUS(){ if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then if [ "${srvc}" == "gitea" ]; then - echo - - + SERVICE gitea stop q + SET-PERMISSIONS gitea q + SERVICE gitea start q + if [ "${ST_ACTION}" != "check" ]; then + if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then + echo -e "${idsCL[Red]}Not Running - could not fix${idsCL[Default]}" + if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down. Could not fix." | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi + touch ${FOLDER}/${nip}-${srvc}.down + else + echo -e "${idsCL[Red]}Running - FIXED${idsCL[Default]}" + if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then + if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime) + else + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) + fi + if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is back UP! (!!FIXED!!) It was down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi + rm -f ${FOLDER}/${nip}-${srvc}.down + rm -f ${FOLDER}/${nip}-${srvc}.errtime + fi + fi else if [ "${ST_ACTION}" != "check" ]; then @@ -1041,12 +1059,16 @@ SET-PERMISSIONS(){ else NCMD="ssh root@${nip}" fi - echo -en "${idsCL[Yellow]}Resetting folder permissions for Gitea on Webserver-Node${nid} (${nip})... ${idsCL[Default]}" + if [ "${2}" != "q" ]; then + echo -en "${idsCL[Yellow]}Resetting folder permissions for Gitea on Webserver-Node${nid} (${nip})... ${idsCL[Default]}" + fi ${NCMD} chown -R git:git /var/lib/gitea ${NCMD} chmod -R 750 /var/lib/gitea ${NCMD} chown -R git:git /home/git ${NCMD} chmod -R 750 /home/git - echo -e "${idsCL[Green]}Complete${idsCL[Default]}" + if [ "${2}" != "q" ]; then + echo -e "${idsCL[Green]}Complete${idsCL[Default]}" + fi done else DIVIDER