diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index b16bed1a..4dfad44e 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -739,8 +739,7 @@ DELSITE(){ echo -e "${idsCL[LightRed]}-------------------------------------------${idsCL[Default]}" nid=1 - for nip in "${WEB_HOSTS[@]}" - do + for nip in "${WEB_HOSTS[@]}"; do if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then nip='localhost ' NCMD='' @@ -748,19 +747,26 @@ DELSITE(){ NCMD="ssh root@${nip}" fi echo -en "Removing from Webserver-Node${nid} ($nip)... ${idsCL[Default]}" - #if [ -f /etc/nginx/sites-available/${DEL_SITE} ]; then - ${NCMD} rm -f /etc/nginx/sites-available/${DEL_SITE} - ${NCMD} rm -f /etc/nginx/sites-enabled/${DEL_SITE} - #fi - #if [ -d /var/www/${DEL_SITE} ]; then - ${NCMD} rm -rf /var/www/${DEL_SITE} - #fi - if [ "${DEL_SSL}" = "yes" ]; 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 [ "${NCMD}" != "" ]; then + checkhost=$(CHECK_HOST ${nip}) + fi + if [ "${checkhost}" != "false" ]; then + #if [ -f /etc/nginx/sites-available/${DEL_SITE} ]; then + ${NCMD} rm -f /etc/nginx/sites-available/${DEL_SITE} + ${NCMD} rm -f /etc/nginx/sites-enabled/${DEL_SITE} + #fi + #if [ -d /var/www/${DEL_SITE} ]; then + ${NCMD} rm -rf /var/www/${DEL_SITE} + #fi + if [ "${DEL_SSL}" = "yes" ]; 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]}" + else + echo -e "${idsCL[Red]}Node is down${idsCL[Default]}" fi - echo -e "${idsCL[Green]}OK${idsCL[Default]}" nid=`expr $nid + 1` done echo "" @@ -784,7 +790,10 @@ DELSITES(){ echo -e "${idsCL[Red]}Select a site to delete...${idsCL[Default]}" DIVIDER true sid=1 - for siteconf in /etc/nginx/sites-available/* ; do + filels="( $(ssh root@10.5.10.121 ls '/etc/nginx/sites-available/*') )" + #IFS='\n' + for siteconf in $filels; do + # for siteconf in /etc/nginx/sites-available/* ; do [ -e "$siteconf" ] || continue IFS='/'; site_conf=(${siteconf}); unset IFS SITES[${sid}]=${site_conf[4]}