Skip to content

Commit

Permalink
Merge branch 'next/minor' of github.com:Start9Labs/start-os into next…
Browse files Browse the repository at this point in the history
…/major
  • Loading branch information
MattDHill committed Dec 2, 2024
2 parents 9f640b2 + f48750c commit a5bac39
Show file tree
Hide file tree
Showing 42 changed files with 601 additions and 190 deletions.
105 changes: 105 additions & 0 deletions build/lib/scripts/gather_debug_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# Define the output file
OUTPUT_FILE="system_debug_info.txt"

# Check if the script is run as root, if not, restart with sudo
if [ "$(id -u)" -ne 0 ]; then
exec sudo bash "$0" "$@"
fi

# Create or clear the output file and add a header
echo "===================================================================" > "$OUTPUT_FILE"
echo " StartOS System Debug Information " >> "$OUTPUT_FILE"
echo "===================================================================" >> "$OUTPUT_FILE"
echo "Generated on: $(date)" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"

# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Function to run a command if it exists and append its output to the file with headers
run_command() {
local CMD="$1"
local DESC="$2"
local CMD_NAME="${CMD%% *}" # Extract the command name (first word)

if command_exists "$CMD_NAME"; then
echo "===================================================================" >> "$OUTPUT_FILE"
echo "COMMAND: $CMD" >> "$OUTPUT_FILE"
echo "DESCRIPTION: $DESC" >> "$OUTPUT_FILE"
echo "===================================================================" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
eval "$CMD" >> "$OUTPUT_FILE" 2>&1
echo "" >> "$OUTPUT_FILE"
else
echo "===================================================================" >> "$OUTPUT_FILE"
echo "COMMAND: $CMD" >> "$OUTPUT_FILE"
echo "DESCRIPTION: $DESC" >> "$OUTPUT_FILE"
echo "===================================================================" >> "$OUTPUT_FILE"
echo "SKIPPED: Command not found" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
fi
}

# Collecting basic system information
run_command "start-cli --version; start-cli git-info" "StartOS CLI version and Git information"
run_command "hostname" "Hostname of the system"
run_command "uname -a" "Kernel version and system architecture"

# Services Info
run_command "start-cli lxc stats" "All Running Services"

# Collecting CPU information
run_command "lscpu" "CPU architecture information"
run_command "cat /proc/cpuinfo" "Detailed CPU information"

# Collecting memory information
run_command "free -h" "Available and used memory"
run_command "cat /proc/meminfo" "Detailed memory information"

# Collecting storage information
run_command "lsblk" "List of block devices"
run_command "df -h" "Disk space usage"
run_command "fdisk -l" "Detailed disk partition information"

# Collecting network information
run_command "ip a" "Network interfaces and IP addresses"
run_command "ip route" "Routing table"
run_command "netstat -i" "Network interface statistics"

# Collecting RAID information (if applicable)
run_command "cat /proc/mdstat" "List of RAID devices (if applicable)"

# Collecting virtualization information
run_command "egrep -c '(vmx|svm)' /proc/cpuinfo" "Check if CPU supports virtualization"
run_command "systemd-detect-virt" "Check if the system is running inside a virtual machine"

# Final message
echo "===================================================================" >> "$OUTPUT_FILE"
echo " End of StartOS System Debug Information " >> "$OUTPUT_FILE"
echo "===================================================================" >> "$OUTPUT_FILE"

# Prompt user to send the log file to a Start9 Technician
echo "System debug information has been collected in $OUTPUT_FILE."
echo ""
echo "Would you like to send this log file to a Start9 Technician? (yes/no)"
read SEND_LOG

if [[ "$SEND_LOG" == "yes" || "$SEND_LOG" == "y" ]]; then
if command -v wormhole >/dev/null 2>&1; then
echo ""
echo "==================================================================="
echo " Running wormhole to send the file. Please follow the "
echo " instructions and provide the code to the Start9 support team. "
echo "==================================================================="
wormhole send "$OUTPUT_FILE"
echo "==================================================================="
else
echo "Error: wormhole command not found."
fi
else
echo "Log file not sent. You can manually share $OUTPUT_FILE with the Start9 support team if needed."
fi
2 changes: 1 addition & 1 deletion core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/startos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = [
name = "start-os"
readme = "README.md"
repository = "https://github.com/Start9Labs/start-os"
version = "0.3.6-alpha.8"
version = "0.3.6-alpha.9"
license = "MIT"

[lib]
Expand Down
10 changes: 10 additions & 0 deletions core/startos/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,20 @@ impl fmt::Display for ActionResultV0 {
#[derive(Debug, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")]
pub struct ActionResultV1 {
/// Primary text to display as the header of the response modal. e.g. "Success!", "Name Updated", or "Service Information", whatever makes sense
pub title: String,
/// (optional) A general message for the user, just under the title
pub message: Option<String>,
/// (optional) Structured data to present inside the modal
pub result: Option<ActionResultValue>,
}

#[derive(Debug, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")]
pub struct ActionResultMember {
/// A human-readable name or title of the value, such as "Last Active" or "Login Password"
pub name: String,
/// (optional) A description of the value, such as an explaining why it exists or how to use it
pub description: Option<String>,
#[serde(flatten)]
#[ts(flatten)]
Expand All @@ -145,12 +150,17 @@ pub struct ActionResultMember {
#[serde(tag = "type")]
pub enum ActionResultValue {
Single {
/// The actual string value to display
value: String,
/// Whether or not to include a copy to clipboard icon to copy the value
copyable: bool,
/// Whether or not to also display the value as a QR code
qr: bool,
/// Whether or not to mask the value using ●●●●●●●, which is useful for password or other sensitive information
masked: bool,
},
Group {
/// An new group of nested values, experienced by the user as an accordion dropdown
value: Vec<ActionResultMember>,
},
}
Expand Down
12 changes: 12 additions & 0 deletions core/startos/src/db/model/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,25 @@ pub enum AllowedStatuses {
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct ActionMetadata {
/// A human-readable name
pub name: String,
/// A detailed description of what the action will do
pub description: String,
/// Presents as an alert prior to executing the action. Should be used sparingly but important if the action could have harmful, unintended consequences
pub warning: Option<String>,
#[serde(default)]
/// One of: "enabled", "hidden", or { disabled: "" }
/// - "enabled" - the action is available be run
/// - "hidden" - the action cannot be seen or run
/// - { disabled: "example explanation" } means the action is visible but cannot be run. Replace "example explanation" with a reason why the action is disable to prevent user confusion.
pub visibility: ActionVisibility,
/// One of: "only-stopped", "only-running", "all"
/// - "only-stopped" - the action can only be run when the service is stopped
/// - "only-running" - the action can only be run when the service is running
/// - "any" - the action can only be run regardless of the service's status
pub allowed_statuses: AllowedStatuses,
pub has_input: bool,
/// If provided, this action will be nested under a header of this value, along with other actions of the same group
pub group: Option<String>,
}

Expand Down
5 changes: 4 additions & 1 deletion core/startos/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C: Context>() -> ParentHandler<C> {
Expand Down Expand Up @@ -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<T: NotificationType>(
Expand Down
6 changes: 5 additions & 1 deletion core/startos/src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ mod v0_3_6_alpha_5;
mod v0_3_6_alpha_6;
mod v0_3_6_alpha_7;
mod v0_3_6_alpha_8;
mod v0_3_6_alpha_9;

pub type Current = v0_3_6_alpha_8::Version; // VERSION_BUMP
pub type Current = v0_3_6_alpha_9::Version; // VERSION_BUMP

impl Current {
#[instrument(skip(self, db))]
Expand Down Expand Up @@ -106,6 +107,7 @@ enum Version {
V0_3_6_alpha_6(Wrapper<v0_3_6_alpha_6::Version>),
V0_3_6_alpha_7(Wrapper<v0_3_6_alpha_7::Version>),
V0_3_6_alpha_8(Wrapper<v0_3_6_alpha_8::Version>),
V0_3_6_alpha_9(Wrapper<v0_3_6_alpha_9::Version>),
Other(exver::Version),
}

Expand Down Expand Up @@ -138,6 +140,7 @@ impl Version {
Self::V0_3_6_alpha_6(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_7(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_8(v) => DynVersion(Box::new(v.0)),
Self::V0_3_6_alpha_9(v) => DynVersion(Box::new(v.0)),
Self::Other(v) => {
return Err(Error::new(
eyre!("unknown version {v}"),
Expand All @@ -162,6 +165,7 @@ impl Version {
Version::V0_3_6_alpha_6(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_7(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_8(Wrapper(x)) => x.semver(),
Version::V0_3_6_alpha_9(Wrapper(x)) => x.semver(),
Version::Other(x) => x.clone(),
}
}
Expand Down
83 changes: 83 additions & 0 deletions core/startos/src/version/update_details/v0_3_6.md
Original file line number Diff line number Diff line change
@@ -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.
30 changes: 24 additions & 6 deletions core/startos/src/version/v0_3_6_alpha_6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand All @@ -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<Self::PreUpRes, Error> {
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<Self::PreUpRes, Error> {
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> {
Expand Down
Loading

0 comments on commit a5bac39

Please sign in to comment.