diff --git a/maintenance/reboot.py b/maintenance/reboot.py new file mode 100644 index 0000000..4b0aad2 --- /dev/null +++ b/maintenance/reboot.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 +import docker + +client = docker.from_env() +for container in client.containers.list(): + if container.name == "thsf": + print("[+] Rebooting container
") + print(" '-> Stopping container
") + container.stop() + print(" '-> Starting container
") + container.start() + print("[\o/] Container restarted
") + diff --git a/maintenance/scripts/maintenance.js b/maintenance/scripts/maintenance.js new file mode 100644 index 0000000..2ccefeb --- /dev/null +++ b/maintenance/scripts/maintenance.js @@ -0,0 +1,13 @@ +function reboot() { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + document.getElementById("logs").innerHTML = this.responseText; + } + }; + xhttp.open("GET", "https://www.thsf.net/maintenance/reboot.py", true); + xhttp.send(); + setTimeout(function () { + document.location="https://www.thsf.net/maintenance/status.py"}, 5000 + ); +} diff --git a/maintenance/status.py b/maintenance/status.py new file mode 100644 index 0000000..fdc3edc --- /dev/null +++ b/maintenance/status.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +import docker +import jinja2 + +base_path = "/var/www/www.thsf.net/thsf.net/maintenance/templates" +status_template = "status.html" + +env = jinja2.Environment(loader=jinja2.FileSystemLoader(base_path), + autoescape=True) +template = env.get_template(status_template) + +client = docker.from_env() +for container in client.containers.list(): + if container.name == "thsf": + cont = dict() + cont["name"] = container.name + cont["status"] = container.status + cont["log"] = container.logs().decode('utf-8').replace('\n', '
') + print(template.render(containers=[container])) diff --git a/maintenance/style/maintenance.css b/maintenance/style/maintenance.css new file mode 100644 index 0000000..b06d32f --- /dev/null +++ b/maintenance/style/maintenance.css @@ -0,0 +1,59 @@ +.body { + +} +.page_wrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + align-content: center; + text-align: center; + padding-bottom: 5em; + background-color: red; +} +.center_wrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; + background-color: blue; +} +.container_list { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; + background-color: yellow; +} +.table_headers, .line { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + background-color: green; +} +.header, .status { + font-weight: bold; + border-width: 1px; + border-style: solid; + background-color: violet; +} +.table_content { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; + background-color: cyan; +} +.status { + font-weight: normal; +} +.container_log { + +} +.button { + font-weight: bold; +} diff --git a/maintenance/templates/status.html b/maintenance/templates/status.html new file mode 100644 index 0000000..1816bff --- /dev/null +++ b/maintenance/templates/status.html @@ -0,0 +1,40 @@ + + + + THSF 2023: Status page + + + + + + + +
+
+
+
+
Name
+
Status
+
Action
+
+
+ {% for container in containers %} +
+
{{ container.name }}
+
{{ container.status }}
+
+ +
+
+
+ {{ container.logs }} +
+ {% endfor %} +
+
+
+
+ + diff --git a/resources/thsf_2023.png b/resources/thsf_2023.png new file mode 100644 index 0000000..8df0eb8 Binary files /dev/null and b/resources/thsf_2023.png differ