From eef2a0c0b9ba56c41d0deb8f1a79afe1108a1a37 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 11 Feb 2019 16:55:34 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 63 ++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 5cf8653b..6b1aa605 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -511,39 +511,44 @@ DEL-SSL(){ DEL_SSL=${1} fi if [ ! -z ${DEL_SSL+x} ] && [ "${DEL_SSL}" != "" ]; then - echo -e "${idsCL[LightRed]}Deleting the SSL certificates for '${idsCL[Red]}${DEL_SSL}${idsCL[LightRed]}'...${idsCL[Default]}" - echo "" + if [ -d /etc/letsencrypt/live/${DEL_SSL} ]"; then + echo -e "${idsCL[LightRed]}Deleting the SSL certificates for '${idsCL[Red]}${DEL_SSL}${idsCL[LightRed]}'...${idsCL[Default]}" + echo "" - echo -en "${idsCL[LightRed]}Removing Files and Folders... ${idsCL[Default]}" - # rm -rf /etc/letsencrypt/archive/${DEL_SITE} - # rm -rf /etc/letsencrypt/live/${DEL_SITE} - # rm -f /etc/letsencrypt/renewal/${DEL_SITE}.conf - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - echo "" - echo -en "${idsCL[LightYellow]}Waiting for certificate replication between the nodes... ${idsCL[Default]}" - checked=false - timeout=`date --date='2 minutes' +%s` - until [ "${checked}" = "" ]; do - tchecked='' - for nip in "${NODE_HOSTS[@]}"; do - if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD='' - else NCMD="ssh root@${nip}" - fi - if [ "${NCMD}" != "" ]; then - if ${NCMD} "[ -d /etc/letsencrypt/live/${DEL_SITE} ]"; then - tchecked+=false - else - tchecked+='' + echo -en "${idsCL[LightRed]}Removing Files and Folders... ${idsCL[Default]}" + rm -rf /etc/letsencrypt/archive/${DEL_SITE} + rm -rf /etc/letsencrypt/live/${DEL_SITE} + rm -f /etc/letsencrypt/renewal/${DEL_SITE}.conf + echo -e "${idsCL[Green]}OK${idsCL[Default]}" + echo "" + echo -en "${idsCL[LightYellow]}Waiting for certificate replication between the nodes... ${idsCL[Default]}" + checked=false + timeout=`date --date='2 minutes' +%s` + until [ "${checked}" = "" ]; do + tchecked='' + for nip in "${NODE_HOSTS[@]}"; do + if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD='' + else NCMD="ssh root@${nip}" fi + if [ "${NCMD}" != "" ]; then + if ${NCMD} "[ -d /etc/letsencrypt/live/${DEL_SSL} ]"; then + tchecked+=false + else + tchecked+='' + fi + fi + done + checked=${tchecked} + if [ "`date +%s`" -gt "$timeout" ]; then + echo -e "${idsCL[Red]}Timeout${idsCL[Default]}" + timeout=true + break fi done - checked=${tchecked} - if [ "`date +%s`" -gt "$timeout" ]; then - echo -e "${idsCL[Red]}Timeout${idsCL[Default]}" - timeout=true - break - fi - done + else + echo -e "${idsCL[LightRed]}The SSL files folder for '${idsCL[Red]}${DEL_SSL}${idsCL[LightRed]}' could not be found.${idsCL[Default]}" + exit 1 + fi if [ "${timeout}" != "true" ]; then echo -e "${idsCL[Green]}Completed${idsCL[Default]}" fi