From 22a32af7502edf67e2e16b916aa44dbf94049dde Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 2 Dec 2024 13:58:09 -0700 Subject: [PATCH] use notification system for OS updates (#2670) * use notification system for OS updates * feat: Include the version update notification in the update in rs * chore: Change the location of the comment * progress on release notes * fill out missing sections * fix build * fix build --------- Co-authored-by: J H Co-authored-by: Aiden McClelland --- core/startos/src/notifications.rs | 5 +- .../src/version/update_details/v0_3_6.md | 83 +++++++++++++++++++ core/startos/src/version/v0_3_6_alpha_6.rs | 30 +++++-- web/projects/ui/src/app/app.module.ts | 2 - .../ui/src/app/components/form/control.ts | 5 +- .../form-control/form-control.component.html | 2 +- .../form-control/form-control.providers.ts | 7 +- .../modals/os-welcome/os-welcome.module.ts | 13 --- .../modals/os-welcome/os-welcome.page.html | 32 ------- .../modals/os-welcome/os-welcome.page.scss | 29 ------- .../app/modals/os-welcome/os-welcome.page.ts | 15 ---- .../notifications/notifications.page.html | 9 ++ .../pages/notifications/notifications.page.ts | 20 ++++- .../ui/src/app/services/api/api.fixures.ts | 18 +++- .../ui/src/app/services/api/api.types.ts | 2 + .../ui/src/app/services/api/mock-patch.ts | 1 - .../ui/src/app/services/patch-data.service.ts | 30 +------ .../src/app/services/patch-db/data-model.ts | 1 - 18 files changed, 167 insertions(+), 137 deletions(-) create mode 100644 core/startos/src/version/update_details/v0_3_6.md delete mode 100644 web/projects/ui/src/app/modals/os-welcome/os-welcome.module.ts delete mode 100644 web/projects/ui/src/app/modals/os-welcome/os-welcome.page.html delete mode 100644 web/projects/ui/src/app/modals/os-welcome/os-welcome.page.scss delete mode 100644 web/projects/ui/src/app/modals/os-welcome/os-welcome.page.ts diff --git a/core/startos/src/notifications.rs b/core/startos/src/notifications.rs index b310220b53..4b45531a46 100644 --- a/core/startos/src/notifications.rs +++ b/core/startos/src/notifications.rs @@ -13,11 +13,11 @@ use serde::{Deserialize, Serialize}; use tracing::instrument; use ts_rs::TS; -use crate::backup::BackupReport; use crate::context::{CliContext, RpcContext}; use crate::db::model::DatabaseModel; use crate::prelude::*; use crate::util::serde::HandlerExtSerde; +use crate::{backup::BackupReport, db::model::Database}; // #[command(subcommands(list, delete, delete_before, create))] pub fn notification() -> ParentHandler { @@ -285,6 +285,9 @@ impl NotificationType for () { impl NotificationType for BackupReport { const CODE: u32 = 1; } +impl NotificationType for String { + const CODE: u32 = 2; +} #[instrument(skip(subtype, db))] pub fn notify( diff --git a/core/startos/src/version/update_details/v0_3_6.md b/core/startos/src/version/update_details/v0_3_6.md new file mode 100644 index 0000000000..b93e8ad1ae --- /dev/null +++ b/core/startos/src/version/update_details/v0_3_6.md @@ -0,0 +1,83 @@ +# StartOS v0.3.6 + +## Warning + +Previous backups are incompatible with v0.3.6. It is strongly recommended that you (1) immediately update all services, then (2) create a fresh backup. See the [backups](#improved-backups) section below for more details. + +## Summary + +Servers are not toys. They are a critical component of the computing paradigm, and their failure can be catastrophic, resulting in downtime or loss of data. From the beginning, Start9 has taken a "security and reliability first" approach to the development of StartOS, favoring soundness over speed and prioritizing essential features such as encrypted network connections, simple backups, and a reliable container runtime over nice-to-haves like custom theming and more apps. + +Start9 is paving new ground with StartOS, trying to achieve what most developers and IT professionals thought impossible; namely, giving a normal person the same independent control over their data and communications as an experienced Linux sysadmin. + +A consequence of our principled approach to development, combined with the difficulty of our endeavor, is that (1) mistakes will be made and (2) they must be corrected. That means a willingness to discard bad ideas and broken parts, and if absolutely necessary, to nuke everything and start over from scratch. We did this in 2020 with StartOS v0.2.0, again in 2022 with StartOS v0.3.0, and now in 2024 with StartOS v0.3.6. + +StartOS v0.3.6 is a complete rewrite of the OS internals (everything you don't see). Almost nothing survived. After nearly five years of building StartOS, we believe that we have finally arrived at the correct architecture and foundation, and that no additional rewrites will be necessary for StartOS to deliver on its promise. + +## Changelog + +- [Switch to lxc-based container runtime](#lxc) +- [Update s9pk archive format](#new-s9pk-archive-format) +- [Improve config](#better-config) +- [Unify Actions](#unify-actions) +- [Use squashfs images for OS updates](#squashfs-updates) +- [Introduce Typescript package API and SDK](#typescript-package-api-and-sdk) +- [Remove Postgresql](#remove-postgressql) +- [Implement detailed progress reporting](#progress-reporting) +- [Improve registry protocol](#registry-protocol) +- [Replace unique .local URLs with unique ports](#lan-port-forwarding) +- [Use start-fs Fuse module for improved backups](#improved-backups) +- [Switch to Exver for versioning](#Exver) +- [Support clearnet hosting via start-cli](#clearnet) + +### LXC + +StartOS now uses a nested container paradigm based on LXC for the outer container, and using linux namespaces for the inner lite containers. This replaces both Docker and Podman. + +### S9PK archive format + +The S9PK archive format has been overhauled to allow for signature verification of partial downloads, and allow direct mounting of container images without unpacking the s9pk. + +### Better config + +Expanded support for input types and a new UI makes configuring services easier and more powerful. + +### Actions + +Actions take arbitrary form input _and_ return arbitrary responses, thus satisfying the needs of both Config and Properties, which will be removed in a future release. This gives packages developers the ability to break up Config and Properties into smaller, more specific formats, or to exclude them entirely without polluting the UI. + +### Squashfs updates + +StartOS now uses squashfs images to represent OS updates. This allows for better update verification, and improved reliability over rsync updates. + +### Typescript package API and SDK + +StartOS now exposes a Typescript API. Package developers can take advantage in a simple, typesafe way using the new start-sdk. A barebones StartOS package (s9pk) can be produced in minutes with minimal knowledge or skill. More advanced developers can use the SDK to create highly customized user experiences with their service. + +### Remove PostgresSQL + +StartOS itself has miniscule data persistence needs. PostgresSQL was overkill and has been removed in favor of lightweight PatchDB. + +### Progress reporting + +A new progress reporting API enabled package developers to create unique phases and provide real-time progress reporting for actions such as installing, updating, or backing up a service. + +### Registry protocol + +The new registry protocol bifurcates package indexing (listing/validating) and package hosting (downloading). Registries are now simple indexes of packages that reference binaries hosted in arbitrary locations, locally or externally. For example, when someone visits the Start9 Registry, the currated list of packages comes from Start9. But when someone installs a listed service, the package binary is being downloaded from Github. The registry also valides the binary. This makes it much easier to host a custom registry, since it is just a currated list of services tat reference package binaries hosted on Github or elsewhere. + +### LAN port forwarding + +Perhaps the biggest complaint with prior version of StartOS was use of unique .local URLs for service interfaces. This has been corrected. Service interfaces are now available on unique ports, allowing for non-http traffic on the LAN as well as remote access via VPN. + +### Improved Backups + +The new start-fs fuse module unifies file system expectations for various platforms, enabling more reliable backups. The new system also defaults to using rsync differential backups instead of incremental backups, which is faster and saves on disk space by also deleting from the backup files that were deleted from the server. + +### Exver + +StartOS now uses Extended Versioning (Exver), which consists of three parts, separated by semicolons: (1) a Semver-compliant upstream version, (2) a Semver-compliant wrapper version, and (3) an optional "flavor" prefix. Flavors can be thought of as alternative implementations of services, where a user would only want one or the other installed, and data can feasibly be migrating beetween the two. Another common characteristic of flavors is that they satisfy the same API requirement of dependents, though this is not strictly necessary. A valid Exver looks something like this: `#knots:28.0.:1.0-beta.1`. This would translate to "the first beta release of StartOS wrapper version 1.0 of Bitcoin Knots version 27.0". + +### Clearnet + +It is now possible, and quite easy, to expose specific services interfaces to the public Internet on a standard domain using start-cli. This functionality will be expanded upon and moved into the StartOS UI in a future release. diff --git a/core/startos/src/version/v0_3_6_alpha_6.rs b/core/startos/src/version/v0_3_6_alpha_6.rs index 843e5a45b6..d91caa82bf 100644 --- a/core/startos/src/version/v0_3_6_alpha_6.rs +++ b/core/startos/src/version/v0_3_6_alpha_6.rs @@ -2,6 +2,7 @@ use exver::{PreReleaseSegment, VersionRange}; use super::v0_3_5::V0_3_0_COMPAT; use super::{v0_3_6_alpha_5, VersionT}; +use crate::notifications::{notify, NotificationLevel}; use crate::prelude::*; lazy_static::lazy_static! { @@ -11,23 +12,40 @@ lazy_static::lazy_static! { ); } -#[derive(Clone, Copy, Debug, Default)] +#[derive(Default, Clone, Copy, Debug)] pub struct Version; impl VersionT for Version { type Previous = v0_3_6_alpha_5::Version; type PreUpRes = (); - - async fn pre_up(self) -> Result { - Ok(()) - } fn semver(self) -> exver::Version { V0_3_6_alpha_6.clone() } fn compat(self) -> &'static VersionRange { &V0_3_0_COMPAT } - fn up(self, _db: &mut Value, _: Self::PreUpRes) -> Result<(), Error> { + async fn pre_up(self) -> Result { + Ok(()) + } + fn up(self, db: &mut Value, _: Self::PreUpRes) -> Result<(), Error> { + Ok(()) + } + async fn post_up<'a>(self, ctx: &'a crate::context::RpcContext) -> Result<(), Error> { + let message_update = include_str!("update_details/v0_3_6.md").to_string(); + + ctx.db + .mutate(|db| { + notify( + db, + None, + NotificationLevel::Success, + "Welcome to StartOS 0.3.6!".to_string(), + "Click \"View Details\" to learn all about the new version".to_string(), + message_update, + )?; + Ok(()) + }) + .await?; Ok(()) } fn down(self, _db: &mut Value) -> Result<(), Error> { diff --git a/web/projects/ui/src/app/app.module.ts b/web/projects/ui/src/app/app.module.ts index 048d81fe0e..eb199d8a75 100644 --- a/web/projects/ui/src/app/app.module.ts +++ b/web/projects/ui/src/app/app.module.ts @@ -22,7 +22,6 @@ import { import { AppComponent } from './app.component' import { AppRoutingModule } from './app-routing.module' -import { OSWelcomePageModule } from './modals/os-welcome/os-welcome.module' import { MarketplaceModule } from './marketplace.module' import { PreloaderModule } from './app/preloader/preloader.module' import { FooterModule } from './app/footer/footer.module' @@ -47,7 +46,6 @@ import { environment } from '../environments/environment' PreloaderModule, FooterModule, EnterModule, - OSWelcomePageModule, MarkdownModule, LoadingModule, MonacoEditorModule, diff --git a/web/projects/ui/src/app/components/form/control.ts b/web/projects/ui/src/app/components/form/control.ts index c77c76ecf9..5cf9d84abb 100644 --- a/web/projects/ui/src/app/components/form/control.ts +++ b/web/projects/ui/src/app/components/form/control.ts @@ -2,7 +2,10 @@ import { inject } from '@angular/core' import { FormControlComponent } from './form-control/form-control.component' import { IST } from '@start9labs/start-sdk' -export abstract class Control, Value> { +export abstract class Control< + Spec extends Exclude, + Value, +> { private readonly control: FormControlComponent = inject(FormControlComponent) diff --git a/web/projects/ui/src/app/components/form/form-control/form-control.component.html b/web/projects/ui/src/app/components/form/form-control/form-control.component.html index dd3cf2b892..731d64a631 100644 --- a/web/projects/ui/src/app/components/form/form-control/form-control.component.html +++ b/web/projects/ui/src/app/components/form/form-control/form-control.component.html @@ -36,4 +36,4 @@ Accept - \ No newline at end of file + diff --git a/web/projects/ui/src/app/components/form/form-control/form-control.providers.ts b/web/projects/ui/src/app/components/form/form-control/form-control.providers.ts index 62e1ff6aaa..f61ac092d1 100644 --- a/web/projects/ui/src/app/components/form/form-control/form-control.providers.ts +++ b/web/projects/ui/src/app/components/form/form-control/form-control.providers.ts @@ -12,7 +12,12 @@ export const FORM_CONTROL_PROVIDERS: Provider[] = [ { provide: TUI_VALIDATION_ERRORS, deps: [forwardRef(() => FormControlComponent)], - useFactory: (control: FormControlComponent, string>) => ({ + useFactory: ( + control: FormControlComponent< + Exclude, + string + >, + ) => ({ required: 'Required', pattern: ({ requiredPattern }: ValidatorsPatternError) => ('patterns' in control.spec && diff --git a/web/projects/ui/src/app/modals/os-welcome/os-welcome.module.ts b/web/projects/ui/src/app/modals/os-welcome/os-welcome.module.ts deleted file mode 100644 index 3e910403e4..0000000000 --- a/web/projects/ui/src/app/modals/os-welcome/os-welcome.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { NgModule } from '@angular/core' -import { CommonModule } from '@angular/common' -import { IonicModule } from '@ionic/angular' -import { OSWelcomePage } from './os-welcome.page' -import { SharedPipesModule } from '@start9labs/shared' -import { FormsModule } from '@angular/forms' - -@NgModule({ - declarations: [OSWelcomePage], - imports: [CommonModule, IonicModule, FormsModule, SharedPipesModule], - exports: [OSWelcomePage], -}) -export class OSWelcomePageModule {} diff --git a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.html b/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.html deleted file mode 100644 index 0b06c4a909..0000000000 --- a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.html +++ /dev/null @@ -1,32 +0,0 @@ - - - Release Notes - - - - - - - - - -

This Release

- -

0.3.6-alpha.8

-
This is an ALPHA release! DO NOT use for production data!
-
- Expect that any data you create or store on this version of the OS can be - LOST FOREVER! -
- -
- - Begin - -
-
diff --git a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.scss b/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.scss deleted file mode 100644 index 0dc939f99e..0000000000 --- a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.scss +++ /dev/null @@ -1,29 +0,0 @@ -.close-button { - width: 100%; - display: flex; - justify-content: center; - align-items: center; - min-height: 100px; -} - -.main-content { - color: var(--ion-color-dark); -} - -.spaced-list { - li { - padding-bottom: 12px; - } -} - -.note-padding { - padding-bottom: 12px; -} - -h2 { - font-weight: bold; -} - -h4 { - font-style: italic; -} \ No newline at end of file diff --git a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.ts b/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.ts deleted file mode 100644 index f9a6ecd7b0..0000000000 --- a/web/projects/ui/src/app/modals/os-welcome/os-welcome.page.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, Input } from '@angular/core' -import { ModalController } from '@ionic/angular' - -@Component({ - selector: 'os-welcome', - templateUrl: './os-welcome.page.html', - styleUrls: ['./os-welcome.page.scss'], -}) -export class OSWelcomePage { - constructor(private readonly modalCtrl: ModalController) {} - - async dismiss() { - return this.modalCtrl.dismiss() - } -} diff --git a/web/projects/ui/src/app/pages/notifications/notifications.page.html b/web/projects/ui/src/app/pages/notifications/notifications.page.html index fb3ba08838..a00fb76cbe 100644 --- a/web/projects/ui/src/app/pages/notifications/notifications.page.html +++ b/web/projects/ui/src/app/pages/notifications/notifications.page.html @@ -115,6 +115,15 @@

