diff --git a/modules/pi_control/pages/console.php b/modules/pi_control/pages/console.php index 2c7948c..f578881 100644 --- a/modules/pi_control/pages/console.php +++ b/modules/pi_control/pages/console.php @@ -8,6 +8,7 @@ $error = null; $terminalNotice = null; $terminalError = null; $terminalUrl = null; +$terminalToken = null; $settings = modules()->settings('pi_control'); $ttydUrl = trim((string)($settings['ttyd_url'] ?? '/ttyd')); @@ -36,6 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { : "DATETIME('now', '+{$tokenTtl} minutes')"; $token = bin2hex(random_bytes(24)); + $terminalToken = $token; $stmt = $pdo->prepare( 'INSERT INTO ' . $table('sessions') . ' (token, host_id, provider, created_by, expires_at) VALUES (:token, :host_id, :provider, :created_by, ' . $expiresSql . ')' @@ -146,6 +148,11 @@ $runs = $pdo->query('SELECT * FROM ' . $table('runs') . ' ORDER BY id DESC LIMIT Aktive Konsole In neuem Tab öffnen + +
+ Token: +
+
diff --git a/tools/pi_control/ttyd/entrypoint.sh b/tools/pi_control/ttyd/entrypoint.sh new file mode 100644 index 0000000..8967e79 --- /dev/null +++ b/tools/pi_control/ttyd/entrypoint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +set -eu + +APP_ENV="${APP_ENV:-staging}" + +if [ "$APP_ENV" = "live" ]; then + SCRIPT="/app/live/tools/pi_control/terminal_entry.sh" +else + SCRIPT="/app/staging/tools/pi_control/terminal_entry.sh" +fi + +if [ ! -f "$SCRIPT" ]; then + echo "terminal_entry.sh not found at $SCRIPT" + exit 1 +fi + +exec ttyd --writable --url-arg "$SCRIPT"