mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
Feature/consolidate setup (#3092)
* start consolidating * add start-cli flash-os * combine install and setup and refactor all * use http * undo mock * fix translation * translations * use dialogservice wrapper * better ST messaging on setup * only warn on update if breakages (#3097) * finish setup wizard and ui language-keyboard feature * fix typo * wip: localization * remove start-tunnel readme * switch to posix strings for language internal * revert mock * translate backend strings * fix missing about text * help text for args * feat: add "Add new gateway" option (#3098) * feat: add "Add new gateway" option * Update web/projects/ui/src/app/routes/portal/components/form/controls/select.component.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * add translation --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Matt Hill <mattnine@protonmail.com> * fix dns selection * keyboard keymap also * ability to shutdown after install * revert mock * working setup flow + manifest localization * (mostly) redundant localization on frontend * version bump * omit live medium from disk list and better space management * ignore missing package archive on 035 migration * fix device migration * add i18n helper to sdk * fix install over 0.3.5.1 * fix grub config --------- Co-authored-by: Matt Hill <mattnine@protonmail.com> Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Alex Inkin <alexander@inkin.ru> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -33,11 +33,13 @@ use crate::version::VersionT;
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct BackupParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
target_id: BackupTargetId,
|
||||
#[arg(long = "old-password")]
|
||||
#[arg(long = "old-password", help = "help.arg.old-backup-password")]
|
||||
old_password: Option<crate::auth::PasswordType>,
|
||||
#[arg(long = "package-ids")]
|
||||
#[arg(long = "package-ids", help = "help.arg.package-ids-to-backup")]
|
||||
package_ids: Option<Vec<PackageId>>,
|
||||
#[arg(help = "help.arg.backup-password")]
|
||||
password: crate::auth::PasswordType,
|
||||
}
|
||||
|
||||
@@ -69,8 +71,8 @@ impl BackupStatusGuard {
|
||||
db,
|
||||
None,
|
||||
NotificationLevel::Success,
|
||||
"Backup Complete".to_owned(),
|
||||
"Your backup has completed".to_owned(),
|
||||
t!("backup.bulk.complete-title").to_string(),
|
||||
t!("backup.bulk.complete-message").to_string(),
|
||||
BackupReport {
|
||||
server: ServerBackupReport {
|
||||
attempted: true,
|
||||
@@ -88,9 +90,8 @@ impl BackupStatusGuard {
|
||||
db,
|
||||
None,
|
||||
NotificationLevel::Warning,
|
||||
"Backup Complete".to_owned(),
|
||||
"Your backup has completed, but some package(s) failed to backup"
|
||||
.to_owned(),
|
||||
t!("backup.bulk.complete-title").to_string(),
|
||||
t!("backup.bulk.complete-with-failures").to_string(),
|
||||
BackupReport {
|
||||
server: ServerBackupReport {
|
||||
attempted: true,
|
||||
@@ -103,7 +104,7 @@ impl BackupStatusGuard {
|
||||
.await
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Backup Failed: {}", e);
|
||||
tracing::error!("{}", t!("backup.bulk.failed-error", error = e));
|
||||
tracing::debug!("{:?}", e);
|
||||
let err_string = e.to_string();
|
||||
db.mutate(|db| {
|
||||
@@ -111,8 +112,8 @@ impl BackupStatusGuard {
|
||||
db,
|
||||
None,
|
||||
NotificationLevel::Error,
|
||||
"Backup Failed".to_owned(),
|
||||
"Your backup failed to complete.".to_owned(),
|
||||
t!("backup.bulk.failed-title").to_string(),
|
||||
t!("backup.bulk.failed-message").to_string(),
|
||||
BackupReport {
|
||||
server: ServerBackupReport {
|
||||
attempted: true,
|
||||
@@ -224,7 +225,7 @@ fn assure_backing_up<'a>(
|
||||
.as_backup_progress_mut();
|
||||
if backing_up.transpose_ref().is_some() {
|
||||
return Err(Error::new(
|
||||
eyre!("Server is already backing up!"),
|
||||
eyre!("{}", t!("backup.bulk.already-backing-up")),
|
||||
ErrorKind::InvalidRequest,
|
||||
));
|
||||
}
|
||||
@@ -303,7 +304,7 @@ async fn perform_backup(
|
||||
|
||||
let mut backup_guard = Arc::try_unwrap(backup_guard).map_err(|_| {
|
||||
Error::new(
|
||||
eyre!("leaked reference to BackupMountGuard"),
|
||||
eyre!("{}", t!("backup.bulk.leaked-reference")),
|
||||
ErrorKind::Incoherent,
|
||||
)
|
||||
})?;
|
||||
|
||||
@@ -37,12 +37,12 @@ pub fn backup<C: Context>() -> ParentHandler<C> {
|
||||
"create",
|
||||
from_fn_async(backup_bulk::backup_all)
|
||||
.no_display()
|
||||
.with_about("Create backup for all packages")
|
||||
.with_about("about.create-backup-all-packages")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"target",
|
||||
target::target::<C>().with_about("Commands related to a backup target"),
|
||||
target::target::<C>().with_about("about.commands-backup-target"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ pub fn package_backup<C: Context>() -> ParentHandler<C> {
|
||||
"restore",
|
||||
from_fn_async(restore::restore_packages_rpc)
|
||||
.no_display()
|
||||
.with_about("Restore package(s) from backup")
|
||||
.with_about("about.restore-packages-from-backup")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -23,16 +23,19 @@ use crate::progress::ProgressUnits;
|
||||
use crate::s9pk::S9pk;
|
||||
use crate::service::service_map::DownloadInstallFuture;
|
||||
use crate::setup::SetupExecuteProgress;
|
||||
use crate::system::sync_kiosk;
|
||||
use crate::util::serde::IoFormat;
|
||||
use crate::system::{save_language, sync_kiosk};
|
||||
use crate::util::serde::{IoFormat, Pem};
|
||||
use crate::{PLATFORM, PackageId};
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct RestorePackageParams {
|
||||
#[arg(help = "help.arg.package-ids")]
|
||||
pub ids: Vec<PackageId>,
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
pub target_id: BackupTargetId,
|
||||
#[arg(help = "help.arg.backup-password")]
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
@@ -63,7 +66,10 @@ pub async fn restore_packages_rpc(
|
||||
match async { res.await?.await }.await {
|
||||
Ok(_) => (),
|
||||
Err(err) => {
|
||||
tracing::error!("Error restoring package {}: {}", id, err);
|
||||
tracing::error!(
|
||||
"{}",
|
||||
t!("backup.restore.package-error", id = id, error = err)
|
||||
);
|
||||
tracing::debug!("{:?}", err);
|
||||
}
|
||||
}
|
||||
@@ -75,10 +81,10 @@ pub async fn restore_packages_rpc(
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub async fn recover_full_embassy(
|
||||
pub async fn recover_full_server(
|
||||
ctx: &SetupContext,
|
||||
disk_guid: Arc<String>,
|
||||
start_os_password: String,
|
||||
disk_guid: InternedString,
|
||||
password: String,
|
||||
recovery_source: TmpMountGuard,
|
||||
server_id: &str,
|
||||
recovery_password: &str,
|
||||
@@ -102,7 +108,7 @@ pub async fn recover_full_embassy(
|
||||
)?;
|
||||
|
||||
os_backup.account.password = argon2::hash_encoded(
|
||||
start_os_password.as_bytes(),
|
||||
password.as_bytes(),
|
||||
&rand::random::<[u8; 16]>()[..],
|
||||
&argon2::Config::rfc9106_low_mem(),
|
||||
)
|
||||
@@ -111,16 +117,32 @@ pub async fn recover_full_embassy(
|
||||
let kiosk = Some(kiosk.unwrap_or(true)).filter(|_| &*PLATFORM != "raspberrypi");
|
||||
sync_kiosk(kiosk).await?;
|
||||
|
||||
let language = ctx.language.peek(|a| a.clone());
|
||||
let keyboard = ctx.keyboard.peek(|a| a.clone());
|
||||
|
||||
if let Some(language) = &language {
|
||||
save_language(&**language).await?;
|
||||
}
|
||||
|
||||
if let Some(keyboard) = &keyboard {
|
||||
keyboard.save().await?;
|
||||
}
|
||||
|
||||
let db = ctx.db().await?;
|
||||
db.put(&ROOT, &Database::init(&os_backup.account, kiosk)?)
|
||||
.await?;
|
||||
db.put(
|
||||
&ROOT,
|
||||
&Database::init(&os_backup.account, kiosk, language, keyboard)?,
|
||||
)
|
||||
.await?;
|
||||
drop(db);
|
||||
|
||||
let init_result = init(&ctx.webserver, &ctx.config, init_phases).await?;
|
||||
let config = ctx.config.peek(|c| c.clone());
|
||||
|
||||
let init_result = init(&ctx.webserver, &config, init_phases).await?;
|
||||
|
||||
let rpc_ctx = RpcContext::init(
|
||||
&ctx.webserver,
|
||||
&ctx.config,
|
||||
&config,
|
||||
disk_guid.clone(),
|
||||
Some(init_result),
|
||||
rpc_ctx_phases,
|
||||
@@ -145,7 +167,10 @@ pub async fn recover_full_embassy(
|
||||
match async { res.await?.await }.await {
|
||||
Ok(_) => (),
|
||||
Err(err) => {
|
||||
tracing::error!("Error restoring package {}: {}", id, err);
|
||||
tracing::error!(
|
||||
"{}",
|
||||
t!("backup.restore.package-error", id = id, error = err)
|
||||
);
|
||||
tracing::debug!("{:?}", err);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +180,14 @@ pub async fn recover_full_embassy(
|
||||
.await;
|
||||
restore_phase.lock().await.complete();
|
||||
|
||||
Ok(((&os_backup.account).try_into()?, rpc_ctx))
|
||||
Ok((
|
||||
SetupResult {
|
||||
hostname: os_backup.account.hostname,
|
||||
root_ca: Pem(os_backup.account.root_ca_cert),
|
||||
needs_restart: ctx.install_rootfs.peek(|a| a.is_some()),
|
||||
},
|
||||
rpc_ctx,
|
||||
))
|
||||
}
|
||||
|
||||
#[instrument(skip(ctx, backup_guard))]
|
||||
|
||||
@@ -52,21 +52,21 @@ pub fn cifs<C: Context>() -> ParentHandler<C> {
|
||||
"add",
|
||||
from_fn_async(add)
|
||||
.no_display()
|
||||
.with_about("Add a new backup target")
|
||||
.with_about("about.add-new-backup-target")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"update",
|
||||
from_fn_async(update)
|
||||
.no_display()
|
||||
.with_about("Update an existing backup target")
|
||||
.with_about("about.update-existing-backup-target")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"remove",
|
||||
from_fn_async(remove)
|
||||
.no_display()
|
||||
.with_about("Remove an existing backup target")
|
||||
.with_about("about.remove-existing-backup-target")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
}
|
||||
@@ -75,9 +75,13 @@ pub fn cifs<C: Context>() -> ParentHandler<C> {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct AddParams {
|
||||
#[arg(help = "help.arg.cifs-hostname")]
|
||||
pub hostname: String,
|
||||
#[arg(help = "help.arg.cifs-path")]
|
||||
pub path: PathBuf,
|
||||
#[arg(help = "help.arg.cifs-username")]
|
||||
pub username: String,
|
||||
#[arg(help = "help.arg.cifs-password")]
|
||||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
@@ -130,10 +134,15 @@ pub async fn add(
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct UpdateParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
pub id: BackupTargetId,
|
||||
#[arg(help = "help.arg.cifs-hostname")]
|
||||
pub hostname: String,
|
||||
#[arg(help = "help.arg.cifs-path")]
|
||||
pub path: PathBuf,
|
||||
#[arg(help = "help.arg.cifs-username")]
|
||||
pub username: String,
|
||||
#[arg(help = "help.arg.cifs-password")]
|
||||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
@@ -151,7 +160,7 @@ pub async fn update(
|
||||
id
|
||||
} else {
|
||||
return Err(Error::new(
|
||||
eyre!("Backup Target ID {} Not Found", id),
|
||||
eyre!("{}", t!("backup.target.cifs.target-not-found", id = id)),
|
||||
ErrorKind::NotFound,
|
||||
));
|
||||
};
|
||||
@@ -171,7 +180,7 @@ pub async fn update(
|
||||
.as_idx_mut(&id)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
eyre!("Backup Target ID {} Not Found", BackupTargetId::Cifs { id }),
|
||||
eyre!("{}", t!("backup.target.cifs.target-not-found", id = BackupTargetId::Cifs { id })),
|
||||
ErrorKind::NotFound,
|
||||
)
|
||||
})?
|
||||
@@ -195,6 +204,7 @@ pub async fn update(
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct RemoveParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
pub id: BackupTargetId,
|
||||
}
|
||||
|
||||
@@ -203,7 +213,7 @@ pub async fn remove(ctx: RpcContext, RemoveParams { id }: RemoveParams) -> Resul
|
||||
id
|
||||
} else {
|
||||
return Err(Error::new(
|
||||
eyre!("Backup Target ID {} Not Found", id),
|
||||
eyre!("{}", t!("backup.target.cifs.target-not-found", id = id)),
|
||||
ErrorKind::NotFound,
|
||||
));
|
||||
};
|
||||
@@ -220,7 +230,7 @@ pub fn load(db: &DatabaseModel, id: u32) -> Result<Cifs, Error> {
|
||||
.as_idx(&id)
|
||||
.ok_or_else(|| {
|
||||
Error::new(
|
||||
eyre!("Backup Target ID {} Not Found", id),
|
||||
eyre!("{}", t!("backup.target.cifs.target-not-found-id", id = id)),
|
||||
ErrorKind::NotFound,
|
||||
)
|
||||
})?
|
||||
|
||||
@@ -143,13 +143,13 @@ pub fn target<C: Context>() -> ParentHandler<C> {
|
||||
ParentHandler::new()
|
||||
.subcommand(
|
||||
"cifs",
|
||||
cifs::cifs::<C>().with_about("Add, remove, or update a backup target"),
|
||||
cifs::cifs::<C>().with_about("about.add-remove-update-backup-target"),
|
||||
)
|
||||
.subcommand(
|
||||
"list",
|
||||
from_fn_async(list)
|
||||
.with_display_serializable()
|
||||
.with_about("List existing backup targets")
|
||||
.with_about("about.list-existing-backup-targets")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
@@ -159,20 +159,20 @@ pub fn target<C: Context>() -> ParentHandler<C> {
|
||||
.with_custom_display_fn::<CliContext, _>(|params, info| {
|
||||
display_backup_info(params.params, info)
|
||||
})
|
||||
.with_about("Display package backup information")
|
||||
.with_about("about.display-package-backup-information")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"mount",
|
||||
from_fn_async(mount)
|
||||
.with_about("Mount backup target")
|
||||
.with_about("about.mount-backup-target")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
.subcommand(
|
||||
"umount",
|
||||
from_fn_async(umount)
|
||||
.no_display()
|
||||
.with_about("Unmount backup target")
|
||||
.with_about("about.unmount-backup-target")
|
||||
.with_call_remote::<CliContext>(),
|
||||
)
|
||||
}
|
||||
@@ -268,8 +268,11 @@ fn display_backup_info(params: WithIoFormat<InfoParams>, info: BackupInfo) -> Re
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct InfoParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
target_id: BackupTargetId,
|
||||
#[arg(help = "help.arg.server-id")]
|
||||
server_id: String,
|
||||
#[arg(help = "help.arg.backup-password")]
|
||||
password: String,
|
||||
}
|
||||
|
||||
@@ -305,11 +308,13 @@ lazy_static::lazy_static! {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct MountParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
target_id: BackupTargetId,
|
||||
#[arg(long)]
|
||||
#[arg(long, help = "help.arg.server-id")]
|
||||
server_id: Option<String>,
|
||||
#[arg(help = "help.arg.backup-password")]
|
||||
password: String, // TODO: rpassword
|
||||
#[arg(long)]
|
||||
#[arg(long, help = "help.arg.allow-partial-backup")]
|
||||
allow_partial: bool,
|
||||
}
|
||||
|
||||
@@ -385,6 +390,7 @@ pub async fn mount(
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
pub struct UmountParams {
|
||||
#[arg(help = "help.arg.backup-target-id")]
|
||||
target_id: Option<BackupTargetId>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user