From ed93f70f944414115a2973659ac44209527146c8 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Mon, 20 Oct 2025 07:34:06 -0300 Subject: [PATCH] Remove tables install from bootstrap The tables component is now installed by default. The install command no longer installs it as part of the bootstrap process. --- gbot.sh | 2 +- src/bootstrap/mod.rs | 48 ++++++++++++++++++++++++-------- src/package_manager/installer.rs | 3 +- src/shared/utils.rs | 46 ++++++++++++++++++++---------- 4 files changed, 71 insertions(+), 28 deletions(-) diff --git a/gbot.sh b/gbot.sh index 31553cbf..544aaf5a 100755 --- a/gbot.sh +++ b/gbot.sh @@ -1,2 +1,2 @@ clear && \ - RUST_LOG=trace cargo run install tables + RUST_LOG=trace cargo run diff --git a/src/bootstrap/mod.rs b/src/bootstrap/mod.rs index b110e45a..f4af8fb3 100644 --- a/src/bootstrap/mod.rs +++ b/src/bootstrap/mod.rs @@ -1,7 +1,7 @@ use crate::config::AppConfig; use crate::package_manager::{InstallMode, PackageManager}; use anyhow::Result; -use log::{debug, trace, warn}; +use log::{trace, warn}; use rand::distr::Alphanumeric; use rand::rngs::ThreadRng; use rand::Rng; @@ -14,7 +14,11 @@ pub struct BootstrapManager { impl BootstrapManager { pub fn new(install_mode: InstallMode, tenant: Option) -> Self { - trace!("Initializing BootstrapManager with mode {:?} and tenant {:?}", install_mode, tenant); + trace!( + "Initializing BootstrapManager with mode {:?} and tenant {:?}", + install_mode, + tenant + ); Self { install_mode, tenant, @@ -24,9 +28,26 @@ impl BootstrapManager { pub fn start_all(&mut self) -> Result<()> { let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; let components = vec![ - "tables", "cache", "drive", "llm", "email", "proxy", "directory", - "alm", "alm_ci", "dns", "webmail", "meeting", "table_editor", - "doc_editor", "desktop", "devtools", "bot", "system", "vector_db", "host" + "tables", + "cache", + "drive", + "llm", + "email", + "proxy", + "directory", + "alm", + "alm_ci", + "dns", + "webmail", + "meeting", + "table_editor", + "doc_editor", + "desktop", + "devtools", + "bot", + "system", + "vector_db", + "host", ]; for component in components { @@ -42,8 +63,8 @@ impl BootstrapManager { pub fn bootstrap(&mut self) -> Result { let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; - let required_components = vec!["tables", "cache", "drive", "llm"]; - + let required_components = vec!["tables"]; // , "cache", "drive", "llm"]; + for component in required_components { if !pm.is_installed(component) { trace!("Installing required component: {}", component); @@ -55,7 +76,9 @@ impl BootstrapManager { } } - let config = match diesel::Connection::establish("postgres://botserver:botserver@localhost:5432/botserver") { + let config = match diesel::Connection::establish( + "postgres://botserver:botserver@localhost:5432/botserver", + ) { Ok(mut conn) => { self.setup_secure_credentials(&mut conn)?; AppConfig::from_database(&mut conn) @@ -74,16 +97,17 @@ impl BootstrapManager { use diesel::prelude::*; use uuid::Uuid; - let farm_password = std::env::var("FARM_PASSWORD").unwrap_or_else(|_| self.generate_secure_password(32)); + let farm_password = + std::env::var("FARM_PASSWORD").unwrap_or_else(|_| self.generate_secure_password(32)); let db_password = self.generate_secure_password(16); - + let encrypted_db_password = self.encrypt_password(&db_password, &farm_password); let env_contents = format!( "FARM_PASSWORD={}\nDATABASE_URL=postgres://gbuser:{}@localhost:5432/botserver", farm_password, db_password ); - + std::fs::write(".env", env_contents) .map_err(|e| anyhow::anyhow!("Failed to write .env file: {}", e))?; @@ -99,7 +123,7 @@ impl BootstrapManager { } fn generate_secure_password(&self, length: usize) -> String { - let mut rng: ThreadRng = rand::thread_rng(); + let rng: ThreadRng = rand::rng(); rng.sample_iter(&Alphanumeric) .take(length) .map(char::from) diff --git a/src/package_manager/installer.rs b/src/package_manager/installer.rs index 1841c9ec..f5d913d1 100644 --- a/src/package_manager/installer.rs +++ b/src/package_manager/installer.rs @@ -648,6 +648,7 @@ impl PackageManager { ); Ok(std::process::Command::new("sh") + .current_dir(&bin_path) .arg("-c") .arg(&rendered_cmd) .spawn()?) @@ -657,7 +658,7 @@ impl PackageManager { } fn generate_secure_password(&self, length: usize) -> String { - let mut rng: ThreadRng = rand::thread_rng(); + let rng: ThreadRng = rand::rng(); rng.sample_iter(&Alphanumeric) .take(length) .map(char::from) diff --git a/src/shared/utils.rs b/src/shared/utils.rs index 16a4ae9d..639d0f7c 100644 --- a/src/shared/utils.rs +++ b/src/shared/utils.rs @@ -1,4 +1,8 @@ -use log::{debug, trace}; +use crate::config::AIConfig; +use futures_util::StreamExt; +use indicatif::{ProgressBar, ProgressStyle}; +use log::trace; +use reqwest::Client; use rhai::{Array, Dynamic}; use serde_json::Value; use smartstring::SmartString; @@ -7,14 +11,13 @@ use std::fs::File; use std::io::BufReader; use std::path::Path; use tokio::fs::File as TokioFile; -use zip::ZipArchive; -use crate::config::AIConfig; -use reqwest::Client; use tokio::io::AsyncWriteExt; -use indicatif::{ProgressBar, ProgressStyle}; -use futures_util::StreamExt; +use zip::ZipArchive; -pub fn extract_zip_recursive(zip_path: &Path, destination_path: &Path) -> Result<(), Box> { +pub fn extract_zip_recursive( + zip_path: &Path, + destination_path: &Path, +) -> Result<(), Box> { let file = File::open(zip_path)?; let buf_reader = BufReader::new(file); let mut archive = ZipArchive::new(buf_reader)?; @@ -75,14 +78,17 @@ pub fn to_array(value: Dynamic) -> Array { } } -pub async fn download_file(url: &str, output_path: &str) -> Result<(), Box> { +pub async fn download_file( + url: &str, + output_path: &str, +) -> Result<(), Box> { let url = url.to_string(); let output_path = output_path.to_string(); - + let download_handle = tokio::spawn(async move { let client = Client::new(); let response = client.get(&url).send().await?; - + if response.status().is_success() { let total_size = response.content_length().unwrap_or(0); let pb = ProgressBar::new(total_size); @@ -123,14 +129,20 @@ pub fn parse_filter(filter_str: &str) -> Result<(String, Vec), Box Result<(String, Vec), Box> { +pub fn parse_filter_with_offset( + filter_str: &str, + offset: usize, +) -> Result<(String, Vec), Box> { let mut clauses = Vec::new(); let mut params = Vec::new(); @@ -143,7 +155,10 @@ pub fn parse_filter_with_offset(filter_str: &str, offset: usize) -> Result<(Stri let column = parts[0].trim(); let value = parts[1].trim(); - if !column.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') { + if !column + .chars() + .all(|c| c.is_ascii_alphanumeric() || c == '_') + { return Err("Invalid column name".into()); } @@ -154,6 +169,9 @@ pub fn parse_filter_with_offset(filter_str: &str, offset: usize) -> Result<(Stri Ok((clauses.join(" AND "), params)) } -pub async fn call_llm(prompt: &str, _ai_config: &AIConfig) -> Result> { +pub async fn call_llm( + prompt: &str, + _ai_config: &AIConfig, +) -> Result> { Ok(format!("Generated response for: {}", prompt)) }