This commit is contained in:
2026-03-05 21:59:23 +01:00
parent 2d4f53351a
commit 9e68ac42f2
2 changed files with 24 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ $error = null;
$terminalNotice = null; $terminalNotice = null;
$terminalError = null; $terminalError = null;
$terminalUrl = null; $terminalUrl = null;
$terminalToken = null;
$settings = modules()->settings('pi_control'); $settings = modules()->settings('pi_control');
$ttydUrl = trim((string)($settings['ttyd_url'] ?? '/ttyd')); $ttydUrl = trim((string)($settings['ttyd_url'] ?? '/ttyd'));
@@ -36,6 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
: "DATETIME('now', '+{$tokenTtl} minutes')"; : "DATETIME('now', '+{$tokenTtl} minutes')";
$token = bin2hex(random_bytes(24)); $token = bin2hex(random_bytes(24));
$terminalToken = $token;
$stmt = $pdo->prepare( $stmt = $pdo->prepare(
'INSERT INTO ' . $table('sessions') . ' (token, host_id, provider, created_by, expires_at) 'INSERT INTO ' . $table('sessions') . ' (token, host_id, provider, created_by, expires_at)
VALUES (:token, :host_id, :provider, :created_by, ' . $expiresSql . ')' VALUES (:token, :host_id, :provider, :created_by, ' . $expiresSql . ')'
@@ -146,6 +148,11 @@ $runs = $pdo->query('SELECT * FROM ' . $table('runs') . ' ORDER BY id DESC LIMIT
<strong>Aktive Konsole</strong> <strong>Aktive Konsole</strong>
<a class="nav-link" href="<?= e($terminalUrl) ?>" target="_blank" rel="noopener">In neuem Tab öffnen</a> <a class="nav-link" href="<?= e($terminalUrl) ?>" target="_blank" rel="noopener">In neuem Tab öffnen</a>
</div> </div>
<?php if ($terminalToken): ?>
<div class="muted" style="margin-top:.5rem;">
Token: <code><?= e($terminalToken) ?></code>
</div>
<?php endif; ?>
<div style="margin-top:.75rem; border-radius:12px; overflow:hidden; border:1px solid var(--line); background:#0b0f17;"> <div style="margin-top:.75rem; border-radius:12px; overflow:hidden; border:1px solid var(--line); background:#0b0f17;">
<iframe src="<?= e($terminalUrl) ?>" title="Pi Konsole" style="width:100%; height:520px; border:0;"></iframe> <iframe src="<?= e($terminalUrl) ?>" title="Pi Konsole" style="width:100%; height:520px; border:0;"></iframe>
</div> </div>

View File

@@ -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"