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