Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
stop_grace_period: 30s
volumes:
- /mnt/hdd/mynode/canary:/app/data
env_file:
- /mnt/hdd/mynode/canary/canary.env
environment:
CANARY_DATA_DIR: /app/data
CANARY_ELECTRUM_URL: tcp://127.0.0.1:50001
Expand All @@ -24,4 +26,4 @@ services:
- backend
environment:
API_URL: http://127.0.0.1:3004
PORT: "3005"
PORT: "3005"
4 changes: 3 additions & 1 deletion rootfs/standard/usr/share/mynode_apps/canary/canary.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Get instant notifications when your bitcoins move via ntfy push notifications.",
"Features include: transaction monitoring, RBF/CPFP detection, balance alerts, and deep wallet scanning."
],
"latest_version": "v1.4.0",
"latest_version": "v1.5.0",
"supported_archs": ["amd64", "arm64"],
"download_skip": true,
"requires_docker_image_installation": true,
Expand All @@ -29,6 +29,8 @@
"app_tile_name": "Canary",
"app_tile_running_status_text": "Monitoring",
"app_tile_default_status_text": "Wallet Monitor",
"app_tile_button_text": "Open",
"app_tile_button_href": "/app/canary/info",
"app_tile_button_open_app_directly": true,
"can_uninstall": true,
"can_reinstall": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,50 @@ set -e

echo "==================== INSTALLING APP ===================="

APP_DIR="/opt/mynode/canary"
VERSION="${VERSION:-v1.5.0}"
VERSION_FILE="/mnt/hdd/mynode/settings/canary_version"

write_compose_file() {
cat > "$APP_DIR/docker-compose.yml" <<EOF
version: "3.8"

services:
backend:
image: canary-backend:latest
network_mode: host
restart: unless-stopped
stop_grace_period: 30s
volumes:
- /mnt/hdd/mynode/canary:/app/data
env_file:
- /mnt/hdd/mynode/canary/canary.env
environment:
CANARY_DATA_DIR: /app/data
CANARY_ELECTRUM_URL: tcp://127.0.0.1:50001
CANARY_NETWORK: mainnet
CANARY_MODE: self-hosted
CANARY_BIND_ADDRESS: 127.0.0.1:3004

frontend:
image: canary-frontend:latest
network_mode: host
restart: unless-stopped
stop_grace_period: 30s
depends_on:
- backend
environment:
API_URL: http://127.0.0.1:3004
PORT: "3005"
EOF
}

mkdir -p /opt/mynode/canary || true
mkdir -p /mnt/hdd/mynode/canary || true

cp -f app_data/docker-compose.yml docker-compose.yml
write_compose_file

cd "$APP_DIR"
/usr/local/bin/docker-compose down --remove-orphans 2>/dev/null || true

remove_docker_images_by_name "canary-backend"
Expand All @@ -25,6 +64,10 @@ docker pull schjonhaug/canary-frontend:$VERSION
docker tag schjonhaug/canary-backend:$VERSION canary-backend:latest
docker tag schjonhaug/canary-frontend:$VERSION canary-frontend:latest

echo "$VERSION" > "$VERSION_FILE"
chown bitcoin:bitcoin "$VERSION_FILE"
touch /tmp/need_application_refresh

chown -R bitcoin:bitcoin /mnt/hdd/mynode/canary

echo "================== DONE INSTALLING APP ================="
70 changes: 66 additions & 4 deletions rootfs/standard/usr/share/mynode_apps/canary/scripts/pre_canary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,71 @@

set -e

# Keep the compose file in sync with the packaged app data.
cp -f app_data/docker-compose.yml docker-compose.yml
APP_DIR="/opt/mynode/canary"
DATA_DIR="/mnt/hdd/mynode/canary"
VERSION_FILE="/mnt/hdd/mynode/settings/canary_version"
VERSION="${VERSION:-$(cat "$VERSION_FILE" 2>/dev/null || echo v1.5.0)}"
ADMIN_PASSWORD_FILE="$DATA_DIR/admin_password"
JWT_SECRET_FILE="$DATA_DIR/jwt_secret"
ENV_FILE="$DATA_DIR/canary.env"

