From 8ea2f5a766223fc2b12c7dfc394f578b3d88253e Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Thu, 25 Feb 2016 21:56:27 +0100 Subject: [PATCH 1/3] Allow a server to be rebooted when a reboot is required --- management/daemon.py | 18 ++++++++++++- management/templates/system-status.html | 34 +++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index 6de0a59a..823bce5e 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -391,7 +391,6 @@ def ssl_provision_certs(): def web_get_domains(): from web_update import get_web_domains_info return json_response(get_web_domains_info(env)) - @app.route('/web/update', methods=['POST']) @authorized_personnel_only def web_update(): @@ -456,6 +455,23 @@ def do_updates(): "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') @authorized_personnel_only def backup_status(): diff --git a/management/templates/system-status.html b/management/templates/system-status.html index 9fe9d08e..efc8ad90 100644 --- a/management/templates/system-status.html +++ b/management/templates/system-status.html @@ -1,5 +1,9 @@

System Status Checks

+ + +
+
+ + + +
+
+ @@ -61,6 +59,9 @@
+
+
+