From febe3dc044fe04ca1dbaba61634d45fd252d938d Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 5 Feb 2019 22:24:30 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index e3b092f9..00abce85 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -176,8 +176,24 @@ BACKUP(){ } DELSITE(){ - if [ ! -z ${1+x} ]; then - DEL_SITE=${1} + while [ $# -gt 0 ]; do + case "$1" in + -site) DEL_SITE=${2};; + -ssl) DEL_SSL=${2};; + -*) + echo "Invalid option: '${1}' requires an argument" 1>&2 + echo "" + echo -e "Usage: ${idsCL[Yellow]}nodemgmt delsite${idsCL[Default]} {" + width=33 + printf "%-${width}s- %s\n" " -site {FQDN address}" "(*required)" + printf "%-${width}s- %s\n" " -ssl {yes or [no]}" "Delete SSL certs as well" + echo "}" + exit 1;; + esac + shift + done + if [ -z ${DEL_SSL+x} ]; then DEL_SSL=no; fi + if [ ! -z ${DEL_SITE+x} ]; then echo -e "${idsCL[LightRed]}Deleting site '${idsCL[Red]}${DEL_SITE}${idsCL[LightRed]}'...${idsCL[Default]}" echo "" @@ -201,10 +217,12 @@ DELSITE(){ if [ -d /var/www/${DEL_SITE} ]; then ${NCMD} rm -rf /var/www/${DEL_SITE} fi - if [ -d /etc/letsencrypt/archive/${DEL_SITE} ]; then - ${NCMD} rm -rf /etc/letsencrypt/archive/${DEL_SITE} - ${NCMD} rm -rf /etc/letsencrypt/live/${DEL_SITE} - ${NCMD} rm -f /etc/letsencrypt/renewal/${DEL_SITE}.conf + if [ "${DEL_SSL}" = "yes" ]; then + if [ -d /etc/letsencrypt/archive/${DEL_SITE} ]; then + ${NCMD} rm -rf /etc/letsencrypt/archive/${DEL_SITE} + ${NCMD} rm -rf /etc/letsencrypt/live/${DEL_SITE} + ${NCMD} rm -f /etc/letsencrypt/renewal/${DEL_SITE}.conf + fi fi echo -e "${idsCL[Green]}OK${idsCL[Default]}" nid=`expr $nid + 1` @@ -255,7 +273,7 @@ DELSITES(){ read response echo "" if [[ $response =~ ^[Yy]$ ]]; then - echo -e -n "${idsCL[LightRed]}Do you also want to delete the certs for '${SITES[${selsite}]}' as well?${idsCL[Default]} " + echo -e -n "${idsCL[LightRed]}Do you also want to delete the certs for '${SITES[${selsite}]}' as well? [y/N]${idsCL[Default]} " read sslresponse echo "delete - '${sslresponse}'" ENTER2CONTINUE @@ -607,7 +625,7 @@ if [ ${action-x} ]; then certrenew) CERTRENEW;; listcerts) LISTCERTS;; nightlyrenew) NIGHTLYRENEW;; - delsite) DELSITE ${2};; + delsite) DELSITE ${2} ${3} ${4} ${5};; delsites) DELSITES;; newsite) NEWSITE ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14};; update) ;;