diff --git a/CHANGELOG.md b/CHANGELOG.md index 640243b8..e8332692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ In Development Control panel: * Munin system monitoring graphs are now zoomable. +* When a reboot is required (due to Ubuntu security updates automatically installed), a Reboot Box button now appears. v0.17b (March 1, 2016) ---------------------- diff --git a/management/daemon.py b/management/daemon.py index 85a722a2..690f8b0f 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -453,6 +453,27 @@ def do_updates(): "DEBIAN_FRONTEND": "noninteractive" }) + +@app.route('/system/reboot', methods=["GET"]) +@authorized_personnel_only +def needs_reboot(): + from status_checks import is_reboot_needed_due_to_package_installation + if is_reboot_needed_due_to_package_installation(): + return json_response(True) + else: + return json_response(False) + +@app.route('/system/reboot', methods=["POST"]) +@authorized_personnel_only +def do_reboot(): + # To keep the attack surface low, we don't allow a remote reboot if one isn't necessary. + from status_checks import is_reboot_needed_due_to_package_installation + if is_reboot_needed_due_to_package_installation(): + return utils.shell("check_output", ["/sbin/shutdown", "-r", "now"], capture_stderr=True) + else: + return "No reboot is required, so it is not allowed." + + @app.route('/system/backup/status') @authorized_personnel_only def backup_status(): diff --git a/management/status_checks.py b/management/status_checks.py index 1feea68a..36a87ea1 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -185,10 +185,13 @@ def check_ssh_password(env, output): else: output.print_ok("SSH disallows password-based login.") +def is_reboot_needed_due_to_package_installation(): + return os.path.exists("/var/run/reboot-required") + def check_software_updates(env, output): # Check for any software package updates. pkgs = list_apt_updates(apt_update=False) - if os.path.exists("/var/run/reboot-required"): + if is_reboot_needed_due_to_package_installation(): output.print_error("System updates have been installed and a reboot of the machine is required.") elif len(pkgs) == 0: output.print_ok("System software is up to date.") diff --git a/management/templates/system-status.html b/management/templates/system-status.html index 9fe9d08e..dc9233a5 100644 --- a/management/templates/system-status.html +++ b/management/templates/system-status.html @@ -34,19 +34,23 @@ font-family: monospace; white-space: pre-wrap; } - -#system-privacy-setting { - float: right; - max-width: 20em; - margin-bottom: 1em; -} +
+
+ + + +
+
@@ -55,6 +59,9 @@
+
+
+