4 Commits

Author SHA1 Message Date
Uber Veng
80d2e7fd71 Fix first startup on macOS 2 2026-05-29 13:17:30 +07:00
Uber Veng
03e1311e90 update install script 5 2026-05-29 13:03:35 +07:00
Uber Veng
a93f3ad9f6 Fix first startup on macOS 2026-05-29 12:58:15 +07:00
Uber Veng
b0407d6519 update install script 4 2026-05-29 12:49:58 +07:00
4 changed files with 23 additions and 11 deletions

2
Cargo.lock generated
View File

@@ -1203,7 +1203,7 @@ dependencies = [
[[package]]
name = "ostiary"
version = "1.1.2"
version = "1.1.4"
dependencies = [
"anyhow",
"base64",

View File

@@ -1,6 +1,6 @@
[package]
name = "ostiary"
version = "1.1.2"
version = "1.1.4"
edition = "2024"
[dependencies]

View File

@@ -109,7 +109,7 @@ fi
echo ""
ok "Launching ${BINARY}..."
if { true </dev/tty; } 2>/dev/null; then
exec "$INSTALL_DIR/$BINARY" </dev/tty >/dev/tty 2>/dev/tty
"$INSTALL_DIR/$BINARY"
else
ok "Run: $BINARY"
fi

View File

@@ -12,6 +12,8 @@ mod updater;
use std::io;
use anyhow::Result;
#[cfg(unix)]
use libc;
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
@@ -29,6 +31,18 @@ async fn main() -> Result<()> {
config::Config::create_with_endpoint(&url, &name)?
};
// Before initializing the TUI, ensure our process group is the terminal's
// foreground group. When launched from a non-interactive install script on
// macOS, the parent shell may not have granted terminal ownership, causing
// crossterm's kqueue-based input reader to fail silently.
#[cfg(unix)]
{
use std::os::unix::io::AsRawFd;
if let Ok(tty) = std::fs::File::open("/dev/tty") {
unsafe { libc::tcsetpgrp(tty.as_raw_fd(), libc::getpgrp()); }
}
}
enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
@@ -172,17 +186,15 @@ async fn run_exec(
fn prompt_first_endpoint() -> Result<(String, String)> {
use std::io::{BufRead, BufReader, Write};
// Open /dev/tty directly so input works even when launched via `curl | bash`
// (where stdin is the pipe carrying the script, not the keyboard).
let tty = std::fs::OpenOptions::new()
.read(true)
.write(true)
.open("/dev/tty")
// Open /dev/tty read-only for keyboard input so the wizard works even when
// stdin is a pipe (e.g. `curl | bash`). Writing goes through stdout so we
// don't touch the terminal's write-side state before crossterm takes over.
let tty_in = std::fs::File::open("/dev/tty")
.map_err(|e| anyhow::anyhow!(
"Не удалось открыть терминал ({e}). Запустите ostiary напрямую."
))?;
let mut out = tty.try_clone()?;
let mut reader = BufReader::new(tty);
let mut reader = BufReader::new(tty_in);
let mut out = std::io::stdout();
writeln!(out)?;
writeln!(out, " ╔══════════════════════════════════╗")?;