Closes #13: Adds a proper cleanup
This commit is contained in:
parent
dd90e79b4b
commit
0adfdf6bc4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue