mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
restart -> rebuild
This commit is contained in:
committed by
Aiden McClelland
parent
4a97908b2b
commit
e2ab4f4fe1
@@ -6,10 +6,10 @@ use crate::install::PKG_DOCKER_DIR;
|
|||||||
use crate::util::Invoke;
|
use crate::util::Invoke;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
pub const HARD_RESTART_PATH: &str = "/embassy-os/hard-restart";
|
pub const SYSTEM_REBUILD_PATH: &str = "/embassy-os/system-rebuild";
|
||||||
|
|
||||||
pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error> {
|
pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error> {
|
||||||
let hard_restart = tokio::fs::metadata(HARD_RESTART_PATH).await.is_ok();
|
let should_rebuild = tokio::fs::metadata(SYSTEM_REBUILD_PATH).await.is_ok();
|
||||||
let secret_store = cfg.secret_store().await?;
|
let secret_store = cfg.secret_store().await?;
|
||||||
let log_dir = cfg.datadir().join("main").join("logs");
|
let log_dir = cfg.datadir().join("main").join("logs");
|
||||||
if tokio::fs::metadata(&log_dir).await.is_err() {
|
if tokio::fs::metadata(&log_dir).await.is_err() {
|
||||||
@@ -27,7 +27,7 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error
|
|||||||
tokio::fs::create_dir_all(&tmp_dir).await?;
|
tokio::fs::create_dir_all(&tmp_dir).await?;
|
||||||
}
|
}
|
||||||
let tmp_docker = cfg.datadir().join("package-data/tmp/docker");
|
let tmp_docker = cfg.datadir().join("package-data/tmp/docker");
|
||||||
if hard_restart {
|
if should_rebuild {
|
||||||
if tokio::fs::metadata(&tmp_docker).await.is_ok() {
|
if tokio::fs::metadata(&tmp_docker).await.is_ok() {
|
||||||
tokio::fs::remove_dir_all(&tmp_docker).await?;
|
tokio::fs::remove_dir_all(&tmp_docker).await?;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error
|
|||||||
.await?;
|
.await?;
|
||||||
tracing::info!("Mounted Docker Data");
|
tracing::info!("Mounted Docker Data");
|
||||||
|
|
||||||
if hard_restart {
|
if should_rebuild {
|
||||||
crate::install::load_images(cfg.datadir().join(PKG_DOCKER_DIR)).await?;
|
crate::install::load_images(cfg.datadir().join(PKG_DOCKER_DIR)).await?;
|
||||||
tracing::info!("Loaded Package Docker Images");
|
tracing::info!("Loaded Package Docker Images");
|
||||||
// Loading system images
|
// Loading system images
|
||||||
@@ -103,8 +103,8 @@ pub async fn init(cfg: &RpcContextConfig, product_key: &str) -> Result<(), Error
|
|||||||
|
|
||||||
crate::version::init(&mut handle).await?;
|
crate::version::init(&mut handle).await?;
|
||||||
|
|
||||||
if hard_restart {
|
if should_rebuild {
|
||||||
tokio::fs::remove_file(HARD_RESTART_PATH).await?;
|
tokio::fs::remove_file(SYSTEM_REBUILD_PATH).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ pub fn main_api() -> Result<(), RpcError> {
|
|||||||
system::metrics,
|
system::metrics,
|
||||||
shutdown::shutdown,
|
shutdown::shutdown,
|
||||||
shutdown::restart,
|
shutdown::restart,
|
||||||
shutdown::hard_restart,
|
shutdown::rebuild,
|
||||||
update::update_system,
|
update::update_system,
|
||||||
marketplace::set_eos_url,
|
marketplace::set_eos_url,
|
||||||
))]
|
))]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use rpc_toolkit::command;
|
|||||||
|
|
||||||
use crate::context::RpcContext;
|
use crate::context::RpcContext;
|
||||||
use crate::disk::main::export;
|
use crate::disk::main::export;
|
||||||
use crate::init::HARD_RESTART_PATH;
|
use crate::init::SYSTEM_REBUILD_PATH;
|
||||||
use crate::sound::SHUTDOWN;
|
use crate::sound::SHUTDOWN;
|
||||||
use crate::util::{display_none, Invoke};
|
use crate::util::{display_none, Invoke};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
@@ -110,8 +110,8 @@ pub async fn restart(#[context] ctx: RpcContext) -> Result<(), Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(rename = "hard-restart", display(display_none))]
|
#[command(display(display_none))]
|
||||||
pub async fn hard_restart(#[context] ctx: RpcContext) -> Result<(), Error> {
|
pub async fn rebuild(#[context] ctx: RpcContext) -> Result<(), Error> {
|
||||||
tokio::fs::write(HARD_RESTART_PATH, b"").await?;
|
tokio::fs::write(SYSTEM_REBUILD_PATH, b"").await?;
|
||||||
restart(ctx).await
|
restart(ctx).await
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user