Skip to content

Commit 652d37f

Browse files
committed
fix: reopen stdin from /dev/tty in generated install scripts (#9)
Scripts served at /username/slug were missing the exec < /dev/tty fix that scripts/install.sh already had, causing "stdin is not a TTY" when run via curl|bash. Affects both public and private config install flows.
1 parent 6f826c3 commit 652d37f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/lib/server/install-script.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import { describe, it, expect } from 'vitest';
22
import { generatePrivateInstallScript, generateInstallScript } from './install-script';
33

44
describe('generatePrivateInstallScript', () => {
5+
it('should reopen stdin from /dev/tty for curl|bash', () => {
6+
const script = generatePrivateInstallScript(
7+
'https://openboot.dev',
8+
'testuser',
9+
'my-config'
10+
);
11+
12+
expect(script).toContain('exec < /dev/tty');
13+
});
14+
515
it('should generate private install script with sanitized username and slug', () => {
616
const script = generatePrivateInstallScript(
717
'https://openboot.dev',
@@ -100,6 +110,12 @@ describe('generatePrivateInstallScript', () => {
100110
});
101111

102112
describe('generateInstallScript', () => {
113+
it('should reopen stdin from /dev/tty for curl|bash', () => {
114+
const script = generateInstallScript('testuser', 'my-config', '', '');
115+
116+
expect(script).toContain('exec < /dev/tty');
117+
});
118+
103119
it('should generate basic install script without custom content', () => {
104120
const script = generateInstallScript('testuser', 'my-config', '', '');
105121

src/lib/server/install-script.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export function generatePrivateInstallScript(
1313
return `#!/bin/bash
1414
set -e
1515
16+
# When run via "curl | bash", stdin is the script content, not the terminal.
17+
# Reopen stdin from /dev/tty so interactive prompts (sudo, Homebrew) work.
18+
if [ ! -t 0 ] && [ -e /dev/tty ]; then
19+
exec < /dev/tty
20+
fi
21+
1622
echo "========================================"
1723
echo " OpenBoot - Private Config Install"
1824
echo " Config: @${safeUsername}/${safeSlug}"
@@ -92,6 +98,12 @@ export function generateInstallScript(
9298
return `#!/bin/bash
9399
set -e
94100
101+
# When run via "curl | bash", stdin is the script content, not the terminal.
102+
# Reopen stdin from /dev/tty so interactive prompts (sudo, Homebrew) work.
103+
if [ ! -t 0 ] && [ -e /dev/tty ]; then
104+
exec < /dev/tty
105+
fi
106+
95107
echo "========================================"
96108
echo " OpenBoot - Custom Install"
97109
echo " Config: @${safeUsername}/${safeSlug}"

0 commit comments

Comments
 (0)