From 0b0138120dd37acb689b6e7d2e5d8ab61220fd55 Mon Sep 17 00:00:00 2001 From: gStart9 Date: Wed, 18 Oct 2023 16:39:11 -0600 Subject: [PATCH] Update upstream to v016, fix backups --- Dockerfile | 8 +-- Makefile | 9 ++-- README.md | 45 ++++++++++++----- assets/compat/backup.sh | 36 ++++++++++++++ docker_entrypoint.sh | 44 ++++++++-------- manifest.yaml | 46 +++++++++-------- scripts/services/getConfig.ts | 94 +++++++++++++++++------------------ 7 files changed, 172 insertions(+), 110 deletions(-) create mode 100644 assets/compat/backup.sh diff --git a/Dockerfile b/Dockerfile index 3138e49..706d9f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM ghcr.io/joinmarket-webui/jam-standalone:v0.1.5-clientserver-v0.9.9 +FROM ghcr.io/joinmarket-webui/jam-standalone:v0.1.6-clientserver-v0.9.10 # arm64 or amd64 ARG PLATFORM # aarch64 or x86_64 ARG ARCH -RUN apt-get update && apt-get install -qq --no-install-recommends wget bash tini +RUN sed -i "s|http://|https://|g" /etc/apt/sources.list /etc/apt/sources.list.d/* +RUN apt-get update && apt-get -y upgrade && apt-get install -y -qq --no-install-recommends wget bash tini +RUN apt-get upgrade RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${PLATFORM} && chmod +x /usr/local/bin/yq # USER root @@ -15,7 +17,7 @@ ENV APP_PASSWORD "joinmarket" ENV ENSURE_WALLET true ENV REMOVE_LOCK_FILES true -ENV RESTORE_DEFAULT_CONFIG true +ENV RESTORE_DEFAULT_CONFIG false ADD docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh ADD assets/utils/check-api.sh /usr/local/bin/check-api.sh diff --git a/Makefile b/Makefile index d62a740..efcdbe6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PKG_ID := $(shell yq e ".id" manifest.yaml) PKG_VERSION := $(shell yq e ".version" manifest.yaml) TS_FILES := $(shell find ./ -name \*.ts) +ASSET_PATHS := $(shell find ./assets/compat/*) # delete the target of a rule if it has changed and its recipe exits with a nonzero exit status .DELETE_ON_ERROR: @@ -8,12 +9,12 @@ TS_FILES := $(shell find ./ -name \*.ts) all: verify verify: $(PKG_ID).s9pk - @embassy-sdk verify s9pk $(PKG_ID).s9pk + @start-sdk verify s9pk $(PKG_ID).s9pk @echo " Done!" @echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready" install: $(PKG_ID).s9pk - embassy-cli package install $(PKG_ID).s9pk + start-cli package install $(PKG_ID).s9pk clean: rm -rf docker-images @@ -32,5 +33,5 @@ docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh assets/utils/* mkdir -p docker-images docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/arm64 --build-arg PLATFORM=arm64 -o type=docker,dest=docker-images/aarch64.tar . -$(PKG_ID).s9pk: manifest.yaml instructions.md LICENSE icon.png scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar - embassy-sdk pack +$(PKG_ID).s9pk: manifest.yaml instructions.md LICENSE icon.png scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar $(ASSET_PATHS) + start-sdk pack diff --git a/README.md b/README.md index cffea5f..0c056e4 100644 --- a/README.md +++ b/README.md @@ -8,61 +8,78 @@ JAM is a web UI for JoinMarket with focus on user-friendliness. It aims to provi - [docker-buildx](https://docs.docker.com/buildx/working-with-buildx/) - [yq](https://mikefarah.gitbook.io/yq) - [deno](https://deno.land/) -- [embassy-sdk](https://github.com/Start9Labs/embassy-os/tree/master/backend) +- [start-sdk](https://github.com/Start9Labs/start-os/tree/master/backend) - [make](https://www.gnu.org/software/make/) ## Build enviroment -Prepare your EmbassyOS build enviroment. In this example we are using Ubuntu 20.04. + +Prepare your StartOS build enviroment. In this example we are using Ubuntu 20.04. 1. Install docker + ``` curl -fsSL https://get.docker.com -o- | bash sudo usermod -aG docker "$USER" exec sudo su -l $USER ``` + 2. Set buildx as the default builder + ``` docker buildx install docker buildx create --use ``` + 3. Enable cross-arch emulated builds in docker + ``` docker run --privileged --rm linuxkit/binfmt:v0.8 ``` + 4. Install yq + ``` sudo snap install yq ``` + 5. Install essentials build packages + ``` sudo apt-get install -y build-essential openssl libssl-dev libc6-dev clang libclang-dev ca-certificates ``` + 6. Install Rust + ``` curl https://sh.rustup.rs -sSf | sh # Choose nr 1 (default install) source $HOME/.cargo/env ``` + 7. Install toml + ``` cargo install toml-cli ``` -8. Build and install embassy-sdk + +8. Build and install start-sdk + ``` -cd ~/ && git clone https://github.com/Start9Labs/embassy-os.git -cd embassy-os/backend/ +cd ~/ && git clone https://github.com/Start9Labs/start-os.git +cd start-os/backend/ ./install-sdk.sh ``` ## Cloning -Clone the project locally. Note the submodule link to the original project(s). +Clone the project locally. Note the submodule link to the original project(s). ``` git clone https://github.com/Start9Labs/jam-wrapper.git cd jam-wrapper git submodule update --init --recursive ``` + ## Building To build the project, run the following commands: @@ -79,19 +96,23 @@ You should only run the above commands once to create a custom builder. Afterwar make ``` -## Installing (on Embassy) +## Installing (on StartOS) -SSH into an Embassy device. +Sideload from the web-UI via: +System > Sideload Service + +...or SSH into an StartOS device. `scp` the `.s9pk` to any directory from your local machine. Run the following command to install the package: ``` -embassy-cli auth login -#Enter your embassy password then run: -embassy-cli package install /path/to/jam.s9pk +start-cli auth login +#Enter your StartOS server's master password, then run: +start-cli package install /path/to/jam.s9pk ``` + ## Verify Install -Go to your Embassy Services page, select JAM and start the service. +Go to your StartOS Services page, select JAM and start the service. #Done diff --git a/assets/compat/backup.sh b/assets/compat/backup.sh new file mode 100644 index 0000000..99471d4 --- /dev/null +++ b/assets/compat/backup.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Multi-path backup script +set -e + +if [ "$1" = "create" ]; then + shift + backup_type="create" +elif [ "$1" = "restore" ]; then + shift + backup_type="restore" +else + echo "Usage: $0 [create|restore] [dir1] [dir2] ..." + exit 1 +fi + +backup_dir="/mnt/backup" + +for dir in "$@"; do + if [ ! -d "$dir" ]; then + echo "Error: Directory '$dir' does not exist." + exit 1 + fi + + target_dir="$backup_dir/$(basename "$dir")" + + mkdir -p "$target_dir" + + case "$backup_type" in + create) + compat duplicity create "$target_dir" "$dir" + ;; + restore) + compat duplicity restore "$target_dir" "$dir" + ;; + esac +done \ No newline at end of file diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 5343b3e..c7b3265 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -4,34 +4,34 @@ set -e # Setting env-vars echo "Setting environment variables..." -export APP_USER=$(yq e '.username' /embassy/start9/config.yaml) -export APP_PASSWORD=$(yq e '.password' /embassy/start9/config.yaml) -export TOR_HOST=$(yq e '.tor-address' /embassy/start9/config.yaml) -export LAN_HOST=$(yq e '.lan-address' /embassy/start9/config.yaml) -export JM_RPC_USER=$(yq e '.bitcoind-user' /embassy/start9/config.yaml) -export JM_RPC_PASSWORD=$(yq e '.bitcoind-password' /embassy/start9/config.yaml) +export APP_USER=$(yq e '.username' /data/start9/config.yaml) +export APP_PASSWORD=$(yq e '.password' /data/start9/config.yaml) +export TOR_HOST=$(yq e '.tor-address' /data/start9/config.yaml) +export LAN_HOST=$(yq e '.lan-address' /data/start9/config.yaml) +export JM_RPC_USER=$(yq e '.bitcoind-user' /data/start9/config.yaml) +export JM_RPC_PASSWORD=$(yq e '.bitcoind-password' /data/start9/config.yaml) export JM_RPC_PORT=8332 export JM_RPC_WALLET_FILE="embassy_jam_wallet" export JM_RPC_HOST="bitcoind.embassy" echo "Running on Bitcoin Core..." # Properties Page showing password to be used for login - echo 'version: 2' > /embassy/start9/stats.yaml - echo 'data:' >> /embassy/start9/stats.yaml - echo ' Username: ' >> /embassy/start9/stats.yaml - echo ' type: string' >> /embassy/start9/stats.yaml - echo " value: \"$APP_USER\"" >> /embassy/start9/stats.yaml - echo ' description: This is your username for JAM' >> /embassy/start9/stats.yaml - echo ' copyable: true' >> /embassy/start9/stats.yaml - echo ' masked: false' >> /embassy/start9/stats.yaml - echo ' qr: false' >> /embassy/start9/stats.yaml - echo ' Password: ' >> /embassy/start9/stats.yaml - echo ' type: string' >> /embassy/start9/stats.yaml - echo " value: \"$APP_PASSWORD\"" >> /embassy/start9/stats.yaml - echo ' description: This is your password for JAM. Please use caution when sharing this password, you could lose your funds!' >> /embassy/start9/stats.yaml - echo ' copyable: true' >> /embassy/start9/stats.yaml - echo ' masked: true' >> /embassy/start9/stats.yaml - echo ' qr: false' >> /embassy/start9/stats.yaml + echo 'version: 2' > /data/start9/stats.yaml + echo 'data:' >> /data/start9/stats.yaml + echo ' Username: ' >> /data/start9/stats.yaml + echo ' type: string' >> /data/start9/stats.yaml + echo " value: \"$APP_USER\"" >> /data/start9/stats.yaml + echo ' description: This is your username for JAM' >> /data/start9/stats.yaml + echo ' copyable: true' >> /data/start9/stats.yaml + echo ' masked: false' >> /data/start9/stats.yaml + echo ' qr: false' >> /data/start9/stats.yaml + echo ' Password: ' >> /data/start9/stats.yaml + echo ' type: string' >> /data/start9/stats.yaml + echo " value: \"$APP_PASSWORD\"" >> /data/start9/stats.yaml + echo ' description: This is your password for JAM. Please use caution when sharing this password, you could lose your funds!' >> /data/start9/stats.yaml + echo ' copyable: true' >> /data/start9/stats.yaml + echo ' masked: true' >> /data/start9/stats.yaml + echo ' qr: false' >> /data/start9/stats.yaml # Starting JoinMarket API echo "Starting JoinMarket..." diff --git a/manifest.yaml b/manifest.yaml index e038050..9274504 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,8 +1,9 @@ -id: jam +id: jam title: JAM -version: 0.1.5 +version: 0.1.6 release-notes: | - * Update to latest upstream - [JAM v0.1.5 Release Notes](https://github.com/joinmarket-webui/jam/releases/tag/v0.1.5) + * Update to latest upstream - [JAM v0.1.6 Release Notes](https://github.com/joinmarket-webui/jam/releases/tag/v0.1.6) + * Fix backup creation and restore processes. license: mit wrapper-repo: "https://github.com/Start9Labs/jam-wrapper" upstream-repo: "https://github.com/joinmarket-webui/jam-docker" @@ -10,7 +11,7 @@ support-site: "https://github.com/joinmarket-webui/jam-docker/issues" marketing-site: "https://jamapp.org" build: ["make"] description: - short: JAM - A friendly UI for JoinMarket + short: JAM - A friendly UI for JoinMarket long: | Jam is a web UI for JoinMarket with focus on user-friendliness. It aims to provide sensible defaults and be easy to use for beginners while still providing the features advanced users expect. @@ -24,7 +25,7 @@ main: entrypoint: "tini" args: ["-g", "--", "docker_entrypoint.sh"] mounts: - main: /embassy + main: /data jam: /root/.joinmarket health-checks: web-ui: @@ -52,6 +53,8 @@ volumes: type: data jam: type: data + compat: + type: assets interfaces: main: name: JAM Web UI @@ -67,14 +70,14 @@ interfaces: protocols: - tcp - http -dependencies: +dependencies: bitcoind: version: ">=0.23.0.1 <=26.0.0" requirement: type: required description: Used to subscribe to new block events from a full archival node. config: - check: + check: type: script auto-configure: type: script @@ -82,7 +85,7 @@ alerts: install: | WARNING: If you have an older version of JAM running, this install will stop all active liquidity offers. You will need to manually restart your offers after the install is complete. start: | - It may take some time for the JAM API to initialize over the Tor network, please be patient. + It may take some time for the JAM API to initialize over the Tor network, please be patient. migrations: from: "*": @@ -96,29 +99,28 @@ backup: create: type: docker image: compat - system: true - entrypoint: compat - args: - - duplicity + system: true + entrypoint: /mnt/assets/backup.sh + args: - create - - /mnt/backup - - /app/data + - /data/start9 + - /root/.joinmarket mounts: - BACKUP: "/mnt/backup" - main: "/app/data" + BACKUP: "/mnt/backup" + compat: "/mnt/assets" + main: "/data/start9" jam: "/root/.joinmarket" restore: type: docker image: compat system: true - entrypoint: compat + entrypoint: /mnt/assets/backup.sh args: - - duplicity - restore - - /mnt/backup - - /app/data + - /data/start9 + - /root/.joinmarket mounts: BACKUP: "/mnt/backup" - main: "/app/data" + compat: "/mnt/assets" + main: "/data/start9" jam: "/root/.joinmarket" - diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index d04b8a5..7c239b5 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -2,62 +2,62 @@ import { compat, types as T } from "../deps.ts"; export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({ "tor-address": { - "name": "Tor Address", - "description": "The Tor address of the network interface", - "type": "pointer", - "subtype": "package", + name: "Tor Address", + description: "The Tor address of the network interface", + type: "pointer", + subtype: "package", "package-id": "jam", - "target": "tor-address", - "interface": "main", + target: "tor-address", + interface: "main", }, "lan-address": { - "name": "Network LAN Address", - "description": "The LAN address for the network interface.", - "type": "pointer", - "subtype": "package", - "package-id": "jam", - "target": "lan-address", - "interface": "main" + name: "Network LAN Address", + description: "The LAN address for the network interface.", + type: "pointer", + subtype: "package", + "package-id": "jam", + target: "lan-address", + interface: "main", }, - "username": { - "type": "string", - "name": "JAM Username", - "description": "Administrator username for JAM", - "nullable": false, - "copyable": true, - "masked": false, - "default": "embassy" + username: { + type: "string", + name: "JAM Username", + description: "Administrator username for JAM", + nullable: false, + copyable: true, + masked: false, + default: "jam", }, - "password": { - "type": "string", - "name": "JAM Password", - "description": "Administrator password for JAM", - "nullable": false, - "copyable": true, - "masked": true, - "default": { - "charset": "a-z,A-Z,0-9", - "len": 22 - } + password: { + type: "string", + name: "JAM Password", + description: "Administrator password for JAM", + nullable: false, + copyable: true, + masked: true, + default: { + charset: "a-z,A-Z,0-9", + len: 22, + }, }, "bitcoind-user": { - "type": "pointer", - "name": "RPC Username", - "description": "The username for Bitcoin Core's RPC interface", - "subtype": "package", + type: "pointer", + name: "RPC Username", + description: "The username for Bitcoin Core's RPC interface", + subtype: "package", "package-id": "bitcoind", - "target": "config", - "multi": false, - "selector": "$.rpc.username" + target: "config", + multi: false, + selector: "$.rpc.username", }, "bitcoind-password": { - "type": "pointer", - "name": "RPC Password", - "description": "The password for Bitcoin Core's RPC interface", - "subtype": "package", + type: "pointer", + name: "RPC Password", + description: "The password for Bitcoin Core's RPC interface", + subtype: "package", "package-id": "bitcoind", - "target": "config", - "multi": false, - "selector": "$.rpc.password" - } + target: "config", + multi: false, + selector: "$.rpc.password", + }, });