diff --git a/createVhosts.sh b/createVhosts.sh index 9e60a82..b24f8be 100755 --- a/createVhosts.sh +++ b/createVhosts.sh @@ -48,6 +48,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 @@ -71,12 +80,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") @@ -217,16 +220,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