mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 18:31:52 +00:00
Setup Scripts (#472)
* Init commit of setup scripts * Minor edit * Script edit and dir rename * Oops * Updated README * Updated scripts/readme * Additional Script/README updates * Further Script updates * BuildGuide updates * More git fuckery * Init commit of setup scripts * Minor edit * Script edit and dir rename * Oops * Updated scripts/readme * Script/README updates * Additional Script/README updates * Script/README edits * Copy script edit * Copy script edit * Filesystem script edit * More edits * Guide edit * Makefile * fixes ui build scripts to use submodules (#546) * fix product key generation Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Keagan McClelland <keagan.mcclelland@gmail.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
.DS_Store
|
||||
/*.img
|
||||
/buster.zip
|
||||
/product_key
|
||||
/ubuntu.img.xz
|
||||
/product_key.txt
|
||||
|
||||
118
Makefile
118
Makefile
@@ -1,75 +1,75 @@
|
||||
UNAME := $(shell uname -m)
|
||||
|
||||
EMBASSY_SRC := buster.img product_key appmgr/target/armv7-unknown-linux-gnueabihf/release/appmgr ui/www agent/dist/agent agent/config/agent.service lifeline/target/armv7-unknown-linux-gnueabihf/release/lifeline lifeline/lifeline.service setup.sh setup.service docker-daemon.json
|
||||
APPMGR_RELEASE_SRC := appmgr/target/armv7-unknown-linux-gnueabihf/release/appmgr
|
||||
LIFELINE_RELEASE_SRC := lifeline/target/armv7-unknown-linux-gnueabihf/release/lifeline
|
||||
|
||||
ifeq ($(UNAME), armv7l)
|
||||
EMBASSY_SRC := buster.img product_key appmgr/target/release/appmgr ui/www agent/dist/agent agent/config/agent.service lifeline/target/release/lifeline lifeline/lifeline.service setup.sh setup.service docker-daemon.json
|
||||
APPMGR_RELEASE_SRC := appmgr/target/release/appmgr
|
||||
LIFELINE_RELEASE_SRC := lifeline/target/release/lifeline
|
||||
endif
|
||||
EMBASSY_BINS := appmgr/target/aarch64-unknown-linux-gnu/release/embassyd appmgr/target/aarch64-unknown-linux-gnu/release/embassy-init appmgr/target/aarch64-unknown-linux-gnu/release/embassy-cli appmgr/target/aarch64-unknown-linux-gnu/release/embassy-sdk
|
||||
EMBASSY_UIS := ui/www setup-wizard/www diagnostic-ui/www
|
||||
EMBASSY_SRC := ubuntu.img product_key.txt $(EMBASSY_BINS) appmgr/embassyd.service appmgr/embassy-init.service $(EMBASSY_UIS) build/initialization.sh build/initialization.service
|
||||
|
||||
APPMGR_SRC := $(shell find appmgr/src) appmgr/Cargo.toml appmgr/Cargo.lock
|
||||
LIFELINE_SRC := $(shell find lifeline/src) lifeline/Cargo.toml lifeline/Cargo.lock
|
||||
AGENT_SRC := $(shell find agent/src) $(shell find agent/config) agent/stack.yaml agent/package.yaml agent/build.sh
|
||||
UI_SRC := $(shell find ui/src) \
|
||||
ui/angular.json \
|
||||
ui/browserslist \
|
||||
ui/client-manifest.yaml \
|
||||
ui/ionic.config.json \
|
||||
ui/postprocess.ts \
|
||||
ui/tsconfig.json \
|
||||
ui/tslint.json \
|
||||
ui/use-mocks.json
|
||||
UI_SRC := $(shell find ui/src)
|
||||
SETUP_WIZARD_SRC := $(shell find setup-wizard/src)
|
||||
DIAGNOSTIC_UI_SRC := $(shell find diagnostic-ui/src)
|
||||
PATCH_DB_CLIENT_SRC = $(shell find patch-db/client)
|
||||
|
||||
all: embassy.img
|
||||
all: eos.img
|
||||
|
||||
embassy.img: $(EMBASSY_SRC)
|
||||
chmod +x make_image.sh
|
||||
sudo ./make_image.sh
|
||||
clean:
|
||||
rm -f eos.img
|
||||
rm -f ubuntu.img
|
||||
rm -f product_key.txt
|
||||
sudo rm -f $(EMBASSY_BINS)
|
||||
rm -rf ui/node_modules
|
||||
rm -rf ui/www
|
||||
rm -rf setup-wizard/node_modules
|
||||
rm -rf setup-wizard/www
|
||||
rm -rf diagnostic-ui/node_modules
|
||||
rm -rf diagnostic-ui/www
|
||||
rm -rf patch-db/client/node_modules
|
||||
rm -rf patch-db/client/dist
|
||||
|
||||
buster.img:
|
||||
wget -O buster.zip https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2020-08-24/2020-08-20-raspios-buster-armhf-lite.zip
|
||||
unzip buster.zip
|
||||
rm buster.zip
|
||||
mv 2020-08-20-raspios-buster-armhf-lite.img buster.img
|
||||
eos.img: $(EMBASSY_SRC)
|
||||
./build/make-image.sh
|
||||
|
||||
product_key:
|
||||
echo "X\c" > product_key
|
||||
cat /dev/random | base32 | head -c11 | tr '[:upper:]' '[:lower:]' >> product_key
|
||||
ubuntu.img:
|
||||
wget -O ubuntu.img.xz https://cdimage.ubuntu.com/releases/21.04/release/ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz
|
||||
unxz ubuntu.img.xz
|
||||
|
||||
$(APPMGR_RELEASE_SRC): $(APPMGR_SRC)
|
||||
ifeq ($(UNAME), armv7l)
|
||||
cd appmgr && cargo update && cargo build --release --features=production
|
||||
arm-linux-gnueabihf-strip appmgr/target/release/appmgr
|
||||
else
|
||||
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)":/home/rust/src start9/rust-arm-cross:latest sh -c "(cd appmgr && cargo build --release --features=production)"
|
||||
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)":/home/rust/src start9/rust-arm-cross:latest arm-linux-gnueabi-strip appmgr/target/armv7-unknown-linux-gnueabihf/release/appmgr
|
||||
endif
|
||||
product_key.txt:
|
||||
echo "X\c" > product_key.txt
|
||||
cat /dev/random | base32 | head -c11 | tr '[:upper:]' '[:lower:]' >> product_key.txt
|
||||
|
||||
appmgr: $(APPMGR_RELEASE_SRC)
|
||||
|
||||
agent/dist/agent: $(AGENT_SRC)
|
||||
(cd agent && ./build.sh)
|
||||
|
||||
agent: agent/dist/agent
|
||||
$(EMBASSY_BINS): $(APPMGR_SRC)
|
||||
cd appmgr && ./build-prod.sh
|
||||
|
||||
ui/node_modules: ui/package.json
|
||||
npm --prefix ui install
|
||||
|
||||
ui/www: $(UI_SRC) ui/node_modules
|
||||
ui/www: $(UI_SRC) ui/node_modules patch-db/client/dist ui/config.json
|
||||
npm --prefix ui run build-prod
|
||||
|
||||
ui: ui/www
|
||||
ui/config.json:
|
||||
cp ui/config-sample.json ui/config.json
|
||||
|
||||
$(LIFELINE_RELEASE_SRC): $(LIFELINE_SRC)
|
||||
ifeq ($(UNAME), armv7l)
|
||||
cd lifeline && cargo build --release
|
||||
arm-linux-gnueabihf-strip lifeline/target/release/lifeline
|
||||
else
|
||||
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)":/home/rust/src start9/rust-arm-cross:latest sh -c "(cd lifeline && cargo build --release)"
|
||||
docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)":/home/rust/src start9/rust-arm-cross:latest arm-linux-gnueabi-strip lifeline/target/armv7-unknown-linux-gnueabihf/release/lifeline
|
||||
endif
|
||||
setup-wizard/node_modules: setup-wizard/package.json
|
||||
npm --prefix setup-wizard install
|
||||
|
||||
setup-wizard/www: $(SETUP_WIZARD_SRC) setup-wizard/node_modules setup-wizard/config.json
|
||||
npm --prefix setup-wizard run build-prod
|
||||
|
||||
setup-wizard/config.json:
|
||||
cp setup-wizard/config-sample.json setup-wizard/config.json
|
||||
|
||||
diagnostic-ui/node_modules: diagnostic-ui/package.json
|
||||
npm --prefix diagnostic-ui install
|
||||
|
||||
diagnostic-ui/www: $(DIAGNOSTIC_UI_SRC) diagnostic-ui/node_modules diagnostic-ui/config.json
|
||||
npm --prefix diagnostic-ui run build-prod
|
||||
|
||||
diagnostic-ui/config.json:
|
||||
cp diagnostic-ui/config-sample.json diagnostic-ui/config.json
|
||||
|
||||
patch-db/client/node_modules: patch-db/client/package.json
|
||||
npm --prefix patch-db/client install
|
||||
|
||||
patch-db/client/dist: $(PATCH_DB_SRC) patch-db/client/node_modules
|
||||
npm --prefix patch-db/client run build
|
||||
|
||||
ui: $(EMBASSY_UIS)
|
||||
|
||||
lifeline: $(LIFELINE_RELEASE_SRC)
|
||||
|
||||
12
appmgr/copy.sh
Executable file
12
appmgr/copy.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Enter the appmgr directory, copy over the built EmbassyOS binaries and systemd services, edit the nginx config, then create the .ssh directory
|
||||
|
||||
cp target/aarch64-unknown-linux-gnu/release/embassy-init /mnt/usr/local/bin
|
||||
cp target/aarch64-unknown-linux-gnu/release/embassyd /mnt/usr/local/bin
|
||||
cp target/aarch64-unknown-linux-gnu/release/embassy-cli /mnt/usr/local/bin
|
||||
cp *.service /mnt/etc/systemd/system/
|
||||
|
||||
echo "application/wasm wasm;" | sudo tee -a "/mnt/etc/nginx/mime.types"
|
||||
|
||||
mkdir -p /mnt/root/.ssh
|
||||
214
build/NOTES.md
Normal file
214
build/NOTES.md
Normal file
@@ -0,0 +1,214 @@
|
||||
# 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 appmgr dir: `./build-prod.sh`), then, also from the appmgr 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?
|
||||
13
build/README.md
Normal file
13
build/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Building Embassy OS
|
||||
|
||||
## Prerequisites
|
||||
|
||||
TODO
|
||||
|
||||
## Build
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
## Setup
|
||||
http://embassy.local
|
||||
46
build/README.old.md
Normal file
46
build/README.old.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# 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 appmgr 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
|
||||
10
build/initialization.service
Normal file
10
build/initialization.service
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Boot process for system initialization.
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/initialization.sh
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
37
build/initialization.sh
Executable file
37
build/initialization.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Update repositories, install dependencies, do some initial configurations, set hostname, enable embassy-init, and config Tor
|
||||
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
|
||||
sed -i '/}/i \ \ \ \ application\/wasm \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ wasm;' /etc/nginx/mime.types
|
||||
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
|
||||
|
||||
systemctl disable initialization.service
|
||||
sync
|
||||
reboot
|
||||
19
build/make-image.sh
Executable file
19
build/make-image.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
cd $DIR/..
|
||||
|
||||
truncate --size=$[(31116287+1)*512] eos.img
|
||||
export OUTPUT_DEVICE=$(sudo losetup --show -fP eos.img)
|
||||
export LOOPDEV=$(sudo losetup --show -fP ubuntu.img)
|
||||
./build/partitioning.sh
|
||||
./build/write-image.sh
|
||||
sudo losetup -d $OUTPUT_DEVICE
|
||||
6
build/partitioning.sh
Executable file
6
build/partitioning.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Use fdisk to create DOS partition table with 4 primary partitions, set 1 as bootable, write, and quite
|
||||
(echo o; echo n; echo p; echo 1; echo 2048; echo 526335; echo t; echo c; echo n; echo p; echo 2; echo 526336; echo 1050623; echo t; echo 2; echo c; echo n; echo p; echo 3; echo 1050624; echo 16083455; echo n; echo p; echo 16083456; echo 31116287; echo a; echo 1; echo w) | sudo fdisk ${OUTPUT_DEVICE}
|
||||
58
build/write-image.sh
Executable file
58
build/write-image.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Write contents of LOOPDEV (Ubuntu image) to sd card and make filesystems, then detach the loop device
|
||||
echo USING $LOOPDEV TO IMAGE $OUTPUT_DEVICE
|
||||
sudo dd if=${LOOPDEV}p1 of=${OUTPUT_DEVICE}p1 bs=4096 conv=fsync status=progress
|
||||
sudo mkfs.vfat -F 32 ${OUTPUT_DEVICE}p2
|
||||
sudo dd if=${LOOPDEV}p2 of=${OUTPUT_DEVICE}p3 bs=4096 conv=fsync status=progress
|
||||
sudo mkfs.ext4 ${OUTPUT_DEVICE}p4
|
||||
|
||||
sudo losetup -d $LOOPDEV
|
||||
|
||||
# Label the filesystems
|
||||
sudo fatlabel ${OUTPUT_DEVICE}p1 system-boot
|
||||
sudo fatlabel ${OUTPUT_DEVICE}p2 EMBASSY
|
||||
sudo e2label ${OUTPUT_DEVICE}p3 writable
|
||||
sudo e2label ${OUTPUT_DEVICE}p4 reserved
|
||||
|
||||
# Mount the boot partition and config
|
||||
mkdir -p /tmp/eos-mnt
|
||||
sudo mount ${OUTPUT_DEVICE}p1 /tmp/eos-mnt
|
||||
|
||||
cat /tmp/eos-mnt/config.txt | grep -v "dtoverlay=" | sudo tee /tmp/eos-mnt/config.txt.tmp
|
||||
echo "dtoverlay=pwm-2chan" | sudo tee -a /tmp/eos-mnt/config.txt.tmp
|
||||
sudo mv /tmp/eos-mnt/config.txt.tmp /tmp/eos-mnt/config.txt
|
||||
|
||||
# Unmount the boot partition and mount embassy partition
|
||||
sudo umount /tmp/eos-mnt
|
||||
sudo mount ${OUTPUT_DEVICE}p2 /tmp/eos-mnt
|
||||
sudo cp product_key.txt /tmp/eos-mnt
|
||||
sudo umount /tmp/eos-mnt
|
||||
|
||||
sudo mount ${OUTPUT_DEVICE}p3 /tmp/eos-mnt
|
||||
# Enter the appmgr directory, copy over the built EmbassyOS binaries and systemd services, edit the nginx config, then create the .ssh directory
|
||||
cd appmgr/
|
||||
|
||||
sudo cp target/aarch64-unknown-linux-gnu/release/embassy-init /tmp/eos-mnt/usr/local/bin
|
||||
sudo cp target/aarch64-unknown-linux-gnu/release/embassyd /tmp/eos-mnt/usr/local/bin
|
||||
sudo cp target/aarch64-unknown-linux-gnu/release/embassy-cli /tmp/eos-mnt/usr/local/bin
|
||||
sudo cp *.service /tmp/eos-mnt/etc/systemd/system/
|
||||
|
||||
cd ..
|
||||
|
||||
# after performing npm run build
|
||||
sudo mkdir -p /tmp/eos-mnt/var/www/html
|
||||
sudo cp -R ui/www /tmp/eos-mnt/var/www/html/main
|
||||
sudo cp -R setup-wizard/www /tmp/eos-mnt/var/www/html/setup
|
||||
sudo cp -R diagnostic-ui/www /tmp/eos-mnt/var/www/html/diagnostic
|
||||
|
||||
# Make the .ssh directory
|
||||
sudo mkdir -p /tmp/eos-mnt/root/.ssh
|
||||
|
||||
sudo cp ./build/initialization.sh /tmp/eos-mnt/usr/local/bin
|
||||
sudo cp ./build/initialization.service /tmp/eos-mnt/etc/systemd/system/initialization.service
|
||||
sudo ln -s /etc/systemd/system/initialization.service /tmp/eos-mnt/etc/systemd/system/multi-user.target.wants/initialization.service
|
||||
|
||||
sudo umount /tmp/eos-mnt
|
||||
24
diagnostic-ui/package-lock.json
generated
24
diagnostic-ui/package-lock.json
generated
@@ -18716,7 +18716,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.0",
|
||||
@@ -18796,7 +18798,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18857,7 +18861,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18975,7 +18981,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -20813,7 +20821,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -21411,7 +21421,9 @@
|
||||
"integrity": "sha512-Brah4Uo5/U8v76c6euTwtjVFFaVishwnJrQBYpev1JRh4vjA1F4HY3UzQez41YUCszUCXKagG8v6eVRBHV1gkw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"alphanum-sort": {
|
||||
"version": "1.0.2",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"build-prod": "ng build --configuration production",
|
||||
"lint": "ng lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
25
setup-wizard/package-lock.json
generated
25
setup-wizard/package-lock.json
generated
@@ -5,6 +5,7 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "setup-wizard",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@angular/common": "^12.2.1",
|
||||
@@ -18822,7 +18823,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.0",
|
||||
@@ -18902,7 +18905,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18963,7 +18968,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -19073,7 +19080,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -20911,7 +20920,9 @@
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz",
|
||||
"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -21526,7 +21537,9 @@
|
||||
"integrity": "sha512-Brah4Uo5/U8v76c6euTwtjVFFaVishwnJrQBYpev1JRh4vjA1F4HY3UzQez41YUCszUCXKagG8v6eVRBHV1gkw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {}
|
||||
"requires": {
|
||||
"ajv": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"alphanum-sort": {
|
||||
"version": "1.0.2",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"lint": "ng lint",
|
||||
"build-prod": "ng build --prod"
|
||||
"build-prod": "ng build --configuration production"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/common": "^12.2.1",
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
[Unit]
|
||||
Description=Boot process for system setup.
|
||||
After=rc-local.service
|
||||
Before=getty.target
|
||||
ConditionFileNotEmpty=/root/setup.sh
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/root/setup.sh
|
||||
ExecStartPost=/root/setup-s2.sh
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
|
||||
35
setup.sh
35
setup.sh
@@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
mkdir -p /root/volumes
|
||||
mkdir -p /root/tmp/appmgr
|
||||
mkdir -p /root/agent
|
||||
mkdir -p /root/appmgr/tor
|
||||
apt-get update -y
|
||||
apt-get install -y tor
|
||||
apt-get install -y iotop
|
||||
apt-get install -y bmon
|
||||
apt-get install -y libavahi-client3
|
||||
apt-get install -y libsecp256k1-0
|
||||
apt-get install -y docker.io needrestart-
|
||||
mv /root/setup.sh /root/setup-s1.sh.done
|
||||
cat <<EOT >> /root/setup-s2.sh
|
||||
#!/bin/bash
|
||||
apt-get update -y
|
||||
apt-get install -y tor
|
||||
apt-get install -y iotop
|
||||
apt-get install -y bmon
|
||||
apt-get install -y libavahi-client3
|
||||
apt-get install -y libsecp256k1-0
|
||||
apt-get install -y docker.io needrestart-
|
||||
apt-get autoremove -y
|
||||
systemctl enable lifeline
|
||||
systemctl enable agent
|
||||
systemctl enable ssh
|
||||
systemctl enable avahi-daemon
|
||||
passwd -l root
|
||||
passwd -l pi
|
||||
sync
|
||||
systemctl disable setup
|
||||
mv /root/setup-s2.sh /root/setup-s2.sh.done
|
||||
reboot
|
||||
EOT
|
||||
chmod +x /root/setup-s2.sh
|
||||
20
ui/README.md
20
ui/README.md
@@ -6,29 +6,15 @@
|
||||
|
||||
`npm i -g @ionic/cli`
|
||||
|
||||
`git clone https://github.com/Start9Labs/patch-db.git`
|
||||
|
||||
`git clone https://github.com/Start9Labs/ws-example.git`
|
||||
|
||||
`git clone https://github.com/Start9Labs/embassy-os.git`
|
||||
|
||||
`git clone https://github.com/Start9Labs/rpc-toolkit.git`
|
||||
|
||||
`git clone https://github.com/dr-bonez/yajrc`
|
||||
|
||||
Then open `patch-db`, `ws-example`, and `embassy-os`, in separate tabs.
|
||||
|
||||
### patch-db
|
||||
|
||||
**Sync submodules**
|
||||
`cd embassy-os`
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
|
||||
`cd client/`
|
||||
|
||||
`npm i`
|
||||
|
||||
`npm run build`
|
||||
Then open `ws-example`, and `embassy-os`, in separate tabs.
|
||||
|
||||
### ws-example
|
||||
|
||||
@@ -40,6 +26,8 @@ Then open `patch-db`, `ws-example`, and `embassy-os`, in separate tabs.
|
||||
|
||||
`cd ui/`
|
||||
|
||||
`npm run build-deps`
|
||||
|
||||
`npm i`
|
||||
|
||||
Copy `config-sample.json` to new file `config.json`
|
||||
|
||||
3334
ui/package-lock.json
generated
3334
ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,6 +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",
|
||||
"lint": "ng lint"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -29,7 +30,7 @@
|
||||
"marked": "3.0.2",
|
||||
"mustache": "^4.2.0",
|
||||
"ng-qrcode": "^5.0.0",
|
||||
"patch-db-client": "file: ../../../../patch-db/client",
|
||||
"patch-db-client": "file: ../../../patch-db/client",
|
||||
"rxjs": "^6.6.7",
|
||||
"uuid": "^8.3.2",
|
||||
"zone.js": "^0.11.4"
|
||||
|
||||
Reference in New Issue
Block a user