write_compose_file() {
mkdir -p "$APP_DIR"
cat > "$APP_DIR/docker-compose.yml" <<EOF
version: "3.8"

services:
backend:
image: canary-backend:latest
network_mode: host
restart: unless-stopped
stop_grace_period: 30s
volumes:
- /mnt/hdd/mynode/canary:/app/data
env_file:
- /mnt/hdd/mynode/canary/canary.env
environment:
CANARY_DATA_DIR: /app/data
CANARY_ELECTRUM_URL: tcp://127.0.0.1:50001
CANARY_NETWORK: mainnet
CANARY_MODE: self-hosted
CANARY_BIND_ADDRESS: 127.0.0.1:3004

frontend:
image: canary-frontend:latest
network_mode: host
restart: unless-stopped
stop_grace_period: 30s
depends_on:
- backend
environment:
API_URL: http://127.0.0.1:3004
PORT: "3005"
EOF
}

generate_secret() {
local length="$1"
tr -dc A-Za-z0-9 < /dev/urandom | head -c "$length"
}

write_compose_file

# Ensure data directory exists before starting.
mkdir -p /mnt/hdd/mynode/canary
chown -R bitcoin:bitcoin /mnt/hdd/mynode/canary
mkdir -p "$DATA_DIR"

if [ ! -s "$ADMIN_PASSWORD_FILE" ]; then
generate_secret 32 > "$ADMIN_PASSWORD_FILE"
fi

if [ ! -s "$JWT_SECRET_FILE" ]; then
generate_secret 64 > "$JWT_SECRET_FILE"
fi

cat > "$ENV_FILE" <<EOF
CANARY_SELF_HOSTED_ADMIN_PASSWORD=$(cat "$ADMIN_PASSWORD_FILE")
JWT_SECRET=$(cat "$JWT_SECRET_FILE")
EOF

chown -R bitcoin:bitcoin "$DATA_DIR"
chmod 600 "$ADMIN_PASSWORD_FILE" "$JWT_SECRET_FILE" "$ENV_FILE"
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@ set -x

echo "==================== UNINSTALLING APP ===================="

cp -f app_data/docker-compose.yml docker-compose.yml 2>/dev/null || true
APP_DIR="/opt/mynode/canary"
VERSION_FILE="/mnt/hdd/mynode/settings/canary_version"

remove_canary_images() {
docker images --format '{{.Repository}}:{{.Tag}}' \
| grep -E '^(canary-backend|canary-frontend|schjonhaug/canary-backend|schjonhaug/canary-frontend):' \
| xargs -r docker rmi 2>/dev/null || true
}

cp -f "$APP_DIR/app_data/docker-compose.yml" "$APP_DIR/docker-compose.yml" 2>/dev/null || true
cd "$APP_DIR" 2>/dev/null || true
/usr/local/bin/docker-compose down --remove-orphans 2>/dev/null || true


remove_docker_images_by_name "canary-backend"
remove_docker_images_by_name "canary-frontend"
remove_canary_images

rm -f "$VERSION_FILE"
rm -rf /mnt/hdd/mynode/canary
touch /tmp/need_application_refresh

echo "================== DONE UNINSTALLING APP ================="
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,38 @@
from user_management import check_logged_in
from application_info import get_application, get_application_status, get_application_status_color
from device_info import read_ui_settings
import os


mynode_canary = Blueprint("mynode_canary", __name__)

CANARY_PASSWORD_FILE = "/mnt/hdd/mynode/canary/admin_password"
CANARY_VERSION_FILE = "/mnt/hdd/mynode/settings/canary_version"


def get_canary_password():
if not os.path.isfile(CANARY_PASSWORD_FILE):
return ""
with open(CANARY_PASSWORD_FILE, "r") as password_file:
return password_file.read().strip()


def get_canary_current_version():
if not os.path.isfile(CANARY_VERSION_FILE):
return None
with open(CANARY_VERSION_FILE, "r") as version_file:
return version_file.read().strip()[0:16]


@mynode_canary.route("/info")
def canary_page():
check_logged_in()

app = get_application("canary")
current_version = get_canary_current_version()
if current_version:
app["current_version"] = current_version

app_status = get_application_status("canary")
app_status_color = get_application_status_color("canary")

Expand All @@ -21,5 +43,7 @@ def canary_page():
"app_status": app_status,
"app_status_color": app_status_color,
"app": app,
"canary_username": "admin@local",
"canary_password": get_canary_password(),
}
return render_template("/app/generic_app.html", **template_data)
return render_template("/app/canary/canary.html", **template_data)
Loading