Allow a server to be rebooted when a reboot is required
This commit is contained in:
parent
d880f088be
commit
8ea2f5a766
|
@ -391,7 +391,6 @@ def ssl_provision_certs():
|
||||||
def web_get_domains():
|
def web_get_domains():
|
||||||
from web_update import get_web_domains_info
|
from web_update import get_web_domains_info
|
||||||
return json_response(get_web_domains_info(env))
|
return json_response(get_web_domains_info(env))
|
||||||
|
|
||||||
@app.route('/web/update', methods=['POST'])
|
@app.route('/web/update', methods=['POST'])
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def web_update():
|
def web_update():
|
||||||
|
@ -456,6 +455,23 @@ def do_updates():
|
||||||
"DEBIAN_FRONTEND": "noninteractive"
|
"DEBIAN_FRONTEND": "noninteractive"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@app.route('/system/reboot', methods=["GET"])
|
||||||
|
@authorized_personnel_only
|
||||||
|
def needs_reboot():
|
||||||
|
if os.path.isfile("/var/run/reboot-required"):
|
||||||
|
return json_response(True)
|
||||||
|
else:
|
||||||
|
return json_response(False)
|
||||||
|
|
||||||
|
@app.route('/system/reboot', methods=["POST"])
|
||||||
|
@authorized_personnel_only
|
||||||
|
def do_reboot():
|
||||||
|
if os.path.isfile("/var/run/reboot-required"):
|
||||||
|
return utils.shell("check_output", ["/sbin/shutdown", "-r", "now"], capture_stderr=True)
|
||||||
|
else:
|
||||||
|
return "No reboot is required"
|
||||||
|
|
||||||
|
|
||||||
@app.route('/system/backup/status')
|
@app.route('/system/backup/status')
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def backup_status():
|
def backup_status():
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
<h2>System Status Checks</h2>
|
<h2>System Status Checks</h2>
|
||||||
|
|
||||||
|
<div id="system-reboot-required" style="display: none">
|
||||||
|
<button type="button" class="btn btn-danger" onclick="confirm_reboot(); return false;">Reboot required</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#system-checks .heading td {
|
#system-checks .heading td {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -34,7 +38,10 @@
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
#system-reboot-required {
|
||||||
|
max-width: 20em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
#system-privacy-setting {
|
#system-privacy-setting {
|
||||||
float: right;
|
float: right;
|
||||||
max-width: 20em;
|
max-width: 20em;
|
||||||
|
@ -47,7 +54,6 @@
|
||||||
<p style="line-height: 125%"><small>(When enabled, status checks phone-home to check for a new release of Mail-in-a-Box.)</small></p>
|
<p style="line-height: 125%"><small>(When enabled, status checks phone-home to check for a new release of Mail-in-a-Box.)</small></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<table id="system-checks" class="table" style="max-width: 60em">
|
<table id="system-checks" class="table" style="max-width: 60em">
|
||||||
<thead>
|
<thead>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -70,6 +76,14 @@ function show_system_status() {
|
||||||
$('#system-privacy-setting p').toggle(r);
|
$('#system-privacy-setting p').toggle(r);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api(
|
||||||
|
"/system/reboot",
|
||||||
|
"GET",
|
||||||
|
{ },
|
||||||
|
function(r) {
|
||||||
|
$('#system-reboot-required').toggle(r);
|
||||||
|
});
|
||||||
|
|
||||||
api(
|
api(
|
||||||
"/system/status",
|
"/system/status",
|
||||||
"POST",
|
"POST",
|
||||||
|
@ -122,4 +136,20 @@ function enable_privacy(status) {
|
||||||
});
|
});
|
||||||
return false; // disable link
|
return false; // disable link
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function confirm_reboot() {
|
||||||
|
show_modal_confirm(
|
||||||
|
"Reboot server",
|
||||||
|
$("<p>This will reboot your server, until the server is fully restarted your users will not be able to send and receive email. The reboot can't be cancelled</p>"),
|
||||||
|
"Reboot now",
|
||||||
|
function() {
|
||||||
|
api(
|
||||||
|
"/system/reboot",
|
||||||
|
"POST",
|
||||||
|
{ },
|
||||||
|
function(r) {
|
||||||
|
show_modal_error("Reboot", "Please refresh the page after a minute or so." + r);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue