mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
shutdown setup rpc server after setup
This commit is contained in:
committed by
Aiden McClelland
parent
96b72e541f
commit
8c6fab319a
@@ -24,20 +24,9 @@ fn status_fn(_: i32) -> StatusCode {
|
|||||||
async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
|
async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
|
||||||
let cfg = RpcContextConfig::load(cfg_path).await?;
|
let cfg = RpcContextConfig::load(cfg_path).await?;
|
||||||
embassy::disk::util::mount("LABEL=EMBASSY", "/embassy-os").await?;
|
embassy::disk::util::mount("LABEL=EMBASSY", "/embassy-os").await?;
|
||||||
if tokio::fs::metadata("/embassy-os/disk.guid").await.is_ok() {
|
if tokio::fs::metadata("/embassy-os/disk.guid").await.is_err() {
|
||||||
embassy::disk::main::load(
|
|
||||||
tokio::fs::read_to_string("/embassy-os/disk.guid")
|
|
||||||
.await?
|
|
||||||
.trim(),
|
|
||||||
cfg.zfs_pool_name(),
|
|
||||||
cfg.datadir(),
|
|
||||||
DEFAULT_PASSWORD,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
log::info!("Loaded Disk");
|
|
||||||
} else {
|
|
||||||
#[cfg(feature = "avahi")]
|
#[cfg(feature = "avahi")]
|
||||||
let mdns = MdnsController::init();
|
let _mdns = MdnsController::init();
|
||||||
tokio::fs::write(
|
tokio::fs::write(
|
||||||
"/etc/nginx/sites-available/default",
|
"/etc/nginx/sites-available/default",
|
||||||
include_str!("../nginx/setup-wizard.conf"),
|
include_str!("../nginx/setup-wizard.conf"),
|
||||||
@@ -76,6 +65,16 @@ async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
|
|||||||
.with_kind(embassy::ErrorKind::Network)?;
|
.with_kind(embassy::ErrorKind::Network)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
embassy::disk::main::load(
|
||||||
|
tokio::fs::read_to_string("/embassy-os/disk.guid")
|
||||||
|
.await?
|
||||||
|
.trim(),
|
||||||
|
cfg.zfs_pool_name(),
|
||||||
|
cfg.datadir(),
|
||||||
|
DEFAULT_PASSWORD,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
log::info!("Loaded Disk");
|
||||||
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() {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub struct SetupContextSeed {
|
|||||||
pub bind_rpc: SocketAddr,
|
pub bind_rpc: SocketAddr,
|
||||||
pub shutdown: Sender<()>,
|
pub shutdown: Sender<()>,
|
||||||
pub datadir: PathBuf,
|
pub datadir: PathBuf,
|
||||||
pub zfs_pool_name: String,
|
pub zfs_pool_name: Arc<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -71,7 +71,7 @@ impl SetupContext {
|
|||||||
let cfg = SetupContextConfig::load(path).await?;
|
let cfg = SetupContextConfig::load(path).await?;
|
||||||
let (shutdown, _) = tokio::sync::broadcast::channel(1);
|
let (shutdown, _) = tokio::sync::broadcast::channel(1);
|
||||||
let datadir = cfg.datadir().into_owned();
|
let datadir = cfg.datadir().into_owned();
|
||||||
let zfs_pool_name = cfg.zfs_pool_name().to_owned();
|
let zfs_pool_name = Arc::new(cfg.zfs_pool_name().to_owned());
|
||||||
Ok(Self(Arc::new(SetupContextSeed {
|
Ok(Self(Arc::new(SetupContextSeed {
|
||||||
bind_rpc: cfg.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()),
|
bind_rpc: cfg.bind_rpc.unwrap_or(([127, 0, 0, 1], 5959).into()),
|
||||||
shutdown,
|
shutdown,
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ pub async fn execute(
|
|||||||
tokio::fs::write("/embassy-os/disk.guid", &guid)
|
tokio::fs::write("/embassy-os/disk.guid", &guid)
|
||||||
.await
|
.await
|
||||||
.with_ctx(|_| (crate::ErrorKind::Filesystem, "/embassy-os/disk.guid"))?;
|
.with_ctx(|_| (crate::ErrorKind::Filesystem, "/embassy-os/disk.guid"))?;
|
||||||
|
ctx.shutdown.send(()).expect("failed to shutdown");
|
||||||
|
|
||||||
Ok(SetupResult {
|
Ok(SetupResult {
|
||||||
tor_address: tor_key.public().get_onion_address().to_string(),
|
tor_address: tor_key.public().get_onion_address().to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user