diff --git a/createVhosts.sh b/createVhosts.sh index fb70377..42685cc 100755 --- a/createVhosts.sh +++ b/createVhosts.sh @@ -49,6 +49,15 @@ function reload_nginx sleep 0.5 } +function clean_up +{ + debug "Removing Nginx configuration and logs..." + rm $_vhost_conf_file + rm /var/log/nginx/$_domain.* + reload_nginx + err $1 +} + function verify_vhost { local target=127.0.0.1 @@ -72,12 +81,6 @@ function verify_vhost fi } -function rm_vhost_conf -{ - echo "Removing Nginx configuration" - rm $_vhost_conf_file -} - _cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" _bootstrap=${_cwd}/bootstrap.sh _bb_myname=$(basename "$0") @@ -262,16 +265,12 @@ reload_nginx echo "Verifying vhost..." if ! verify_vhost; then - rm_vhost_conf - reload_nginx - err "Failed to verify vhost" + clean_up "Failed to verify vhost" fi echo "Retrieving Let's Encrypt Certificate..." if ! get_cert; then - rm_vhost_conf - reload_nginx - err "Failed to retrieve certificate!" + clean_up "Failed to retrieve certificate!" fi cat << EOF >> $_vhost_conf_file