mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
Clean up README (#1114)
* Update README.md * updated readme assets * delete deprecated lifeline * update contributing guide and delete old build guides/notes * fix typos * update ui formatting recommendation * update readmes and contributing guide with build steps and dependencies * add script to install sdk Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
This commit is contained in:
179
BuildGuide.md
179
BuildGuide.md
@@ -1,179 +0,0 @@
|
||||
##### Initial Notes & Recommendations
|
||||
* Due to issues to cross-compile the image from a desktop, this guide will take you step-by-step through the process of compiling EmbassyOS directly on a Raspberry Pi 4 (4GB or 8GB)
|
||||
* This process will go faster if you have an SSD/NVMe USB drive available.
|
||||
* This build guide does **not** require a large microSD card, especially if your final build wil be used on an SSD/NVMe USB drive.
|
||||
* Basic know-how of linux commands and terminal use is recommended.
|
||||
* Follow the guide carefully and do not skip any steps.
|
||||
|
||||
# :hammer_and_wrench: Build Guide
|
||||
1. Flash [Raspberry Pi OS Lite](https://www.raspberrypi.org/software/operating-systems/) to a microSD and configure your raspi to boot from SSD/NVMe USB drive
|
||||
1. After flashing, create an empty text file called `ssh` in the `boot` partition of the microSD, then proceed with booting the raspi with the flashed microSD (check your router for the IP assigned to your raspi)
|
||||
1. Do the usual initial update/config
|
||||
```
|
||||
sudo apt update
|
||||
sudo raspi-config
|
||||
```
|
||||
1. Change `Advanced Options->Boot Order`
|
||||
1. Select `USB Boot` *(it will try to boot from microSD first if it's available)*
|
||||
1. Select `Finish`, then `Yes` to reboot
|
||||
1. After reboot, `sudo shutdown now` to power off the raspi and remove the microSD
|
||||
|
||||
2. Flash the *Raspi OS Lite* (from step 1) to your SSD/NVMe drive
|
||||
> :information_source: Don't worry about rootfs partition size (raspi will increase it for you on initial boot)
|
||||
|
||||
> :information_source: Every time you re-flash your SSD/NVMe you need to first boot with a microSD and set *Boot Order* again
|
||||
|
||||
1. Don't forget to create the empty `ssh` file
|
||||
1. Connect the drive (remember to remove the microSD) to the raspi and start it up
|
||||
1. Use `sudo raspi-config` to change the default password
|
||||
1. Optional: `sudo apt upgrade -y`
|
||||
1. Optional: `sudo nano /etc/apt/sources.list.d/vscode.list` comment the last line which contains `packages.microsoft.com`
|
||||
|
||||
3. Install GHC
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt install -y ghc
|
||||
|
||||
#test:
|
||||
ghc --version
|
||||
|
||||
#example of output:
|
||||
The Glorious Glasgow Haskell Compilation System, version 8.4.4
|
||||
```
|
||||
|
||||
4. Compile Stack:
|
||||
1. Install Stack v2.1.3
|
||||
```
|
||||
cd ~/
|
||||
wget -qO- https://raw.githubusercontent.com/commercialhaskell/stack/v2.1.3/etc/scripts/get-stack.sh | sh
|
||||
|
||||
#test with
|
||||
stack --version
|
||||
|
||||
#example output:
|
||||
Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) arm hpack-0.31.2
|
||||
```
|
||||
|
||||
1. Use current Stack to compile Stack v2.5.1:
|
||||
```
|
||||
git clone --depth 1 --branch v2.5.1 https://github.com/commercialhaskell/stack.git
|
||||
cd stack
|
||||
sudo apt install -y screen
|
||||
screen
|
||||
```
|
||||
> :information_source: Build (>=3.5h total... We are using `screen` in case of session timeout issues)
|
||||
|
||||
> :memo: If you get disconected you can reattach last sesion again by executing `screen -r`
|
||||
```
|
||||
stack build --stack-yaml=stack-ghc-84.yaml --system-ghc
|
||||
|
||||
#Install
|
||||
stack install --stack-yaml=stack-ghc-84.yaml --system-ghc
|
||||
export PATH=~/.local/bin:$PATH
|
||||
```
|
||||
|
||||
5. Clone EmbassyOS & try to *make* the `agent`:
|
||||
1. First attempt
|
||||
> :information_source: The first time you run **make** you'll get an error
|
||||
|
||||
```
|
||||
sudo apt install -y llvm-9 libgmp-dev
|
||||
export PATH=/usr/lib/llvm-9/bin:$PATH
|
||||
cd ~/
|
||||
git clone https://github.com/Start9Labs/embassy-os.git
|
||||
cd embassy-os/
|
||||
make agent
|
||||
```
|
||||
> :memo: This will install ghc-8.10.2, then attempt to build but will give errors (in next steps we deal with errors)
|
||||
1. Confirm your cpu info
|
||||
```
|
||||
cat /proc/cpuinfo | grep Hardware
|
||||
```
|
||||
1. If your "Hardware" is [BCM2711](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md) then:
|
||||
1. Change `C compiler flags` to `-marm -fno-stack-protector -mcpu=cortex-a7` in the GHC settings:
|
||||
```
|
||||
nano ~/.stack/programs/arm-linux/ghc-8.10.4/lib/ghc-8.10.4/settings
|
||||
```
|
||||
1. To prevent gcc errors we delete the `setup-exe-src` folder
|
||||
```
|
||||
rm -rf ~/.stack/setup-exe-src/
|
||||
```
|
||||
1. Re-make the agent
|
||||
```
|
||||
make agent
|
||||
```
|
||||
|
||||
6. Install requirements for step 7
|
||||
1. Install NVM
|
||||
```
|
||||
cd ~/ && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
nvm --version
|
||||
```
|
||||
1. Install Node.js & NPM
|
||||
```
|
||||
nvm install node
|
||||
```
|
||||
1. Install Ionic CLI
|
||||
```
|
||||
npm install -g @ionic/cli
|
||||
```
|
||||
1. Install Dependencies
|
||||
```
|
||||
sudo apt-get install -y build-essential openssl libssl-dev libc6-dev clang libclang-dev libavahi-client-dev upx ca-certificates
|
||||
```
|
||||
1. Install Rust
|
||||
```
|
||||
cd ~/ && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o- | bash
|
||||
|
||||
#Choose option 1
|
||||
source $HOME/.cargo/env
|
||||
|
||||
#Check rust & cargo versions
|
||||
rustc --version
|
||||
cargo --version
|
||||
```
|
||||
|
||||
7. Finally, getting to build the **.img**
|
||||
1. At this stage you hava a working development environment to build your **embassy.img**.
|
||||
Before you do that you can choose to enable SSH login for user `pi` in case something will go wrong or just skip to the next step.
|
||||
```
|
||||
cd ~/embassy-os
|
||||
sed -e '/passwd -l pi/ s/^#*/#/' -i setup.sh
|
||||
```
|
||||
> :warning: Default password for user `pi` is `raspberry`, change it the next you login.
|
||||
1. Build the `embassy.img`
|
||||
```
|
||||
cd ~/embassy-os
|
||||
make
|
||||
|
||||
#Depending on your hardware this can take 1-2h+
|
||||
#Wait for the "DONE!" message and take note of your product_key
|
||||
exit
|
||||
```
|
||||
8. Flash the `embassy.img` to a microSD
|
||||
1. Copy `embassy.img` from the raspi to your PC with scp
|
||||
```
|
||||
scp pi@raspi_IP:~/embassy-os/embassy.img .
|
||||
```
|
||||
1. Connect to raspi again to do `sudo shutdown now`, after a complete shutdown disconnect SSD/NVMe drive
|
||||
1. Flash `embassy.img` to a microSD (do this before flashing to the SSD/NVMe, to be sure it works)
|
||||
|
||||
9. Prepare for initial setup
|
||||
1. Boot raspi using flashed microSD
|
||||
1. After a few minutes, the raspi should reboot itself and make it's first [sounds](#embassy-sounds-explained).
|
||||
> :information_source: If needed, you can check the `agent` log with: `journalctl -u agent -ef`
|
||||
1. Proceed with the [initial setup process of EmbassyOS](https://docs.start9labs.com/user-manual/initial-setup.html)
|
||||
1. If all went well you can safely flash `embassy.img` to an SSD/NVMe and repeat step 9
|
||||
|
||||
### Embassy sounds explained
|
||||
Sound :notes: | Indicating
|
||||
------- | --------
|
||||
Bep | Device is powering on
|
||||
Chime | Device is ready for setup
|
||||
Mario "Coin" | EmbassyOS has started
|
||||
Mario "Death" | Device is about to Shutdown/Reboot
|
||||
Mario "Power Up" | EmbassyOS update sequence
|
||||
Beethoven | Update failed :(
|
||||
@@ -76,7 +76,7 @@ Depending on how large the project is, you may want to outsource the questioning
|
||||
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
||||
|
||||
- Make sure that you are using the latest version.
|
||||
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://docs.start9labs.com). If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
||||
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://docs.start9.com). If you are looking for support, you might want to check [this section](#i-have-a-question)).
|
||||
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/Start9Labs/embassy-os/issues?q=label%3Abug).
|
||||
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
|
||||
- Collect information about the bug:
|
||||
@@ -94,7 +94,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform
|
||||
|
||||
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
|
||||
|
||||
- Open an [Issue](https://github.com/Start9Labs/embassy-os/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
|
||||
- Open an [Issue](https://github.com/Start9Labs/embassy-os/issues/new/choose) selecting the appropriate type.
|
||||
- Explain the behavior you would expect and the actual behavior.
|
||||
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
|
||||
- Provide the information you collected in the previous section.
|
||||
@@ -102,8 +102,8 @@ We use GitHub issues to track bugs and errors. If you run into an issue with the
|
||||
Once it's filed:
|
||||
|
||||
- The project team will label the issue accordingly.
|
||||
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
|
||||
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
|
||||
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `Question`. Bugs with the `Question` tag will not be addressed until they are answered.
|
||||
- If the team is able to reproduce the issue, it will be marked a scoping level tag, as well as possibly other tags (such as `Security`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
|
||||
|
||||
<!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
|
||||
|
||||
@@ -116,7 +116,7 @@ This section guides you through submitting an enhancement suggestion for Embassy
|
||||
#### Before Submitting an Enhancement
|
||||
|
||||
- Make sure that you are using the latest version.
|
||||
- Read the [documentation](https://docs.start9labs.com) carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
||||
- Read the [documentation](https://docs.start9.com) carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
||||
- Perform a [search](https://github.com/Start9Labs/embassy-os/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
||||
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
||||
|
||||
@@ -134,67 +134,38 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/Start9
|
||||
<!-- You might want to create an issue template for enhancement suggestions that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->
|
||||
|
||||
### Project Structure
|
||||
Embassy OS has 3 main components: `agent`, `appmgr`, and `ui`.
|
||||
- The `ui` (Typescript Ionic Angular) is the code that is deployed to the browser to provide the user interface for Embassy OS
|
||||
- The `agent` (Haskell) is a daemon that provides the interface for the `ui` to interact with the Embassy, as well as manage system state.
|
||||
- `appmgr` (Rust) is a command line utility and (soon to be) daemon that sets up and manages services and their environments.
|
||||
|
||||
EmbassyOS is composed of the following components. Please visit the README for each component to understand the dependency requirements and installation instructions.
|
||||
- [`ui`](ui/README.md) (Typescript Ionic Angular) is the code that is deployed to the browser to provide the user interface for EmbassyOS.
|
||||
- [`backend`] (backend/README.md) (Rust) is a command line utility, daemon, and software development kit that sets up and manages services and their environments, provides the interface for the ui, manages system state, and provides utilities for packaging services for EmbassyOS.
|
||||
- `patch-db` - A diff based data store that is used to synchronize data between the front and backend
|
||||
- Notably, `patch-db` has a [client](patch-db/client/README.md) with its own dependency and installation requirements.
|
||||
- `rpc-toolkit` - A library for generating an rpc server with cli bindings from Rust functions
|
||||
- `system-images` - (Docker, Rust) A suite of utility Docker images that are preloaded with EmbassyOS to assist with functions relating to services (eg. configuration, backups, health checks)
|
||||
- [`setup-wizard`] (ui/README.md)- Code for the user interface that is displayed during the setup and recovery process for EmbassyOS.
|
||||
- [`diagnostic-ui`] (diagnostic-ui/README.md) - Code for the user interface that is displayed when something has gone wrong with starting up EmbassyOS, which provides helpful debugging tools.
|
||||
### Your First Code Contribution
|
||||
|
||||
#### Setting up your development environment
|
||||
##### agent
|
||||
There are two main workflows to consider when developing on the agent. During the development process you will spend
|
||||
most of your time developing in an environment where you cannot actually run the agent. This is because we make heavy
|
||||
platform specific assumptions (by nature of the project) around what folders get used and what package management tools
|
||||
are used for the underlying system. If you are running this on a platform besides Linux you won't even be able to run
|
||||
the agent effectively on your dev machine. Even if you are on Linux you may not want to turn administrative control over
|
||||
to the software you are currently developing. So how do you know that anything you are doing is right? We make extensive
|
||||
use of Haskell's type system and surrounding tooling. For this you will want to make sure you are using the [haskell-language-server](https://github.com/haskell/haskell-language-server)
|
||||
and [stack](https://github.com/commercialhaskell/stack)
|
||||
|
||||
At some point though you will want to build the agent for the target platform (Raspberry Pi 4). This is the second build
|
||||
flow that you will need to consider.
|
||||
First, clone the EmbassyOS repository and from the project root, pull in the submodules for dependent libraries.
|
||||
|
||||
At Start9 we build the agent in two different ways. The primary way we have done it is on the Raspberry Pi itself. To do
|
||||
this you will need stack built for the Raspberry Pi. Unfortunately, however, FPComplete no longer
|
||||
distributes ARMv7 binaries for stack. Though hopefully soon we will be able to submit the binaries we've built for this
|
||||
project back to them and have them hosted more visibly. The way we bootstrap through this problem is by downloading version
|
||||
[2.1.3](https://github.com/commercialhaskell/stack/releases/download/v2.1.3/stack-2.1.3-linux-arm.tar.gz) and using that
|
||||
to compile v2.5.1. Before you can successfully compile anything with GHC on the Raspberry Pi. You will need to tweak the
|
||||
relevant GHC config. You will need to edit the file at `~/.stack/programs/arm-linux/ghc-8.10.2/lib/ghc-8.10.2/settings`
|
||||
and change the line `("C compiler flags", " -marm -fno-stack-protector -mcpu=cortex-a7")` to include `-mcpu=cortex-a7`.
|
||||
You will also need to make sure you've downloaded and installed LLVM 9.
|
||||
```
|
||||
git clone https://github.com/Start9Labs/embassy-os.git
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
Once you have done these things, you simply need to `cd` into the embassy-os project and then run `make agent`.
|
||||
|
||||
##### ui
|
||||
- Requirements
|
||||
- [Install nodejs](https://nodejs.org/en/)
|
||||
- [Install npm](https://www.npmjs.com/get-npm)
|
||||
- [Install ionic cli](https://ionicframework.com/docs/intro/cli)
|
||||
- Scripts (run within ./ui directory)
|
||||
- `npm i` installs ui node package dependencies
|
||||
- `npm run build` compiles project, depositing build artifacts into ./ui/www
|
||||
- `npm run build-prod` as above but customized for deployment to an Embassy
|
||||
- `ionic serve` serves the ui on localhost:8100 for local development. Edit ./ui/use-mocks.json to 'true' to use mocks during local development
|
||||
- `./build-send.sh <embassy .local address suffix>` builds the project and deploys it to the referenced Embassy
|
||||
- Find your Embassy on the LAN using the Start9 Setup App or network tools. It's address will be of the form `start9-<suffix>.local`.
|
||||
- For example `./build-send.sh abcdefgh` will deploy the ui to the Embassy with LAN address `start9-abcdefgh.local`.
|
||||
- SSH keys must be installed on the Embassy prior to running this script.
|
||||
|
||||
##### appmgr
|
||||
- [Install Rust](https://rustup.rs)
|
||||
- Recommended: [rust-analyzer](https://rust-analyzer.github.io/)
|
||||
Depending on which component of the ecosystem you are interested in contributing to, follow the installation requirements listed in that component's README (linked [above](#project-structure))
|
||||
|
||||
#### Building The Image
|
||||
This step is for setting up an environment in which to test your code changes if you do not yet have a EmbassyOS.
|
||||
|
||||
- Requirements
|
||||
- `ext4fs` (available if running on the Linux kernel)
|
||||
- [Docker](https://docs.docker.com/get-docker/)
|
||||
- GNU Make
|
||||
- Building
|
||||
- build the [agent](#agent)
|
||||
- make sure resulting artifact is agent/dist/agent
|
||||
- run `make`
|
||||
- see setup instructions [here](build/README.md)
|
||||
- run `make` from the project root
|
||||
|
||||
### Improving The Documentation
|
||||
You can find the repository for Start9's documentation [here](https://github.com/Start9Labs/documentation). If there is something you would like to see added, let us know, or create an issue yourself. Welcome are contributions for lacking or incorrect information, broken links, requested additions, or general style improvements.
|
||||
@@ -203,17 +174,14 @@ Contributions in the form of setup guides for integrations with external applica
|
||||
|
||||
## Styleguides
|
||||
### Formatting
|
||||
Code must be formatted with the formatter designated for each component:
|
||||
- `ui`: [tslint](https://palantir.github.io/tslint/)
|
||||
- `agent`: [brittany](https://github.com/lspitzner/brittany)
|
||||
- `appmgr`: [rustfmt](https://github.com/rust-lang/rustfmt)
|
||||
Each component of EmbassyOS contains its own style guide. Code must be formatted with the formatter designated for each component. These are outlined within each component folder's README.
|
||||
|
||||
### Atomic Commits
|
||||
Commits [should be atomic](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) and diffs should be easy to read.
|
||||
Do not mix any formatting fixes or code moves with actual code changes.
|
||||
|
||||
### Commit Messages
|
||||
If a commit touches only 1 component, prefix the message with the affected component. i.e. `appmgr: update to tokio v0.3`.
|
||||
If a commit touches only 1 component, prefix the message with the affected component. i.e. `backend: update to tokio v0.3`.
|
||||
|
||||
### Pull Requests
|
||||
The body of a pull request should contain sufficient description of what the changes do, as well as a justification.
|
||||
|
||||
24
README.md
24
README.md
@@ -9,24 +9,21 @@
|
||||
[](http://mastodon.start9labs.com)
|
||||
[](https://twitter.com/start9labs)
|
||||
|
||||
### _A personal server for everyone._ ###
|
||||
### _Welcome to the era of Sovereign Computing_ ###
|
||||
|
||||
EmbassyOS is an open-source operating system designed to empower anyone at any technical skill level to self-host.
|
||||
EmbassyOS is a browser-based, graphical operating system for a personal server. EmbassyOS facilitates the discovery, installation, network configuration, service configuration, data backup, dependency management, and health monitoring of self-hosted software services. It is the most advanced, secure, reliable, and user friendly personal server OS in the world.
|
||||
|
||||
## Running EmbassyOS
|
||||
There are multiple ways to obtain and begin using EmbassyOS.
|
||||
|
||||
## :heart: Contributing
|
||||
To contribute to the development of EmbassyOS, see [here](https://github.com/Start9Labs/embassy-os/blob/master/CONTRIBUTING.md).
|
||||
There are multiple ways to get your hands on EmbassyOS.
|
||||
|
||||
### :moneybag: Buy an Embassy
|
||||
This is the most convenient option. Simply [buy an Embassy](https://start9.com) from Start9 Labs and plug it in. Depending on where you live, shipping costs and import duties may vary.
|
||||
This is the most convenient option. Simply [buy an Embassy](https://start9.com) from Start9 and plug it in. Depending on where you live, shipping costs and import duties will vary.
|
||||
|
||||
### :construction_worker: Build your own Embassy
|
||||
While not as convenient as buying an Embassy, this option is easier than you might imagine, and there are 4 reasons why you might prefer it:
|
||||
1. You already have a Raspberry Pi and would like to re-purpose it.
|
||||
1. You want to save on shipping costs.
|
||||
1. You prefer not to divulge your physical shipping address.
|
||||
1. You prefer not to divulge your physical address.
|
||||
1. You just like building things.
|
||||
|
||||
To pursue this option, follow this [guide](https://docs.start9.com/getting-started/diy.html).
|
||||
@@ -36,5 +33,14 @@ To pursue this option, follow this [guide](https://docs.start9.com/getting-start
|
||||
EmbassyOS can be built from source, for personal use, for free.
|
||||
A detailed guide for doing so can be found [here](https://github.com/Start9Labs/embassy-os/blob/master/build/README.md).
|
||||
|
||||
## :heart: Contributing
|
||||
There are multiple ways to contribute: work directly on EmbassyOS, package a service for the marketplace, or help with documentation and guides. To learn more about contributing, see [here](https://github.com/Start9Labs/embassy-os/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## UI Screenshots
|
||||
<img src="assets/EmbassyOS.png" alt="Embassy Services" width="100%">
|
||||
<img src="assets/EmbassyOS.png" alt="EmbassyOS" width="60%">
|
||||
<br>
|
||||
<img src="assets/eos-services.png" alt="Embassy Services" width="60%"> |
|
||||
<img src="assets/eos-preferences.png" alt="Embassy Preferences" width="60%">
|
||||
--- | ---
|
||||
<img src="assets/eos-bitcoind-health-check.png" alt="Embassy Bitcoin Health Checks" width="60%"> |
|
||||
<img src="assets/eos-logs.png" alt="Embassy Logs" width="60%">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 285 KiB |
BIN
assets/eos-bitcoind-health-check.png
Normal file
BIN
assets/eos-bitcoind-health-check.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 334 KiB |
BIN
assets/eos-logs.png
Normal file
BIN
assets/eos-logs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/eos-preferences.png
Normal file
BIN
assets/eos-preferences.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 347 KiB |
BIN
assets/eos-services.png
Normal file
BIN
assets/eos-services.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 599 KiB |
@@ -1,2 +1,11 @@
|
||||
# backend
|
||||
(TODO)
|
||||
- Requirements:
|
||||
- [Install Rust](https://rustup.rs)
|
||||
- Recommended: [rust-analyzer](https://rust-analyzer.github.io/)
|
||||
- [Docker](https://docs.docker.com/get-docker/)
|
||||
- [Rust ARM64 Build Container](https://github.com/Start9Labs/rust-arm-builder)
|
||||
- Installation:
|
||||
- follow the setup instructions [here](backend/README.md)
|
||||
- Scripts (run withing the `./backend` directory)
|
||||
- `build-prod.sh` - compiles a release build of the artifacts for running on ARM64
|
||||
- `build-dev.sh` - compiles a development build of the artifacts for running on ARM64
|
||||
|
||||
11
backend/install-sdk.sh
Executable file
11
backend/install-sdk.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
shopt -s expand_aliases
|
||||
|
||||
if [ "$0" != "./build-sdk.sh" ]; then
|
||||
>&2 echo "Must be run from backend directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cargo install --bin=embassy-sdk --path=. --no-default-features --verbose
|
||||
214
build/NOTES.md
214
build/NOTES.md
@@ -1,214 +0,0 @@
|
||||
# Creating an 0.3.0 Image
|
||||
|
||||
- Download [ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz](https://ubuntu.com/download/raspberry-pi/thank-you?version=21.04&architecture=server-arm64+raspi)
|
||||
|
||||
- `unxz ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz` to unzip
|
||||
|
||||
- `export LOOPDEV=$(sudo losetup --show -fP ubuntu-21.04-preinstalled-server-arm64+raspi.img)` to set the `.img` file as a loop device environment variable
|
||||
|
||||
- Got error: `losetup: cannot find an unused loop device`
|
||||
- ran `modprobe loop` which gave: `modprobe: FATAL: Module loop not found in directory /lib/modules/5.13.13-arch1-1`
|
||||
- Fixed with reboot (an update had occurred without recent reboot)
|
||||
|
||||
- Plug in your 16GB microSD card. We are assuming it will be at /dev/mmcblk0
|
||||
|
||||
- Find current devices with `lsblk`
|
||||
|
||||
(To use `partitioning.sh` - `export OUTPUT_DEVICE=mmcblk0` where mmcblk0 is our example, but be sure to use the correct disc name if yours differs)
|
||||
|
||||
- `sudo fdisk /dev/mmcblk0`
|
||||
|
||||
- Use entire disk, not a partition (e.g. `mmcblk0`, not `mmcblk0p1`)
|
||||
|
||||
- Run the following (options to ‘press Enter’ are assuming a 16GB card):
|
||||
|
||||
-`o`, to create a new empty DOS partition table
|
||||
-`n`, to add a new partition
|
||||
-`p` (or press Enter), to make it a primary partition
|
||||
-`1` (or press Enter), to make it the first partition
|
||||
-`2048` (or press Enter), to set the first sector
|
||||
-`526335`, to set the last sector
|
||||
-`t`, to change the partition type
|
||||
-`c`, to select `W95 FAT32 (LBA)`
|
||||
-`n`, to add a new partition
|
||||
-`p` (or press Enter), to make it a primary partition
|
||||
-`2` (or press Enter), to make it the second partition
|
||||
-`526336` (or press Enter), to set the first sector
|
||||
-`1050623`, to set the last sector
|
||||
-`t`, to change the partition type
|
||||
-`2`, to select the partition
|
||||
-`c`, to select `W95 FAT32 (LBA)`
|
||||
-`n`, to add a new partition
|
||||
-`p` (or press Enter), to make it a primary partition
|
||||
-`3` (or press Enter), to make it the third partition
|
||||
-`1050624` (or press Enter), to set the first sector
|
||||
-`16083455`, to set the last sector
|
||||
-`n`, to add a new partition
|
||||
-`p`, to make it a primary partition
|
||||
-`16083456`, to set the first sector
|
||||
- `31116287` (or press Enter), to set the last sector
|
||||
-`a`, to toggle the bootable flag
|
||||
-`1`, to select the first partition
|
||||
-`w`, to save and write the changes to the card
|
||||
|
||||
- Got errors `Failed to add partition 1 (and 2,3,4) to system: Device or resource busy
|
||||
- Had to `sudo umount /dev/mmcblk0p1` then
|
||||
- `sudo fdisk /dev/mmcblk0` then `w` to write
|
||||
- Fucking Arch
|
||||
|
||||
*******************************************
|
||||
|
||||
(Can use `filesystems.sh` here)
|
||||
|
||||
- `sudo dd if=${LOOPDEV}p1 of=/dev/mmcblk0p1` to write partition 1 of the Ubuntu image to the partition 1 of the sd card
|
||||
|
||||
- You may add ` status=progress` if you’d like progress feedback
|
||||
|
||||
- `sudo mkfs.vfat /dev/mmcblk0p2` to make the FAT filesystem on the partition 2
|
||||
|
||||
- `sudo dd if=${LOOPDEV}p2 of=/dev/mmcblk0p3` to write partition 2 of the Ubuntu image to partition 3 of the sd card
|
||||
|
||||
- `sudo mkfs.ext4 /dev/mmcblk0p4` to make the linux filesystem on partition 4
|
||||
|
||||
- `sudo losetup -d $LOOPDEV` to detach the loop device
|
||||
|
||||
- Now, we will label the filesystems:
|
||||
|
||||
- `sudo fatlabel /dev/mmcblk0p1 system-boot` Ignore warning
|
||||
|
||||
- `sudo fatlabel /dev/mmcblk0p2 EMBASSY`
|
||||
|
||||
- `sudo e2label /dev/mmcblk0p3 writable`
|
||||
|
||||
- `sudo e2label /dev/mmcblk0p4 reserved`
|
||||
|
||||
- `sudo mount /dev/mmcblk0p1 /mnt` to mount the boot partition
|
||||
|
||||
- `cat "/mnt/config.txt" | grep -v "dtoverlay=" | sudo tee "/mnt/config.txt.tmp"` This copies everything from the `config.txt` file except the dtoverlay option into the `config.txt.tmp` file
|
||||
|
||||
- `echo "dtoverlay=pwm-2chan" | sudo tee -a "/mnt/config.txt.tmp"` This writes a dtoverlay option into the `config.txt.tmp` file
|
||||
|
||||
- `sudo mv "/mnt/config.txt.tmp" "/mnt/config.txt"` Overwrites the `config.txt` file with the new input
|
||||
|
||||
- `sudo umount /mnt` to unmount the filesystem
|
||||
|
||||
- `sudo mount /dev/mmcblk0p2 /mnt` Mount the EMBASSY filesystem
|
||||
|
||||
***
|
||||
|
||||
- Store a product key as an environment variable in $PRODUCT_KEY, with `export PRODUCT_KEY=123456`, obviously, this number is made up, and then:
|
||||
|
||||
- `echo $PRODUCT_KEY | sudo tee /mnt/product_key.txt` to add it to the `product_key.txt` file.
|
||||
|
||||
- `sudo umount /mnt` to unmount again
|
||||
|
||||
- `sudo mount /dev/mmcblk0p3 /mnt` to mount the writable filesystem
|
||||
|
||||
- Build embassy-os (LINK OR UPDATE, this step ridic – PULL LATEST CODE!!!) (for now, `docker run --rm --privileged linuxkit/binfmt:v0.8`, get rust-arm-cross.img and `docker load < rust-arm-cross.img`, have latest dev branch for patch, yajrc, and master for rpc-toolkit, then from backend dir: `./build-prod.sh`), then, also from the backend dir:
|
||||
|
||||
(Can use `copy.sh` here)
|
||||
|
||||
- `sudo cp target/aarch64-unknown-linux-gnu/release/embassy-init /mnt/usr/local/bin` to copy `embassy-init` over to the new filesystem
|
||||
|
||||
- `sudo cp target/aarch64-unknown-linux-gnu/release/embassyd /mnt/usr/local/bin` to copy `embassyd` over to the new filesystem
|
||||
|
||||
- `sudo cp target/aarch64-unknown-linux-gnu/release/embassy-cli /mnt/usr/local/bin` to copy `embassy-cli` over to the new filesystem
|
||||
|
||||
- `sudo cp *.service /mnt/etc/systemd/system/` to copy over the systemd service files
|
||||
|
||||
- `echo "application/wasm wasm;" | sudo tee -a "/mnt/etc/nginx/mime.types"`
|
||||
|
||||
- `sudo mkdir -p /mnt/root/.ssh` create the `ssh` folder on the new filesystem
|
||||
|
||||
*******************************************
|
||||
|
||||
- `cat ~/.ssh/id_ed25519.pub | sudo tee -a /mnt/root/.ssh/authorized_keys` copy your ssh key over (assuming it is ~/.ssh/id_ed25519.pub)
|
||||
|
||||
- `sudo umount /mnt` unmount once again
|
||||
|
||||
Time to remove your SD card and insert it into your hardware!! See our DIY guide here (LINK REQUIRED) if you have not yet built your Embassy.
|
||||
|
||||
- SSH in (find by hacking) `ssh root@whateverIP` and run:
|
||||
|
||||
(Can use `/setup/initialization.sh` here)
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
apt update
|
||||
apt install -y \
|
||||
docker.io \
|
||||
tor \
|
||||
nginx \
|
||||
libavahi-client3 \
|
||||
avahi-daemon \
|
||||
iotop \
|
||||
bmon \
|
||||
zfsutils-linux \
|
||||
exfat-utils \
|
||||
sqlite3
|
||||
sed -i 's/"1"/"0"/g' /etc/apt/apt.conf.d/20auto-upgrades
|
||||
sed -i 's/Restart=on-failure/Restart=always/g' /lib/systemd/system/tor@default.service
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
docker network create -d bridge --subnet 172.18.0.1/16 start9
|
||||
echo '{ "storage-driver": "zfs" }' > /etc/docker/daemon.json
|
||||
mkdir /etc/embassy
|
||||
hostnamectl set-hostname "embassy"
|
||||
systemctl enable embassyd.service embassy-init.service
|
||||
echo 'overlayroot="tmpfs"' > /etc/overlayroot.local.conf
|
||||
cat << EOF > /etc/tor/torrc
|
||||
SocksPort 0.0.0.0:9050
|
||||
SocksPolicy accept 127.0.0.1
|
||||
SocksPolicy accept 172.18.0.0/16
|
||||
SocksPolicy reject *
|
||||
ControlPort 9051
|
||||
CookieAuthentication 1
|
||||
EOF
|
||||
```
|
||||
|
||||
*******************************************
|
||||
|
||||
- Do a `reboot`
|
||||
|
||||
- Have Aiden fix code for a while
|
||||
|
||||
Do the setup!!
|
||||
|
||||
-
|
||||
|
||||
- Then initialize ZFS (don’t actually though):
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
zpool create embassy-data /dev/sda
|
||||
zpool get -H -ovalue guid embassy-data > /embassy-os/disk.guid
|
||||
echo password > /etc/embassy/password
|
||||
zfs create -o reservation=5G -o encryption=on -o keylocation=file:///etc/embassy/password -o keyformat=passphrase embassy-data/main
|
||||
zfs create -o reservation=5G embassy-data/updates
|
||||
zfs create -o encryption=on -o keylocation=file:///etc/embassy/password -o keyformat=passphrase embassy-data/package-data
|
||||
zfs create -o encryption=on -o keylocation=file:///etc/embassy/password -o keyformat=passphrase embassy-data/tmp
|
||||
rm /etc/embassy/password
|
||||
zpool export embassy-data
|
||||
```
|
||||
|
||||
- Enable services
|
||||
- `systemctl enable embassyd.service embassy-init.service`
|
||||
- Reboot
|
||||
- `reboot`
|
||||
- Once you have rebooted in overlay mode, DO NOT INSTALL ANYTHING
|
||||
- Then seed the db with an account:
|
||||
- `sqlite3 /embassy-data/secrets.db`
|
||||
- `insert into account (id, password, tor_key) VALUES (0, '[your_password_hash]', x'[your_tor_key]');`
|
||||
- You should hear a chime
|
||||
- Now go to your onion address and enjoy
|
||||
|
||||
|
||||
Automation:
|
||||
|
||||
1. partitioning.sh - done
|
||||
2. filesystems.sh - done
|
||||
3. copy.sh - done
|
||||
4. initialization.sh - done
|
||||
5. zfs.sh??
|
||||
6. Final steps?
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Install dependences
|
||||
1. Install dependencies
|
||||
|
||||
- Avahi
|
||||
- `sudo apt install -y avahi-daemon`
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# Creating an 0.3.0 Image (Scripted version)
|
||||
### This guide assumes a linux environment
|
||||
### `Text in this format are commands to run`
|
||||
|
||||
1. a) Download [ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz](https://ubuntu.com/download/raspberry-pi/thank-you?version=21.04&architecture=server-arm64+raspi)
|
||||
|
||||
1. b) `unxz ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz` to unzip
|
||||
|
||||
2. a) Run `git clone https://github.com/Start9Labs/embassy-os` to download the embassy-os repository
|
||||
|
||||
2. b) Plug in your 16GB microSD card. In this example, we are assuming it will be at /dev/mmcblk0
|
||||
|
||||
- Find the location of your device with `lsblk` or `fdisk -l`
|
||||
|
||||
3. a) Run `export OUTPUT_DEVICE=/dev/mmcblk0` where `/dev/mmcblk0` is the sd card’s device name, be sure to change if yours differs
|
||||
|
||||
3. b) Run `export LOOPDEV=$(sudo losetup --show -fP ubuntu-21.04-preinstalled-server-arm64+raspi.img)` to set the `.img` file as a loop device environment variable
|
||||
|
||||
4. Run `./build/partitioning.sh` You should see confirmation of write to disk
|
||||
|
||||
5. Run `./build/filesystems.sh` You will see write progression twice, ignore the warning about lowercase labels
|
||||
|
||||
6. a) Store a product key as an environment variable in $PRODUCT_KEY, with `export PRODUCT_KEY=test1234`, obviously, this number is made up, but must be 8 alphanumeric characters, then:
|
||||
|
||||
6. b) `echo $PRODUCT_KEY | sudo tee /mnt/product_key.txt` to add it to the `product_key.txt` file.
|
||||
|
||||
6. c) `sudo umount /mnt` to unmount again
|
||||
|
||||
6. d) `sudo mount /dev/mmcblk0p3 /mnt` to mount the writable filesystem
|
||||
|
||||
7. a) Build EmbassyOS: Move into the EmbassyOS directory with `cd embassy-os` and Build embassy-os (NEEDS UPDATE – PULL LATEST CODE!!!) (for now, `docker run --rm --privileged linuxkit/binfmt:v0.8`, get rust-arm-cross.img and `docker load < rust-arm-cross.img`, then from backend dir: `./build-prod.sh`)
|
||||
|
||||
7. b) Build UI: First, make sure you have `git`, `node`, and `npm` installed. Then, `cd ui` to enter ui dir, and run `npm i -g @ionic/cli` to install Ionic, `npm i` to install, then `cd ..` to return to the `embassy-os` directory
|
||||
|
||||
8. a) Run `sudo ./build/copy.sh`
|
||||
|
||||
8. b) `cat ~/.ssh/id_ed25519.pub | sudo tee -a /mnt/root/.ssh/authorized_keys` copy your ssh key over (assuming it is ~/.ssh/id_ed25519.pub)
|
||||
|
||||
8. c) `sudo umount /mnt` unmount once again
|
||||
|
||||
## Time to remove your SD card and insert it into your hardware!! See our [DIY guide](https://docs.start9.com/getting-started/diy.html) if you have not yet put built your device.
|
||||
|
||||
9. a) Get IP (find by hacking) and visit x.x.x.x:80
|
||||
9. b) `ssh root@whateverIP` and run `sudo ./build/initialization.sh` which you currently have to scp over from the `embassy-os` dir
|
||||
|
||||
10. Do the setup
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
## Development Environment Setup
|
||||
|
||||
**Make sure you have git, nvm (node, npm), and rust installed**
|
||||
- Requirements
|
||||
- [Install nodejs](https://nodejs.org/en/)
|
||||
- [Install npm](https://www.npmjs.com/get-npm)
|
||||
- [Install ionic cli](https://ionicframework.com/docs/intro/cli)
|
||||
- Recommended: [Install nvm](https://github.com/nvm-sh/nvm)
|
||||
|
||||
```
|
||||
node --version
|
||||
@@ -11,23 +15,38 @@ v16.11.0
|
||||
npm --version
|
||||
v8.0.0
|
||||
```
|
||||
## Styleguide
|
||||
|
||||
### Building Embassy UI
|
||||
This project utilizes [tslint](https://palantir.github.io/tslint/) for formatting.
|
||||
|
||||
## Building Diagnostic UI
|
||||
|
||||
`git clone https://github.com/Start9Labs/embassy-os.git`
|
||||
|
||||
`cd embassy-os`
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
`git submodule update --init --recursive` - installs submodule projects
|
||||
|
||||
`cd diagnostic-ui/`
|
||||
`cd diagnostic-ui/` - installs node package dependencies
|
||||
|
||||
`npm install -g @ionic/cli`
|
||||
|
||||
`npm --prefix . install`
|
||||
|
||||
Copy `config-sample.json` and contents to new file `config.json`
|
||||
Copy `config-sample.json` and contents to a new file `config.json`
|
||||
|
||||
**Start the development server**
|
||||
### Start the development server
|
||||
|
||||
`ionic serve`
|
||||
Serves the diagnostic-ui on `localhost:8100` for local development.
|
||||
Edit `./diagnostic-ui/config.json` and set `useMocks: true` to use mocks during local development
|
||||
|
||||
```
|
||||
ionic serve
|
||||
```
|
||||
|
||||
### Production Build
|
||||
Before publishing a PR, please build for production and correct any errors. Run the following command, which compiles project customized for deployment to an Embassy, depositing build artifacts into `diagnostic-ui/www`.
|
||||
|
||||
```
|
||||
npm --prefix ui run build-prod
|
||||
```
|
||||
2
lifeline/.gitignore
vendored
2
lifeline/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
6
lifeline/Cargo.lock
generated
6
lifeline/Cargo.lock
generated
@@ -1,6 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "lifeline"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[package]
|
||||
name = "lifeline"
|
||||
version = "0.1.0"
|
||||
authors = ["Keagan McClelland <keagan.mcclelland@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=Boot process for system reset.
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/lifeline
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1 +0,0 @@
|
||||
max_width = 120
|
||||
@@ -1,14 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
mod sound;
|
||||
|
||||
use sound::{notes::*, Song};
|
||||
|
||||
const SUCCESS_SONG: Song = Song(&[(Some(A_4), Duration::from_millis(100))]);
|
||||
|
||||
fn main() {
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/export", "0").unwrap();
|
||||
let res = SUCCESS_SONG.play();
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/unexport", "0").unwrap();
|
||||
res.unwrap();
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::io::Error;
|
||||
use std::time::Duration;
|
||||
|
||||
pub mod notes {
|
||||
pub const A_4: f64 = 440.0;
|
||||
pub const B_4: f64 = 493.88;
|
||||
pub const C_5: f64 = 523.25;
|
||||
pub const D_5: f64 = 587.33;
|
||||
pub const E_5: f64 = 659.25;
|
||||
pub const F_5: f64 = 698.46;
|
||||
pub const G_5: f64 = 783.99;
|
||||
pub const A_5: f64 = 880.00;
|
||||
pub const B_5: f64 = 987.77;
|
||||
pub const E_6: f64 = 1318.51;
|
||||
}
|
||||
|
||||
pub fn freq_to_period(freq: f64) -> Duration {
|
||||
Duration::from_secs(1).div_f64(freq)
|
||||
}
|
||||
|
||||
pub fn play(freq: f64) -> Result<(), Error> {
|
||||
// set freq
|
||||
let period = freq_to_period(freq);
|
||||
let period_bytes = std::fs::read("/sys/class/pwm/pwmchip0/pwm0/period")?;
|
||||
if period_bytes == b"0\n" {
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/pwm0/period", format!("{}", 1000))?;
|
||||
}
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/pwm0/duty_cycle", "0")?;
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/pwm0/period", format!("{}", period.as_nanos()))?;
|
||||
std::fs::write(
|
||||
"/sys/class/pwm/pwmchip0/pwm0/duty_cycle",
|
||||
format!("{}", (period / 2).as_nanos()),
|
||||
)?;
|
||||
// enable the thing
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/pwm0/enable", "1")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn stop() -> Result<(), Error> {
|
||||
// disable the thing
|
||||
std::fs::write("/sys/class/pwm/pwmchip0/pwm0/enable", "0")?;
|
||||
// sleep small amount
|
||||
std::thread::sleep(Duration::from_micros(30));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn play_for_duration(freq: f64, duration: Duration) -> Result<(), Error> {
|
||||
play(freq)?;
|
||||
std::thread::sleep(duration);
|
||||
stop()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Song<'a>(pub &'a [(Option<f64>, Duration)]);
|
||||
impl<'a> Song<'a> {
|
||||
pub fn play(&self) -> Result<(), Error> {
|
||||
for (note, duration) in self.0 {
|
||||
if let Some(note) = note {
|
||||
play_for_duration(*note, *duration)?;
|
||||
} else {
|
||||
std::thread::sleep(*duration);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Song<'static> {
|
||||
pub fn play_while<T, F: FnOnce() -> T>(&'static self, f: F) -> T {
|
||||
let run = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(true));
|
||||
let t_run = run.clone();
|
||||
let handle = std::thread::spawn(move || -> Result<(), Error> {
|
||||
while t_run.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
self.play()?;
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
let res = f();
|
||||
run.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
let e = handle.join().unwrap().err();
|
||||
if let Some(e) = e {
|
||||
eprintln!("ERROR PLAYING SOUND: {}\n{:?}", e, e);
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
impl<'a> From<&'a [(Option<f64>, Duration)]> for Song<'a> {
|
||||
fn from(t: &'a [(Option<f64>, Duration)]) -> Self {
|
||||
Song(t)
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
## Development Environment Setup
|
||||
|
||||
**Make sure you have git, nvm (node, npm), and rust installed**
|
||||
- Requirements:
|
||||
- [Install nodejs](https://nodejs.org/en/)
|
||||
- [Install npm](https://www.npmjs.com/get-npm)
|
||||
- [Install ionic cli](https://ionicframework.com/docs/intro/cli)
|
||||
- Recommended: [Install nvm](https://github.com/nvm-sh/nvm)
|
||||
|
||||
```
|
||||
node --version
|
||||
@@ -11,8 +15,11 @@ v16.11.0
|
||||
npm --version
|
||||
v8.0.0
|
||||
```
|
||||
## Styleguide
|
||||
|
||||
### Building Embassy UI
|
||||
This project utilizes [tslint](https://palantir.github.io/tslint/) for formatting.
|
||||
|
||||
## Building Setup Wizard
|
||||
|
||||
`git clone https://github.com/Start9Labs/embassy-os.git`
|
||||
|
||||
@@ -24,8 +31,21 @@ v8.0.0
|
||||
|
||||
`npm --prefix . install`
|
||||
|
||||
Copy `config-sample.json` and contents to new file `config.json`
|
||||
Copy `config-sample.json` and contents to a new file called `config.json`
|
||||
|
||||
**Start the development server**
|
||||
### Start the development server
|
||||
|
||||
`ionic serve`
|
||||
Serves the ui on localhost:8100 for local development.
|
||||
Edit `./setup-wizard/config.json` and set `useMocks: true` to use mocks during local development
|
||||
|
||||
```
|
||||
ionic serve
|
||||
```
|
||||
|
||||
### Production Build
|
||||
|
||||
Before publishing a PR, please build for production and correct any errors. Run the following command, which compiles project customized for deployment to an Embassy, depositing build artifacts into `setup-wizard/www`.
|
||||
|
||||
```
|
||||
npm --prefix ui run build-prod
|
||||
```
|
||||
38
ui/README.md
38
ui/README.md
@@ -2,7 +2,11 @@
|
||||
|
||||
## Development Environment Setup
|
||||
|
||||
**Make sure you have git, nvm (node, npm), and rust installed**
|
||||
- Requirements:
|
||||
- [Install nodejs](https://nodejs.org/en/)
|
||||
- [Install npm](https://www.npmjs.com/get-npm)
|
||||
- [Install ionic cli](https://ionicframework.com/docs/intro/cli)
|
||||
- Recommended: [Install nvm](https://github.com/nvm-sh/nvm)
|
||||
|
||||
```
|
||||
node --version
|
||||
@@ -12,23 +16,27 @@ npm --version
|
||||
v8.0.0
|
||||
```
|
||||
|
||||
### Building Embassy UI
|
||||
## Styleguide
|
||||
|
||||
This project utilizes [prettier](https://prettier.io/) for formatting.
|
||||
|
||||
## Building Embassy UI
|
||||
|
||||
`git clone https://github.com/Start9Labs/embassy-os.git`
|
||||
|
||||
`cd embassy-os`
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
`git submodule update --init --recursive` - installs submodule projects
|
||||
|
||||
`cd ui/`
|
||||
|
||||
`npm install -g @ionic/cli`
|
||||
`npm install -g @ionic/cli`
|
||||
|
||||
`npm --prefix . install`
|
||||
`npm --prefix . install` - installs node package dependencies
|
||||
|
||||
`npm --prefix . run build-deps`
|
||||
`npm --prefix . run build-deps` - compiles dependent libraries, particularly the client for patch-db
|
||||
|
||||
Copy `config-sample.json` to new file `config.json`
|
||||
Copy `config-sample.json` and contents to a new file called `config.json`
|
||||
In `config.json`, edit the "mocks" section to look like the following:
|
||||
|
||||
```
|
||||
@@ -41,6 +49,18 @@ In `config.json`, edit the "mocks" section to look like the following:
|
||||
|
||||
Valid values for "maskAs" are `tor` and `lan`.
|
||||
|
||||
**Start the development server**
|
||||
### Start the development server
|
||||
|
||||
`ionic serve`
|
||||
Serves the ui on localhost:8100 for local development.
|
||||
Edit `./ui/use-mocks.json` to 'true' to use mocks during local development
|
||||
|
||||
```
|
||||
ionic serve
|
||||
```
|
||||
|
||||
### Production Build
|
||||
Before publishing a PR, please build for production and correct any errors. Run the following command, which compiles project customized for deployment to an Embassy, depositing build artifacts into `ui/www`.
|
||||
|
||||
```
|
||||
npm --prefix ui run build-prod
|
||||
```
|
||||
@@ -9,7 +9,7 @@
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"build-prod": "ng build --configuration production && tsc postprocess.ts && node postprocess.js && git log | head -n1 > www/git-hash.txt",
|
||||
"build-deps": "cd ../patch-db/client && npm install && npm run build",
|
||||
"build-deps": "cd ../patch-db/client && npm --prefix . install && npm run build",
|
||||
"lint": "ng lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user