From c199923e16a72768c02e378b75f9235813826c0f Mon Sep 17 00:00:00 2001 From: grdddj Date: Mon, 30 Sep 2024 17:35:35 +0200 Subject: [PATCH] feat: download and update node bridge from Suite dev server --- .gitignore | 1 + docker/Dockerfile-debian | 1 + src/binaries/node-bridge/download.sh | 13 ++++++++++++ .../node-bridge/modify_node_bin_js.sh | 21 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100755 src/binaries/node-bridge/download.sh create mode 100755 src/binaries/node-bridge/modify_node_bin_js.sh diff --git a/.gitignore b/.gitignore index 817a20f..92e2931 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ src/binaries/firmware/bin/* !src/binaries/firmware/bin/patch-bin.sh !src/binaries/firmware/bin/arm !src/binaries/trezord-go/bin/download.sh +src/binaries/node-bridge/bin.js emulator.img .vscode .mypy_cache diff --git a/docker/Dockerfile-debian b/docker/Dockerfile-debian index dd1cdde..165d962 100644 --- a/docker/Dockerfile-debian +++ b/docker/Dockerfile-debian @@ -47,6 +47,7 @@ RUN poetry install --no-dev --no-root # Execute scripts and clean up RUN ./src/binaries/firmware/bin/download.sh RUN ./src/binaries/trezord-go/bin/download.sh +RUN ./src/binaries/node-bridge/download.sh # Patch emulator binaries RUN cd src/binaries/firmware/bin && ./patch-bin.sh diff --git a/src/binaries/node-bridge/download.sh b/src/binaries/node-bridge/download.sh new file mode 100755 index 0000000..5ad3e10 --- /dev/null +++ b/src/binaries/node-bridge/download.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e + +HERE=$(dirname $(readlink -f $0)) + +FILE_NAME="bin.js" +FILE_LOCATION="$HERE/$FILE_NAME" +BRANCH="develop" +URL="https://dev.suite.sldev.cz/transport-bridge/$BRANCH/dist/$FILE_NAME" + +# Downloading and modifying node bridge bin.js file +curl -L $URL -o "$FILE_LOCATION" || echo "Failed to download $FILE_NAME" +"$HERE/modify_node_bin_js.sh" "$FILE_LOCATION" || echo "Failed to modify $FILE_NAME" diff --git a/src/binaries/node-bridge/modify_node_bin_js.sh b/src/binaries/node-bridge/modify_node_bin_js.sh new file mode 100755 index 0000000..2ceee90 --- /dev/null +++ b/src/binaries/node-bridge/modify_node_bin_js.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Please supply the path to the file to modify" + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "Error: File '$1' not found." + exit 1 +fi + +# Getting rid of USB import, which is not needed when we will spawn in with UDP argument +string_to_comment='^var import_usb =' +if grep -q "$string_to_comment" "$1"; then + sed -i "/$string_to_comment/ s/^/\/\//" "$1" + echo "Success: line matching '$string_to_comment' was commented out." +else + echo "Error: no line matching '$string_to_comment' found in '$1'." + exit 1 +fi