{{ truncate(not.message) }}

> View Report + + View Details + ) { + const modal = await this.modalCtrl.create({ + componentProps: { + title: not.title, + content: not.data, + }, + component: MarkdownComponent, + }) + + await modal.present() + } + async viewFullMessage(header: string, message: string) { const alert = await this.alertCtrl.create({ header, @@ -134,7 +150,7 @@ export class NotificationsPage { } truncate(message: string): string { - return message.length <= 240 ? message : '...' + message.substr(-240) + return message.length <= 240 ? message : message.substring(0, 160) + '...' } getColor({ level }: ServerNotification): string { diff --git a/web/projects/ui/src/app/services/api/api.fixures.ts b/web/projects/ui/src/app/services/api/api.fixures.ts index 2f93b3e283..a3562caa6f 100644 --- a/web/projects/ui/src/app/services/api/api.fixures.ts +++ b/web/projects/ui/src/app/services/api/api.fixures.ts @@ -9,6 +9,8 @@ import { configBuilderToSpec } from 'src/app/util/configBuilderToSpec' import { T, ISB, IST } from '@start9labs/start-sdk' import { GetPackagesRes } from '@start9labs/marketplace' +import markdown from 'raw-loader!../../../../../shared/assets/markdown/md-sample.md' + const mockMerkleArchiveCommitment: T.MerkleArchiveCommitment = { rootSighash: 'fakehash', rootMaxsize: 0, @@ -759,7 +761,7 @@ export module Mock { id: 2, packageId: null, createdAt: '2019-12-26T14:20:30.872Z', - code: 2, + code: 0, level: NotificationLevel.Warning, title: 'SSH Key Added', message: 'A new SSH key was added. If you did not do this, shit is bad.', @@ -769,7 +771,7 @@ export module Mock { id: 3, packageId: null, createdAt: '2019-12-26T14:20:30.872Z', - code: 3, + code: 0, level: NotificationLevel.Info, title: 'SSH Key Removed', message: 'A SSH key was removed.', @@ -779,7 +781,7 @@ export module Mock { id: 4, packageId: 'bitcoind', createdAt: '2019-12-26T14:20:30.872Z', - code: 4, + code: 0, level: NotificationLevel.Error, title: 'Service Crashed', message: new Array(40) @@ -792,6 +794,16 @@ export module Mock { .join(''), data: null, }, + { + id: 5, + packageId: null, + createdAt: '2019-12-26T14:20:30.872Z', + code: 2, + level: NotificationLevel.Success, + title: 'Welcome to StartOS 0.3.6!', + message: 'Click "View Details" to learn all about the new version', + data: markdown, + }, ] export function getServerMetrics() { diff --git a/web/projects/ui/src/app/services/api/api.types.ts b/web/projects/ui/src/app/services/api/api.types.ts index fcf375913f..9120a2df7f 100644 --- a/web/projects/ui/src/app/services/api/api.types.ts +++ b/web/projects/ui/src/app/services/api/api.types.ts @@ -442,6 +442,8 @@ export type NotificationData = T extends 0 ? null : T extends 1 ? BackupReport + : T extends 2 + ? string : any export interface BackupReport { diff --git a/web/projects/ui/src/app/services/api/mock-patch.ts b/web/projects/ui/src/app/services/api/mock-patch.ts index aea6b58285..81e316b562 100644 --- a/web/projects/ui/src/app/services/api/mock-patch.ts +++ b/web/projects/ui/src/app/services/api/mock-patch.ts @@ -6,7 +6,6 @@ const version = require('../../../../../../package.json').version export const mockPatchData: DataModel = { ui: { name: `Matt's Server`, - ackWelcome: '1.0.0', theme: 'Dark', widgets: BUILT_IN_WIDGETS.filter( ({ id }) => diff --git a/web/projects/ui/src/app/services/patch-data.service.ts b/web/projects/ui/src/app/services/patch-data.service.ts index 50023c1f1b..35728c9ec9 100644 --- a/web/projects/ui/src/app/services/patch-data.service.ts +++ b/web/projects/ui/src/app/services/patch-data.service.ts @@ -1,13 +1,9 @@ import { Inject, Injectable } from '@angular/core' -import { ModalController } from '@ionic/angular' import { Observable } from 'rxjs' -import { filter, map, share, switchMap, take, tap } from 'rxjs/operators' +import { filter, map, share, switchMap, take } from 'rxjs/operators' import { PatchDB } from 'patch-db-client' import { DataModel } from 'src/app/services/patch-db/data-model' import { EOSService } from 'src/app/services/eos.service' -import { OSWelcomePage } from 'src/app/modals/os-welcome/os-welcome.page' -import { ConfigService } from 'src/app/services/config.service' -import { ApiService } from 'src/app/services/api/embassy-api.service' import { MarketplaceService } from 'src/app/services/marketplace.service' import { AbstractMarketplaceService } from '@start9labs/marketplace' import { ConnectionService } from 'src/app/services/connection.service' @@ -27,8 +23,6 @@ export class PatchDataService extends Observable { if (index === 0) { // check for updates to StartOS and services this.checkForUpdates() - // show eos welcome message - this.showEosWelcome(cache.ui.ackWelcome) } }), share(), @@ -37,9 +31,6 @@ export class PatchDataService extends Observable { constructor( private readonly patch: PatchDB, private readonly eosService: EOSService, - private readonly config: ConfigService, - private readonly modalCtrl: ModalController, - private readonly embassyApi: ApiService, @Inject(AbstractMarketplaceService) private readonly marketplaceService: MarketplaceService, private readonly connection$: ConnectionService, @@ -52,23 +43,4 @@ export class PatchDataService extends Observable { this.eosService.loadEos() this.marketplaceService.getMarketplace$().pipe(take(1)).subscribe() } - - private async showEosWelcome(ackVersion: string): Promise { - if (this.config.skipStartupAlerts || ackVersion === this.config.version) { - return - } - - const modal = await this.modalCtrl.create({ - component: OSWelcomePage, - presentingElement: await this.modalCtrl.getTop(), - backdropDismiss: false, - }) - modal.onWillDismiss().then(() => { - this.embassyApi - .setDbValue(['ackWelcome'], this.config.version) - .catch() - }) - - await modal.present() - } } diff --git a/web/projects/ui/src/app/services/patch-db/data-model.ts b/web/projects/ui/src/app/services/patch-db/data-model.ts index d7deb31df9..01f80c3a75 100644 --- a/web/projects/ui/src/app/services/patch-db/data-model.ts +++ b/web/projects/ui/src/app/services/patch-db/data-model.ts @@ -7,7 +7,6 @@ export type DataModel = T.Public & { export interface UIData { name: string | null - ackWelcome: string // eOS emver marketplace: UIMarketplaceData gaming: { snake: {