diff --git a/web/logic/non-interactive.py b/web/logic/non-interactive.py index ea2385f..3d9774e 100644 --- a/web/logic/non-interactive.py +++ b/web/logic/non-interactive.py @@ -3,24 +3,29 @@ import json import os import sys -# Use a memory-backed path for temporary secrets if available, else local -SECRET_PATH = "/run/user/{}/numbus".format(os.getuid()) if os.path.exists("/run/user/{}".format(os.getuid())) else "." +### Variables --> +SECRET_PATH = "/run/user/{}/numbus".format(os.getuid()) if os.path.exists("/run/user/{}".format(os.getuid())) else "../secrets" os.makedirs(SECRET_PATH, exist_ok=True) +LOGS_DIR = "../web/logs/" +PAGES_DIR = "../web/pages/" +CONFIG_DIR = "../web/config/" +SIGNALS_DIR = "../web/signal/" +### <-- Variables class BridgeHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): # Route for logs: /logs?type=out or /logs?type=err if self.path.startswith('/logs'): log_type = "out" if "type=err" not in self.path else "err" - log_file = f'deploy-{log_type}.log' + log_path = os.path.join(LOGS_DIR, f'deploy-{log_type}.log') self.send_response(200) self.send_header('Content-type', 'text/plain') self.send_header('Access-Control-Allow-Origin', '*') self.end_headers() - if os.path.exists(log_file): - with open(log_file, 'r') as f: + if os.path.exists(log_path): + with open(log_path, 'r') as f: # Read last 50 lines for better context during errors self.wfile.write("".join(f.readlines()[-50:]).encode()) return @@ -37,14 +42,14 @@ class BridgeHandler(http.server.SimpleHTTPRequestHandler): self.send_response(200) self.end_headers() # Signal Bash that discovery data is ready - with open(".discovery_ready", "w") as f: f.write("1") + with open(os.path.join(SIGNALS_DIR, ".discovery_ready"), "w") as f: f.write("1") elif self.path == '/deploy': - with open("../numbus.yaml", "wb") as f: + with open(os.path.join(CONFIG_DIR, "numbus.yaml"), "wb") as f: f.write(post_data) self.send_response(200) self.end_headers() - with open(".deploy_signal", "w") as f: f.write("1") + with open(os.path.join(SIGNALS_DIR, ".deploy_signal"), "w") as f: f.write("1") -os.chdir("configurator") +os.chdir(PAGES_DIR) http.server.HTTPServer(('localhost', 8088), BridgeHandler).serve_forever() \ No newline at end of file diff --git a/web/pages/index.html b/web/pages/index.html index e49f7c0..b61b420 100644 --- a/web/pages/index.html +++ b/web/pages/index.html @@ -28,7 +28,7 @@
+
Transform your device into a secure, reliable and private appliance
using the power of open-soure software.
You will be guided through the configuration process.
@@ -41,7 +41,7 @@