38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use super::InstallStrategy;
|
|
use crate::ws::{WsEvent, WsEventKind};
|
|
use std::collections::HashMap;
|
|
use std::process::Command;
|
|
use tokio::sync::broadcast;
|
|
|
|
pub struct LinuxInstallStrategy;
|
|
|
|
impl InstallStrategy for LinuxInstallStrategy {
|
|
fn install(
|
|
&self,
|
|
details: &mut HashMap<String, String>,
|
|
issues: &mut Vec<String>,
|
|
broker: &broadcast::Sender<WsEvent>,
|
|
) -> Result<(), String> {
|
|
let _ = broker.send(WsEvent {
|
|
kind: WsEventKind::Log,
|
|
message: "Iniciando instalação no Linux...".into(),
|
|
});
|
|
|
|
// Script oficial de instalação
|
|
let install_cmd = "curl -fsSL https://ollama.com/install.sh | sh";
|
|
|
|
let status = Command::new("sh")
|
|
.arg("-c")
|
|
.arg(install_cmd)
|
|
.status()
|
|
.map_err(|e| format!("Falha ao executar script de instalação: {}", e))?;
|
|
|
|
if !status.success() {
|
|
return Err("Script de instalação falhou".into());
|
|
}
|
|
|
|
details.insert("method".to_string(), "curl_script".to_string());
|
|
Ok(())
|
|
}
|
|
}
|