mirror of
https://github.com/robcholz/vibebox.git
synced 2026-05-24 07:14:01 +02:00
feat: removed rust and rename to vibebox
This commit is contained in:
+2
-2
@@ -36,6 +36,6 @@
|
||||
## Integration
|
||||
|
||||
1. [x] Wire up the vm and tui.
|
||||
2. [ ] Use ssh to connect to vm.
|
||||
2. [x] Use ssh to connect to vm.
|
||||
3. [ ] wire up SessionManager.
|
||||
4. [ ] VM should be separated by per-session VM daemon process (only accepts if to shutdown vm and itself).
|
||||
4. [ ] VM should be separated by a per-session VM daemon process (only accepts if to shut down vm and itself).
|
||||
|
||||
+21
-30
@@ -1,12 +1,8 @@
|
||||
use std::{
|
||||
env,
|
||||
fs,
|
||||
env, fs,
|
||||
io::{self, Write},
|
||||
net::{SocketAddr, TcpStream},
|
||||
os::unix::{
|
||||
fs::PermissionsExt,
|
||||
io::OwnedFd,
|
||||
},
|
||||
os::unix::{fs::PermissionsExt, io::OwnedFd},
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, Stdio},
|
||||
sync::{
|
||||
@@ -17,8 +13,8 @@ use std::{
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use std::sync::mpsc::Sender;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
session_manager::INSTANCE_DIR_NAME,
|
||||
@@ -30,7 +26,7 @@ const INSTANCE_TOML: &str = "instance.toml";
|
||||
const SSH_KEY_NAME: &str = "ssh_key";
|
||||
const SERIAL_LOG_NAME: &str = "serial.log";
|
||||
const SSH_GUEST_DIR: &str = "/root/.vibebox";
|
||||
const DEFAULT_SSH_USER: &str = "vibebox";
|
||||
const DEFAULT_SSH_USER: &str = "vibecoder";
|
||||
const SSH_CONNECT_RETRIES: usize = 30;
|
||||
const SSH_CONNECT_DELAY_MS: u64 = 500;
|
||||
const SSH_SETUP_SCRIPT: &str = include_str!("ssh.sh");
|
||||
@@ -76,12 +72,8 @@ pub fn run_with_ssh(
|
||||
true,
|
||||
)?];
|
||||
|
||||
let extra_login_actions = build_ssh_login_actions(
|
||||
&config,
|
||||
&project_name,
|
||||
SSH_GUEST_DIR,
|
||||
SSH_KEY_NAME,
|
||||
);
|
||||
let extra_login_actions =
|
||||
build_ssh_login_actions(&config, &project_name, SSH_GUEST_DIR, SSH_KEY_NAME);
|
||||
|
||||
vm::run_with_args_and_extras(
|
||||
args,
|
||||
@@ -107,7 +99,9 @@ fn ensure_instance_dir(project_root: &Path) -> Result<PathBuf, io::Error> {
|
||||
Ok(instance_dir)
|
||||
}
|
||||
|
||||
fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box<dyn std::error::Error>> {
|
||||
fn ensure_ssh_keypair(
|
||||
instance_dir: &Path,
|
||||
) -> Result<(PathBuf, PathBuf), Box<dyn std::error::Error>> {
|
||||
let private_key = instance_dir.join(SSH_KEY_NAME);
|
||||
let public_key = instance_dir.join(format!("{SSH_KEY_NAME}.pub"));
|
||||
|
||||
@@ -129,12 +123,13 @@ fn ensure_ssh_keypair(instance_dir: &Path) -> Result<(PathBuf, PathBuf), Box<dyn
|
||||
"-N",
|
||||
"",
|
||||
"-f",
|
||||
private_key
|
||||
.to_str()
|
||||
.ok_or("ssh key path not utf-8")?,
|
||||
private_key.to_str().ok_or("ssh key path not utf-8")?,
|
||||
"-C",
|
||||
"vibebox",
|
||||
])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::inherit())
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
@@ -283,8 +278,7 @@ fn spawn_ssh_io(
|
||||
let ssh_connected = Arc::new(AtomicBool::new(false));
|
||||
let ssh_started = Arc::new(AtomicBool::new(false));
|
||||
let ssh_ready = Arc::new(AtomicBool::new(false));
|
||||
let input_tx_holder: Arc<Mutex<Option<Sender<VmInput>>>> =
|
||||
Arc::new(Mutex::new(None));
|
||||
let input_tx_holder: Arc<Mutex<Option<Sender<VmInput>>>> = Arc::new(Mutex::new(None));
|
||||
|
||||
let instance_path = instance_dir.join(INSTANCE_TOML);
|
||||
let config_for_output = config.clone();
|
||||
@@ -415,9 +409,7 @@ fn spawn_ssh_io(
|
||||
);
|
||||
break;
|
||||
}
|
||||
thread::sleep(std::time::Duration::from_millis(
|
||||
SSH_CONNECT_DELAY_MS,
|
||||
));
|
||||
thread::sleep(std::time::Duration::from_millis(SSH_CONNECT_DELAY_MS));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -427,9 +419,7 @@ fn spawn_ssh_io(
|
||||
let status = Command::new("ssh")
|
||||
.args([
|
||||
"-i",
|
||||
ssh_key_for_thread
|
||||
.to_str()
|
||||
.unwrap_or(".vibebox/ssh_key"),
|
||||
ssh_key_for_thread.to_str().unwrap_or(".vibebox/ssh_key"),
|
||||
"-o",
|
||||
"IdentitiesOnly=yes",
|
||||
"-o",
|
||||
@@ -447,6 +437,9 @@ fn spawn_ssh_io(
|
||||
"-o",
|
||||
"ConnectTimeout=5",
|
||||
])
|
||||
.env_remove("LC_CTYPE")
|
||||
.env_remove("LC_ALL")
|
||||
// .env_remove("LANG")
|
||||
.arg(format!("{ssh_user}@{ip}"))
|
||||
.stdin(Stdio::inherit())
|
||||
.stdout(Stdio::inherit())
|
||||
@@ -458,8 +451,7 @@ fn spawn_ssh_io(
|
||||
ssh_connected_for_thread.store(false, Ordering::SeqCst);
|
||||
eprintln!("[vibebox] ssh exited with status: {status}");
|
||||
if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() {
|
||||
let _ =
|
||||
tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
|
||||
let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -479,8 +471,7 @@ fn spawn_ssh_io(
|
||||
ssh_connected_for_thread.store(false, Ordering::SeqCst);
|
||||
eprintln!("[vibebox] ssh exited with status: {status}");
|
||||
if let Some(tx) = input_tx_holder_for_thread.lock().unwrap().clone() {
|
||||
let _ =
|
||||
tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
|
||||
let _ = tx.send(VmInput::Bytes(b"systemctl poweroff\n".to_vec()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
pub mod instance;
|
||||
pub mod session_manager;
|
||||
pub mod tui;
|
||||
pub mod vm;
|
||||
pub mod instance;
|
||||
|
||||
pub use session_manager::{SessionError, SessionManager, SessionRecord};
|
||||
|
||||
+2
-13
@@ -15,16 +15,10 @@ apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
ripgrep \
|
||||
openssh-server \
|
||||
locales \
|
||||
sudo
|
||||
|
||||
# Set hostname to "vibe" so it's clear that you're inside the VM.
|
||||
hostnamectl set-hostname vibe
|
||||
|
||||
# Locale (fix: setlocale: LC_CTYPE ... UTF-8)
|
||||
sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
||||
locale-gen
|
||||
update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
|
||||
# Set hostname to "vibebox" so it's clear that you're inside the VM.
|
||||
hostnamectl set-hostname vibebox
|
||||
|
||||
# SSH: host keys + base config (doesn't depend on runtime user)
|
||||
ssh-keygen -A
|
||||
@@ -54,11 +48,6 @@ systemctl poweroff
|
||||
sleep 100 # sleep here so that we don't see the login screen flash up before the shutdown.
|
||||
EOF
|
||||
|
||||
|
||||
# Install Rust
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --component "rustfmt,clippy"
|
||||
|
||||
|
||||
# Install Mise
|
||||
curl https://mise.run | sh
|
||||
echo 'eval "$(~/.local/bin/mise activate bash)"' >> .bashrc
|
||||
|
||||
@@ -795,12 +795,7 @@ where
|
||||
continue;
|
||||
}
|
||||
|
||||
match poll_with_wakeup(
|
||||
libc::STDIN_FILENO,
|
||||
wakeup_read.as_raw_fd(),
|
||||
&mut buf,
|
||||
-1,
|
||||
) {
|
||||
match poll_with_wakeup(libc::STDIN_FILENO, wakeup_read.as_raw_fd(), &mut buf, -1) {
|
||||
PollResult::Shutdown | PollResult::Error => break,
|
||||
PollResult::Spurious => continue,
|
||||
PollResult::Ready(bytes) => {
|
||||
@@ -858,8 +853,7 @@ where
|
||||
wakeup_read.as_raw_fd(),
|
||||
&mut buf,
|
||||
100,
|
||||
)
|
||||
{
|
||||
) {
|
||||
PollResult::Shutdown | PollResult::Error => break,
|
||||
PollResult::Spurious => continue,
|
||||
PollResult::Ready(bytes) => {
|
||||
|
||||
Reference in New Issue
Block a user