Update nodemgmt-scripts.sh

This commit is contained in:
2019-10-01 23:14:05 -05:00
parent b2f4cfe9c1
commit d96e876352

View File

@@ -390,36 +390,7 @@ NEWCERT(){
echo -e "${NEW_CERT}\n${daterun}" > ${FOLDER}/cert-request.lastrun
yes | cp -rfH ${FOLDER}/cert-request.lastrun /etc/letsencrypt/cert-request.lastrun
DIVIDER true
echo -e "Since this certificate is tied to a site in NGINX, we will reload NGINX across the nodes."
echo -en "${idsCL[LightYellow]}Waiting for certificate replication across the nodes... ${idsCL[Default]}"
checked=false
timeout=`date --date='2 minutes' +%s`
until [ "${checked}" = "" ]; do
tchecked=''
for nip in "${WEB_HOSTS[@]}"; do
checkhost=$(CHECK_HOST ${nip})
if [ "${checkhost}" != "false" ]; then
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''
else NCMD="ssh root@${nip}"
fi
if [ "${NCMD}" != "" ]; then
tchecked+=`${NCMD} "cat /etc/letsencrypt/cert-request.lastrun" | diff - /etc/letsencrypt/cert-request.lastrun`
fi
fi
done
checked=${tchecked}
if [ "`date +%s`" -gt "$timeout" ]; then
echo -e "${idsCL[Red]}Timeout${idsCL[Default]}"
timeout=true
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "Timeout occurred in waiting for replication between nodes. (${NEW_CERT})" | mail -s "Cert-Request" ${STATUS_CHECK_EMAIL}; fi
break
fi
done
if [ "${timeout}" != "true" ]; then
echo -e "${idsCL[Green]}Completed${idsCL[Default]}"
fi
echo
`service nginx reload`
SERVICE nginx reload
fi
echo
echo -e "${idsCL[Green]}Certificate has been successfully created for '${idsCL[Yellow]}${NEW_CERT}${idsCL[Green]}'...${idsCL[Default]}"
@@ -546,7 +517,7 @@ CERTRENEW(){
echo -e "${idsCL[Green]}Completed${idsCL[Default]}"
fi
echo
SERVICE nginx reload 2>&1 | tee -a ${FOLDER}/cert-renewal.lastrun
SERVICE nginx reload ns 2>&1 | tee -a ${FOLDER}/cert-renewal.lastrun
echo -e "${idsCL[LightGreen]}The certificates have been renewed.${idsCL[Default]}"
echo ""
if [ -z $action ] || [ "${action}" = "gui" ]; then
@@ -580,7 +551,7 @@ NIGHTLYRENEW(){
break
fi
done
SERVICE nginx reload &>> ${FOLDER}/cert-renewal.lastrun
SERVICE nginx reload ns &>> ${FOLDER}/cert-renewal.lastrun
}
LISTCERTS(){
@@ -770,7 +741,7 @@ DELSITE(){
nid=`expr $nid + 1`
done
echo ""
SERVICE nginx reload
SERVICE nginx reload ns
echo -e "${idsCL[LightRed]}Site has been deleted.${idsCL[Default]}"
else
echo "Missing arguments"
@@ -1087,7 +1058,7 @@ NEWSITE(){
fi
echo
SERVICE nginx reload
SERVICE nginx reload ns
echo ""
echo -e "${idsCL[LightGreen]}The new site for '${idsCL[LightGreen]}${NEW_SITE}${idsCL[Default]}' has been created.${idsCL[Default]}"
echo ""
@@ -1311,6 +1282,7 @@ SERVICE(){
fi
PH_CMD="ssh root@${WEB_HOSTS[0]}"
${PH_CMD} "echo -e \"Service ${1} ${2}\" > /etc/nginx/test.repl"
${PH_CMD} "echo -e \"Service ${1} ${2}\" > /etc/letsencrypt/test.repl"
for nip in "${WEB_HOSTS[@]}"; do
checkhost=$(CHECK_HOST ${nip})
if [ "${checkhost}" != "false" ]; then
@@ -1318,11 +1290,13 @@ SERVICE(){
checked=false
until [ "${checked}" = "" ]; do
checked="`${PH_CMD} \"ssh root@${nip} \"cat /etc/nginx/test.repl\" | diff - /etc/nginx/test.repl\"`"
checked="`${PH_CMD} \"ssh root@${nip} \"cat /etc/letsencrypt/test.repl\" | diff - /etc/letsencrypt/test.repl\"`"
done
fi
fi
done
${PH_CMD} rm -f /etc/nginx/test.repl
${PH_CMD} rm -f /etc/letsencrypt/test.repl
fi
fi
fi