Support legacy bootstrap and update installer
This commit is contained in:
parent
248ad08efc
commit
c595380837
2 changed files with 44 additions and 5 deletions
|
|
@ -63,6 +63,45 @@ impl BootstrapManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bootstrap(&mut self) -> Result<AppConfig> {
|
pub fn bootstrap(&mut self) -> Result<AppConfig> {
|
||||||
|
// Check for legacy mode - if TABLES_SERVER is present, skip bootstrap
|
||||||
|
if let Ok(tables_server) = std::env::var("TABLES_SERVER") {
|
||||||
|
if !tables_server.is_empty() {
|
||||||
|
trace!(
|
||||||
|
"Legacy mode detected (TABLES_SERVER present), skipping bootstrap installation"
|
||||||
|
);
|
||||||
|
info!("Running in legacy mode with existing database configuration");
|
||||||
|
|
||||||
|
// Try to connect to the database and load config
|
||||||
|
let database_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| {
|
||||||
|
let username =
|
||||||
|
std::env::var("TABLES_USERNAME").unwrap_or_else(|_| "postgres".to_string());
|
||||||
|
let password =
|
||||||
|
std::env::var("TABLES_PASSWORD").unwrap_or_else(|_| "postgres".to_string());
|
||||||
|
let server =
|
||||||
|
std::env::var("TABLES_SERVER").unwrap_or_else(|_| "localhost".to_string());
|
||||||
|
let port = std::env::var("TABLES_PORT").unwrap_or_else(|_| "5432".to_string());
|
||||||
|
let database =
|
||||||
|
std::env::var("TABLES_DATABASE").unwrap_or_else(|_| "gbserver".to_string());
|
||||||
|
format!(
|
||||||
|
"postgres://{}:{}@{}:{}/{}",
|
||||||
|
username, password, server, port, database
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
match diesel::PgConnection::establish(&database_url) {
|
||||||
|
Ok(mut conn) => {
|
||||||
|
info!("Successfully connected to legacy database, loading configuration");
|
||||||
|
return Ok(AppConfig::from_database(&mut conn));
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to connect to legacy database: {}", e);
|
||||||
|
info!("Using environment variables as fallback");
|
||||||
|
return Ok(AppConfig::from_env());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
|
let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
|
||||||
let required_components = vec!["tables", "drive", "cache", "llm"];
|
let required_components = vec!["tables", "drive", "cache", "llm"];
|
||||||
let mut config = AppConfig::from_env();
|
let mut config = AppConfig::from_env();
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ impl PackageManager {
|
||||||
post_install_cmds_linux: vec![
|
post_install_cmds_linux: vec![
|
||||||
"wget https://dl.min.io/client/mc/release/linux-amd64/mc -O {{BIN_PATH}}/mc".to_string(),
|
"wget https://dl.min.io/client/mc/release/linux-amd64/mc -O {{BIN_PATH}}/mc".to_string(),
|
||||||
"chmod +x {{BIN_PATH}}/mc".to_string(),
|
"chmod +x {{BIN_PATH}}/mc".to_string(),
|
||||||
format!("{{BIN_PATH}}/mc alias set mc http://localhost:9000 gbdriveuser {}", drive_password).to_string(),
|
format!("{{{{BIN_PATH}}}}/mc alias set mc http://localhost:9000 gbdriveuser {}", drive_password),
|
||||||
"{{BIN_PATH}}/mc mb mc/default.gbai".to_string(),
|
"{{BIN_PATH}}/mc mb mc/default.gbai".to_string(),
|
||||||
format!("{{BIN_PATH}}/mc admin user add mc gbdriveuser {}", drive_password).to_string(),
|
format!("{{{{BIN_PATH}}}}/mc admin user add mc gbdriveuser {}", drive_password),
|
||||||
"{{BIN_PATH}}/mc admin policy attach mc readwrite --user=gbdriveuser".to_string()
|
"{{BIN_PATH}}/mc admin policy attach mc readwrite --user=gbdriveuser".to_string()
|
||||||
],
|
],
|
||||||
pre_install_cmds_macos: vec![],
|
pre_install_cmds_macos: vec![],
|
||||||
|
|
@ -192,9 +192,9 @@ impl PackageManager {
|
||||||
download_url: None,
|
download_url: None,
|
||||||
binary_name: Some("valkey-server".to_string()),
|
binary_name: Some("valkey-server".to_string()),
|
||||||
pre_install_cmds_linux: vec![
|
pre_install_cmds_linux: vec![
|
||||||
"if [ ! -f /usr/share/keyrings/valkey.gpg ]; then curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/valkey.gpg; fi".to_string(),
|
"sudo bash -c 'if [ ! -f /usr/share/keyrings/valkey.gpg ]; then curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/valkey.gpg; fi'".to_string(),
|
||||||
"if [ ! -f /etc/apt/sources.list.d/valkey.list ]; then echo 'deb [signed-by=/usr/share/keyrings/valkey.gpg] https://packages.redis.io/deb $(lsb_release -cs) main' | tee /etc/apt/sources.list.d/valkey.list; fi".to_string(),
|
"sudo bash -c 'if [ ! -f /etc/apt/sources.list.d/valkey.list ]; then echo \"deb [signed-by=/usr/share/keyrings/valkey.gpg] https://packages.redis.io/deb $(lsb_release -cs) main\" | tee /etc/apt/sources.list.d/valkey.list; fi'".to_string(),
|
||||||
"apt-get update && apt-get install -y valkey".to_string()
|
"sudo apt-get update && sudo apt-get install -y valkey".to_string()
|
||||||
],
|
],
|
||||||
post_install_cmds_linux: vec![],
|
post_install_cmds_linux: vec![],
|
||||||
pre_install_cmds_macos: vec![],
|
pre_install_cmds_macos: vec![],
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue