diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 77b62ec6..6c90cc5e 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -94,35 +94,45 @@ NIGHTLYRENEW(){ } DELSITE(){ - DEL_SITE=${1} - echo -e "${idsCL[LightRed]}Deleting site '${idsCL[Red]}${DEL_SITE}${idsCL[LightRed]}'...${idsCL[Default]}" - echo "" + if [ ! -z ${1+x} ]; then + DEL_SITE=${1} + echo -e "${idsCL[LightRed]}Deleting site '${idsCL[Red]}${DEL_SITE}${idsCL[LightRed]}'...${idsCL[Default]}" + echo "" - echo -e "${idsCL[LightRed]}[[Removing Files and Folders]]${idsCL[Default]}" - echo -e "${idsCL[LightRed]}-------------------------------------------${idsCL[Default]}" + echo -e "${idsCL[LightRed]}[[Removing Files and Folders]]${idsCL[Default]}" + echo -e "${idsCL[LightRed]}-------------------------------------------${idsCL[Default]}" - nid=1 - for nip in "${NODE_HOSTS[@]}" - do - if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then - nip='localhost ' - NCMD='' - else - NCMD="ssh root@${nip}" - fi - echo -en "Removing from iDS-Node${nid} ($nip)... ${idsCL[Default]}" - ${NCMD} rm -f /etc/nginx/sites-available/${DEL_SITE}.conf - ${NCMD} rm -f /etc/nginx/sites-enabled/${DEL_SITE}.conf - ${NCMD} rm -rf /var/www/${DEL_SITE} - ${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 - echo -e "${idsCL[Green]}OK${idsCL[Default]}" - nid=`expr $nid + 1` - done - echo "" - ${FOLDER}/nodemgmt-scripts.sh service nginx reload - echo -e "${idsCL[LightRed]}Site has been deleted.${idsCL[Default]}" + nid=1 + for nip in "${NODE_HOSTS[@]}" + do + if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then + nip='localhost ' + NCMD='' + else + NCMD="ssh root@${nip}" + fi + echo -en "Removing from iDS-Node${nid} ($nip)... ${idsCL[Default]}" + if [ -f /etc/nginx/sites-available/${DEL_SITE}.conf ]; then + ${NCMD} rm -f /etc/nginx/sites-available/${DEL_SITE}.conf + ${NCMD} rm -f /etc/nginx/sites-enabled/${DEL_SITE}.conf + fi + 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 + fi + echo -e "${idsCL[Green]}OK${idsCL[Default]}" + nid=`expr $nid + 1` + done + echo "" + ${FOLDER}/nodemgmt-scripts.sh service nginx reload + echo -e "${idsCL[LightRed]}Site has been deleted.${idsCL[Default]}" + else + echo -e "${idsCL[LightRed]}No site was defined.${idsCL[Default]}" + fi } NEWSITE(){