fix: reattach tty for shell bootstrap
Deploy tsrun / deploy (push) Successful in 1m35s

This commit is contained in:
2026-07-22 14:47:58 +00:00 Unverified
parent 874b749a3a
commit 3b41a253a8
+18 -2
View File
@@ -43,6 +43,9 @@ need_root() {
}
run_as_root() {
if [ -r /dev/tty ]; then
exec </dev/tty
fi
if need_root; then
exec "$1" "\${TSRUN_ARGS[@]}"
fi
@@ -76,6 +79,19 @@ function Test-Administrator {
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Get-TsrunTempDir {
if ($env:TEMP) {
return $env:TEMP
}
if ($env:TMPDIR) {
return $env:TMPDIR
}
if ($IsWindows) {
return [System.IO.Path]::GetTempPath()
}
return '/tmp'
}
function Download-Tsrun {
param(
[string] $PrimaryUrl,
@@ -136,7 +152,7 @@ function Start-Tsrun {
$url = ${psQuote(binURL)}
$rawUrl = ${psQuote(rawBinURL)}
$tempDir = Join-Path $env:TEMP 'tsrun-bootstrap'
$tempDir = Join-Path (Get-TsrunTempDir) 'tsrun-bootstrap'
$exePath = Join-Path $tempDir 'tsrun.exe'
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
@@ -190,7 +206,7 @@ function detectBootstrapKind(req: Request, url: URL): "shell" | "powershell" | "
if (forced === "windows") return "powershell";
const ua = (req.headers.get("user-agent") ?? "").toLowerCase();
if (ua.includes("powershell") || ua.includes("windowspowershell")) return "powershell";
if ((ua.includes("powershell") || ua.includes("windowspowershell")) && ua.includes("windows")) return "powershell";
if (ua.includes("curl") || ua.includes("wget") || ua.includes("busybox")) return "shell";
return "text";