diff --git a/management/daemon.py b/management/daemon.py index 1698f9e8..88bc0e17 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -367,11 +367,9 @@ def ssl_get_csr(domain): @app.route('/ssl/renew/', methods=['POST']) @authorized_personnel_only def ssl_renew(domain): - from exclusiveprocess import Lock from utils import load_environment from ssl_certificates import provision_certificates existing_key = request.form.get('existing_key') - Lock(die=True).forever() env = load_environment() if existing_key == "yes": status = provision_certificates(env, limit_domains=[], domain_to_be_renewed=domain) diff --git a/management/templates/index.html b/management/templates/index.html index 2c0d5a9a..31657a3d 100644 --- a/management/templates/index.html +++ b/management/templates/index.html @@ -209,17 +209,17 @@ $(function() { // so that we don't attempt to show another modal while this one // is closing. global_modal_state = 0; // OK - }) + }); $('#global_modal .btn-default').click(function() { global_modal_state = 1; // Cancel - }) + }); $('#global_modal').on('hidden.bs.modal', function (e) { // do the cancel function if (global_modal_state == null) global_modal_state = 1; // cancel if the user hit ESC or clicked outside of the modal if (global_modal_funcs && global_modal_funcs[global_modal_state]) global_modal_funcs[global_modal_state](); }) -}) +}); function show_modal_error(title, message, callback) { $('#global_modal h4').text(title); @@ -239,7 +239,7 @@ function show_modal_error(title, message, callback) { return false; // handy when called from onclick } -function show_modal_confirm(title, question, verb, yes_callback, cancel_callback) { +function show_modal_confirm(title, question, verb, yes_callback, cancel_callback, extra_callback=null) { $('#global_modal h4').text(title); if (typeof question == 'string') { $('#global_modal .modal-dialog').addClass("modal-sm"); @@ -256,7 +256,8 @@ function show_modal_confirm(title, question, verb, yes_callback, cancel_callback $('#global_modal .btn-default').show().text(verb[1]); $('#global_modal .btn-danger').show().text(verb[0]); } - global_modal_funcs = [yes_callback, cancel_callback]; + if (extra_callback) global_modal_funcs = [yes_callback, cancel_callback, extra_callback]; + else global_modal_funcs = [yes_callback, cancel_callback]; global_modal_state = null; $('#global_modal').modal({}); return false; // handy when called from onclick diff --git a/management/templates/ssl.html b/management/templates/ssl.html index 5a18e142..d3db8edd 100644 --- a/management/templates/ssl.html +++ b/management/templates/ssl.html @@ -137,46 +137,47 @@ function ssl_install(elem) { $('html, body').animate({ scrollTop: $('#ssl_install_header').offset().top - $('.navbar-fixed-top').height() - 20 }) return false; } +let flag = false; function ssl_renew_or_replace_modal(elem) { + if (!flag) { + $('#global_modal .modal-footer').append(''); + flag = true; + } + $('#global_modal .btn-warning').click(function() { + global_modal_state = 2; // Renew + }); show_modal_confirm( "Options", "Do you want to replace the certificate with a new one or just renew this one?", - ["Replace", "Renew"], + "Replace", function () { + $('#global_modal .modal-footer .btn-warning').remove(); + flag = false; ssl_install(elem); - }, + }, function() {$('#global_modal .modal-footer .btn-warning').remove();flag = false;}, function () { + $('#global_modal .modal-footer .btn-warning').remove(); + flag = false; ssl_cert_renew(elem); }); } function ssl_cert_renew(elem) { + if (!flag) { + $('#global_modal .modal-footer').append(''); + flag = true; + } + $('#global_modal .btn-warning').click(function() { + global_modal_state = 2; // Renew + }); var domain = $(elem).parents('tr').attr('data-domain'); show_modal_confirm( - "Options", + "Renewing options", "Do you want to renew with the existing key?", - ["Yes", "No"], + "No", function () { - ajax_with_indicator(true); - api( - "/ssl/renew/" + domain, - "POST", - { - existing_key: "yes" - }, - function(data) { - $('#ajax_loading_indicator').stop(true).hide(); - show_modal_error(data["title"], data["log"]); - show_tls(true); - }, - function () { - $('#ajax_loading_indicator').stop(true).hide(); - show_modal_error("Error", "Something is not right, sorry!"); - show_tls(true); - }); - }, - function () { - ajax_with_indicator(true); + $('#global_modal .modal-footer .btn-warning').remove();flag = false; + $('#ajax_loading_indicator').show(); api( "/ssl/renew/" + domain, "POST", @@ -194,7 +195,28 @@ function ssl_cert_renew(elem) { show_tls(true); } ); - }); + }, function() {$('#global_modal .modal-footer .btn-warning').remove();flag = false;}, + function () { + $('#global_modal .modal-footer .btn-warning').remove(); + flag = false; + $('#ajax_loading_indicator').show(); + api( + "/ssl/renew/" + domain, + "POST", + { + existing_key: "yes" + }, + function(data) { + $('#ajax_loading_indicator').stop(true).hide(); + show_modal_error(data["title"], data["log"]); + show_tls(true); + }, + function () { + $('#ajax_loading_indicator').stop(true).hide(); + show_modal_error("Error", "Something is not right, sorry!"); + show_tls(true); + }); + },); } function show_csr() { diff --git a/setup/ssl.sh b/setup/ssl.sh index 2a249492..ef07c274 100755 --- a/setup/ssl.sh +++ b/setup/ssl.sh @@ -39,6 +39,7 @@ apt_install openssl # Create a directory to store TLS-related things like "SSL" certificates. mkdir -p $STORAGE_ROOT/ssl +mkdir -p $STORAGE_ROOT/ssl-backup # creating a backup directory for ssl certs just to be safe # Generate a new private key. #