mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
rename embassy to startos
This commit is contained in:
@@ -71,7 +71,7 @@ pub async fn restore_packages_rpc(
|
||||
pub async fn recover_full_embassy(
|
||||
ctx: SetupContext,
|
||||
disk_guid: Arc<String>,
|
||||
embassy_password: String,
|
||||
start_os_password: String,
|
||||
recovery_source: TmpMountGuard,
|
||||
recovery_password: Option<String>,
|
||||
) -> Result<(Arc<String>, Hostname, OnionAddressV3, X509), Error> {
|
||||
@@ -89,7 +89,7 @@ pub async fn recover_full_embassy(
|
||||
)?;
|
||||
|
||||
os_backup.account.password = argon2::hash_encoded(
|
||||
embassy_password.as_bytes(),
|
||||
start_os_password.as_bytes(),
|
||||
&rand::random::<[u8; 16]>()[..],
|
||||
&argon2::Config::rfc9106_low_mem(),
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ pub struct CifsBackupTarget {
|
||||
path: PathBuf,
|
||||
username: String,
|
||||
mountable: bool,
|
||||
embassy_os: Option<EmbassyOsRecoveryInfo>,
|
||||
start_os: Option<EmbassyOsRecoveryInfo>,
|
||||
}
|
||||
|
||||
pub fn cifs() -> ParentHandler {
|
||||
@@ -93,7 +93,7 @@ pub async fn add(
|
||||
password,
|
||||
};
|
||||
let guard = TmpMountGuard::mount(&cifs, ReadOnly).await?;
|
||||
let embassy_os = recovery_info(guard.path()).await?;
|
||||
let start_os = recovery_info(guard.path()).await?;
|
||||
guard.unmount().await?;
|
||||
let id = ctx
|
||||
.db
|
||||
@@ -116,7 +116,7 @@ pub async fn add(
|
||||
path: cifs.path,
|
||||
username: cifs.username,
|
||||
mountable: true,
|
||||
embassy_os,
|
||||
start_os,
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -157,7 +157,7 @@ pub async fn update(
|
||||
password,
|
||||
};
|
||||
let guard = TmpMountGuard::mount(&cifs, ReadOnly).await?;
|
||||
let embassy_os = recovery_info(guard.path()).await?;
|
||||
let start_os = recovery_info(guard.path()).await?;
|
||||
guard.unmount().await?;
|
||||
ctx.db
|
||||
.mutate(|db| {
|
||||
@@ -180,7 +180,7 @@ pub async fn update(
|
||||
path: cifs.path,
|
||||
username: cifs.username,
|
||||
mountable: true,
|
||||
embassy_os,
|
||||
start_os,
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -224,11 +224,11 @@ pub async fn list(db: &DatabaseModel) -> Result<Vec<(u32, CifsBackupTarget)>, Er
|
||||
let mut cifs = Vec::new();
|
||||
for (id, model) in db.as_private().as_cifs().as_entries()? {
|
||||
let mount_info = model.de()?;
|
||||
let embassy_os = async {
|
||||
let start_os = async {
|
||||
let guard = TmpMountGuard::mount(&mount_info, ReadOnly).await?;
|
||||
let embassy_os = recovery_info(guard.path()).await?;
|
||||
let start_os = recovery_info(guard.path()).await?;
|
||||
guard.unmount().await?;
|
||||
Ok::<_, Error>(embassy_os)
|
||||
Ok::<_, Error>(start_os)
|
||||
}
|
||||
.await;
|
||||
cifs.push((
|
||||
@@ -237,8 +237,8 @@ pub async fn list(db: &DatabaseModel) -> Result<Vec<(u32, CifsBackupTarget)>, Er
|
||||
hostname: mount_info.hostname,
|
||||
path: mount_info.path,
|
||||
username: mount_info.username,
|
||||
mountable: embassy_os.is_ok(),
|
||||
embassy_os: embassy_os.ok().and_then(|a| a),
|
||||
mountable: start_os.is_ok(),
|
||||
start_os: start_os.ok().and_then(|a| a),
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ fn display_disk_info(params: WithIoFormat<Empty>, args: Vec<DiskInfo>) {
|
||||
} else {
|
||||
"N/A"
|
||||
},
|
||||
if let Some(eos) = part.embassy_os.as_ref() {
|
||||
if let Some(eos) = part.start_os.as_ref() {
|
||||
eos.version.as_str()
|
||||
} else {
|
||||
"N/A"
|
||||
|
||||
@@ -49,7 +49,7 @@ pub struct PartitionInfo {
|
||||
pub label: Option<String>,
|
||||
pub capacity: u64,
|
||||
pub used: Option<u64>,
|
||||
pub embassy_os: Option<EmbassyOsRecoveryInfo>,
|
||||
pub start_os: Option<EmbassyOsRecoveryInfo>,
|
||||
pub guid: Option<String>,
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ async fn disk_info(disk: PathBuf) -> DiskInfo {
|
||||
}
|
||||
|
||||
async fn part_info(part: PathBuf) -> PartitionInfo {
|
||||
let mut embassy_os = None;
|
||||
let mut start_os = None;
|
||||
let label = get_label(&part)
|
||||
.await
|
||||
.map_err(|e| tracing::warn!("Could not get label of {}: {}", part.display(), e.source))
|
||||
@@ -417,7 +417,7 @@ async fn part_info(part: PathBuf) -> PartitionInfo {
|
||||
None
|
||||
}
|
||||
} {
|
||||
embassy_os = Some(recovery_info)
|
||||
start_os = Some(recovery_info)
|
||||
}
|
||||
if let Err(e) = mount_guard.unmount().await {
|
||||
tracing::error!("Error unmounting partition {}: {}", part.display(), e);
|
||||
@@ -430,7 +430,7 @@ async fn part_info(part: PathBuf) -> PartitionInfo {
|
||||
label,
|
||||
capacity,
|
||||
used,
|
||||
embassy_os,
|
||||
start_os,
|
||||
guid: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ pub fn main_ui_server_router(ctx: RpcContext) -> Router {
|
||||
}),
|
||||
)
|
||||
.fallback(any(move |request: Request| async move {
|
||||
main_embassy_ui(request, ctx)
|
||||
main_start_os_ui(request, ctx)
|
||||
.await
|
||||
.unwrap_or_else(server_error)
|
||||
}))
|
||||
@@ -218,7 +218,7 @@ async fn if_authorized<
|
||||
}
|
||||
}
|
||||
|
||||
async fn main_embassy_ui(req: Request, ctx: RpcContext) -> Result<Response, Error> {
|
||||
async fn main_start_os_ui(req: Request, ctx: RpcContext) -> Result<Response, Error> {
|
||||
let (request_parts, _body) = req.into_parts();
|
||||
match (
|
||||
&request_parts.method,
|
||||
|
||||
@@ -293,7 +293,7 @@ pub async fn execute(
|
||||
.invoke(crate::ErrorKind::OpenSsh)
|
||||
.await?;
|
||||
|
||||
let embassy_fs = MountGuard::mount(
|
||||
let start_os_fs = MountGuard::mount(
|
||||
&Bind::new(rootfs.path()),
|
||||
current.join("media/embassy/embassyfs"),
|
||||
MountType::ReadOnly,
|
||||
@@ -342,7 +342,7 @@ pub async fn execute(
|
||||
}
|
||||
sys.unmount(false).await?;
|
||||
proc.unmount(false).await?;
|
||||
embassy_fs.unmount(false).await?;
|
||||
start_os_fs.unmount(false).await?;
|
||||
if let Some(efi) = efi {
|
||||
efi.unmount(false).await?;
|
||||
}
|
||||
|
||||
@@ -240,9 +240,9 @@ pub async fn verify_cifs(
|
||||
ReadWrite,
|
||||
)
|
||||
.await?;
|
||||
let embassy_os = recovery_info(guard.path()).await?;
|
||||
let start_os = recovery_info(guard.path()).await?;
|
||||
guard.unmount().await?;
|
||||
embassy_os.ok_or_else(|| Error::new(eyre!("No Backup Found"), crate::ErrorKind::NotFound))
|
||||
start_os.ok_or_else(|| Error::new(eyre!("No Backup Found"), crate::ErrorKind::NotFound))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@@ -256,8 +256,8 @@ pub enum RecoverySource {
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExecuteParams {
|
||||
embassy_logicalname: PathBuf,
|
||||
embassy_password: EncryptedWire,
|
||||
start_os_logicalname: PathBuf,
|
||||
start_os_password: EncryptedWire,
|
||||
recovery_source: Option<RecoverySource>,
|
||||
recovery_password: Option<EncryptedWire>,
|
||||
}
|
||||
@@ -266,13 +266,13 @@ pub struct ExecuteParams {
|
||||
pub async fn execute(
|
||||
ctx: SetupContext,
|
||||
ExecuteParams {
|
||||
embassy_logicalname,
|
||||
embassy_password,
|
||||
start_os_logicalname,
|
||||
start_os_password,
|
||||
recovery_source,
|
||||
recovery_password,
|
||||
}: ExecuteParams,
|
||||
) -> Result<(), Error> {
|
||||
let embassy_password = match embassy_password.decrypt(&*ctx) {
|
||||
let start_os_password = match start_os_password.decrypt(&*ctx) {
|
||||
Some(a) => a,
|
||||
None => {
|
||||
return Err(Error::new(
|
||||
@@ -311,8 +311,8 @@ pub async fn execute(
|
||||
let ctx = ctx.clone();
|
||||
match execute_inner(
|
||||
ctx.clone(),
|
||||
embassy_logicalname,
|
||||
embassy_password,
|
||||
start_os_logicalname,
|
||||
start_os_password,
|
||||
recovery_source,
|
||||
recovery_password,
|
||||
)
|
||||
@@ -375,8 +375,8 @@ pub async fn exit(ctx: SetupContext) -> Result<(), Error> {
|
||||
#[instrument(skip_all)]
|
||||
pub async fn execute_inner(
|
||||
ctx: SetupContext,
|
||||
embassy_logicalname: PathBuf,
|
||||
embassy_password: String,
|
||||
start_os_logicalname: PathBuf,
|
||||
start_os_password: String,
|
||||
recovery_source: Option<RecoverySource>,
|
||||
recovery_password: Option<String>,
|
||||
) -> Result<(Arc<String>, Hostname, OnionAddressV3, X509), Error> {
|
||||
@@ -387,7 +387,7 @@ pub async fn execute_inner(
|
||||
};
|
||||
let guid = Arc::new(
|
||||
crate::disk::main::create(
|
||||
&[embassy_logicalname],
|
||||
&[start_os_logicalname],
|
||||
&pvscan().await?,
|
||||
&ctx.datadir,
|
||||
encryption_password,
|
||||
@@ -403,20 +403,20 @@ pub async fn execute_inner(
|
||||
.await?;
|
||||
|
||||
if let Some(RecoverySource::Backup { target }) = recovery_source {
|
||||
recover(ctx, guid, embassy_password, target, recovery_password).await
|
||||
recover(ctx, guid, start_os_password, target, recovery_password).await
|
||||
} else if let Some(RecoverySource::Migrate { guid: old_guid }) = recovery_source {
|
||||
migrate(ctx, guid, &old_guid, embassy_password).await
|
||||
migrate(ctx, guid, &old_guid, start_os_password).await
|
||||
} else {
|
||||
let (hostname, tor_addr, root_ca) = fresh_setup(&ctx, &embassy_password).await?;
|
||||
let (hostname, tor_addr, root_ca) = fresh_setup(&ctx, &start_os_password).await?;
|
||||
Ok((guid, hostname, tor_addr, root_ca))
|
||||
}
|
||||
}
|
||||
|
||||
async fn fresh_setup(
|
||||
ctx: &SetupContext,
|
||||
embassy_password: &str,
|
||||
start_os_password: &str,
|
||||
) -> Result<(Hostname, OnionAddressV3, X509), Error> {
|
||||
let account = AccountInfo::new(embassy_password, root_ca_start_time().await?)?;
|
||||
let account = AccountInfo::new(start_os_password, root_ca_start_time().await?)?;
|
||||
let db = ctx.db().await?;
|
||||
db.put(&ROOT, &Database::init(&account)?).await?;
|
||||
drop(db);
|
||||
@@ -432,7 +432,7 @@ async fn fresh_setup(
|
||||
async fn recover(
|
||||
ctx: SetupContext,
|
||||
guid: Arc<String>,
|
||||
embassy_password: String,
|
||||
start_os_password: String,
|
||||
recovery_source: BackupTargetFS,
|
||||
recovery_password: Option<String>,
|
||||
) -> Result<(Arc<String>, Hostname, OnionAddressV3, X509), Error> {
|
||||
@@ -440,7 +440,7 @@ async fn recover(
|
||||
recover_full_embassy(
|
||||
ctx,
|
||||
guid.clone(),
|
||||
embassy_password,
|
||||
start_os_password,
|
||||
recovery_source,
|
||||
recovery_password,
|
||||
)
|
||||
@@ -452,7 +452,7 @@ async fn migrate(
|
||||
ctx: SetupContext,
|
||||
guid: Arc<String>,
|
||||
old_guid: &str,
|
||||
embassy_password: String,
|
||||
start_os_password: String,
|
||||
) -> Result<(Arc<String>, Hostname, OnionAddressV3, X509), Error> {
|
||||
*ctx.setup_status.write().await = Some(Ok(SetupStatus {
|
||||
bytes_transferred: 0,
|
||||
@@ -537,7 +537,7 @@ async fn migrate(
|
||||
} => res,
|
||||
}
|
||||
|
||||
let (hostname, tor_addr, root_ca) = setup_init(&ctx, Some(embassy_password)).await?;
|
||||
let (hostname, tor_addr, root_ca) = setup_init(&ctx, Some(start_os_password)).await?;
|
||||
|
||||
crate::disk::main::export(&old_guid, "/media/embassy/migrate").await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user