From 4edd86d0e470628d629211d6fbd572d546507061 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 23:37:39 +0000 Subject: [PATCH 01/14] Add automation for ThinkOrSwim installation and update dependencies --- Dockerfile | 11 ++++-- Makefile | 4 +++ thinkorswim_expect_script.sh | 69 ++++++++++++++++++++++++++++++++++++ tos.desktop | 9 +++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100755 thinkorswim_expect_script.sh create mode 100755 tos.desktop diff --git a/Dockerfile b/Dockerfile index 5f087c8..7efea95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,17 @@ FROM lscr.io/linuxserver/webtop:ubuntu-mate # Install OpenJDK 21 (or your required version) RUN sudo apt-get update && \ - sudo apt-get install -y openjdk-21-jdk && \ + sudo apt-get install -y openjdk-21-jdk expect && \ sudo apt-get clean && \ sudo rm -rf /var/lib/apt/lists/* # Add ThinkSwim installer RUN curl -o /tmp/thinkorswim_installer.sh https://tosmediaserver.schwab.com/installer/InstFiles/thinkorswim_installer.sh -RUN chmod +x /tmp/thinkorswim_installer.sh \ No newline at end of file +RUN chmod +x /tmp/thinkorswim_installer.sh + +# Automate ThinkOrSwim installation +ADD thinkorswim_expect_script.sh /tmp +RUN chmod +x /tmp/thinkorswim_expect_script.sh +ADD tos.desktop /etc/xdg/autostart +RUN sudo chmod +x /etc/xdg/autostart/tos.desktop +# RUN sudo chown 1000:1000 /etc/xdg/autostart/tos.desktop diff --git a/Makefile b/Makefile index df7ad63..43c946b 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,10 @@ BACKUP_DIR=./backup download-thinkswim-installer: curl -O https://tosmediaserver.schwab.com/installer/InstFiles/thinkorswim_installer.sh +install-dev-dependencies: + sudo apt-get update + sudo apt-get install -y expect openjdk-21-jre + start: docker compose up -d docker compose logs -f diff --git a/thinkorswim_expect_script.sh b/thinkorswim_expect_script.sh new file mode 100755 index 0000000..3b32cf5 --- /dev/null +++ b/thinkorswim_expect_script.sh @@ -0,0 +1,69 @@ +#!/usr/bin/expect -f + +# Set a timeout for commands (in seconds) +set timeout 5 + +# The path to your installer script +set INSTALLER_SCRIPT "/tmp/thinkorswim_installer.sh" +set FOLDER_PATH "/config/thinkorswim" + +# Use Tcl's 'file exist' command to check if the path exists AND +# 'file isdirectory' to ensure it is specifically a directory. +if {[file exist $FOLDER_PATH] && [file isdirectory $FOLDER_PATH]} { + # The folder exists and is a directory. Exit the script. + puts "ToS Desktop is already installed. Exiting script." + exit 0 +} else { + puts "ToS Desktop is not installed. Proceeding with installation." +} + +# 1. Start the installer in console mode (-c) +spawn sh $INSTALLER_SCRIPT -c + +# 2. Respond to "Please select a language:" +# Expected: "3: English [Enter]" +expect "\[1 - 3\]" +send "3\r" + +# 3. Respond to "OK [o, Enter], Cancel [c]" +# Expected: "OK [o, Enter]" +expect "Cancel \[c\]" +send "o\r" + +# 4. Respond to "Please select your account provider" +# Expected: "Schwab [1, Enter]" +expect "thinkorswim Guest Pass - 30 days trial account \[2\]" +send "1\r" + +# 5. Respond to "I acknowledge, continue with installation. [1], I do not agree; cancel installation. [2, Enter]" +# Expected: "I acknowledge, continue with installation. [1]" +expect "\[2, Enter\]" +send "1\r" + +# 6. Respond to "For which users shall thinkorswim be installed?" +# Expected: "Install for all users of this machine [2]" +expect "Install for all users of this machine \[2\]" +send "2\r" + +# 7. Respond to "Where should thinkorswim be installed?" +# Expected: "[/config/thinkorswim]" and custom path /tmp/thinkorswim +expect "\[/config/thinkorswim\]" +send "/config/thinkorswim\r" + +# 8. Respond to "Create desktop icon?" +# Expected: "Yes [y, Enter]" +expect "No \[n\]" +send "\r" + +# Wait for the "Extracting files ..." and "Setup has finished" lines +expect "Setup has finished installing thinkorswim on your computer." + +# 9. Respond to "Run thinkorswim?" +# Expected: "No [n]" +expect "No \[n\]" +send "y\r" + +# Wait for the script to finish and the prompt to return +expect eof + +puts "ToS Desktop installation done..." \ No newline at end of file diff --git a/tos.desktop b/tos.desktop new file mode 100755 index 0000000..987aaf4 --- /dev/null +++ b/tos.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Exec=bash -c "/tmp/thinkorswim_expect_script.sh > /tmp/tos-install.log" +Hidden=false +Name[en_US]=ToS Desktop Installer +Name=ToS Desktop Installer +Comment[en_US]=Install ToS Desktop if it has not installed +Comment=Install ToS Desktop if it has not installed +X-MATE-Autostart-Delay=0 \ No newline at end of file From f49df1717cb3858937df8985debc8ebecf0c1d32 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 19:27:02 -0700 Subject: [PATCH 02/14] Create docker folder --- docker | 1 + 1 file changed, 1 insertion(+) create mode 100644 docker diff --git a/docker b/docker new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docker @@ -0,0 +1 @@ + From f9bc7af4d3df81dc4a5660f26e96aeabdea4bdf4 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 19:27:25 -0700 Subject: [PATCH 03/14] Delete docker --- docker | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docker diff --git a/docker b/docker deleted file mode 100644 index 8b13789..0000000 --- a/docker +++ /dev/null @@ -1 +0,0 @@ - From e878cfd3439e48b5e85ac436629836134104e3c7 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 19:30:25 -0700 Subject: [PATCH 04/14] Add GitHub Actions workflow for Docker image build --- .github/workflows/docker-publish.yml | 103 +++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..e4c3974 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,103 @@ +name: Build and Push Docker Image + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [ published ] + workflow_dispatch: + inputs: + manual_push: + description: 'Set to "yes" to push tag :test image to GHCR for testing before merging to main' + required: false + default: 'no' + type: choice + options: + - 'no' + - 'yes' + +jobs: + + build-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Docker image + run: | + docker build -f ./Dockerfile -t tos-webtop:test . + + - name: Test Docker image + run: | + docker run --rm tos-webtop:test > /tmp/test.log || true + + if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then + echo "Build successful" + else + echo "Build failed!" + exit 1 + fi + + push-to-ghcr: + runs-on: ubuntu-latest + # Run if on main branch, or if manual_push is yes from workflow_dispatch + if: >- + (github.ref == 'refs/heads/main') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.manual_push == 'yes') + needs: build-test + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # 👆 This is needed ARM emulation on AMD64 runner + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + # 👆 This is need for QEMU to work + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set lowercase repository name + run: | + echo "LOWERCASE_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Set IMAGE_TAG for build-test + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.manual_push }}" = "yes" ]; then + echo "IMAGE_TAG=test" >> $GITHUB_ENV + elif [ "${{ github.ref }}" = "refs/heads/main" ]; then + echo "IMAGE_TAG=latest" >> $GITHUB_ENV + fi + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ env.LOWERCASE_REPO }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + file: ./Dockerfile + push: true + tags: | + ghcr.io/${{ env.LOWERCASE_REPO }}:${{ env.IMAGE_TAG }} + ghcr.io/${{ env.LOWERCASE_REPO }}:${{ github.sha }} + labels: ${{ steps.meta.outputs.labels }} From c30caf88a4ce5044c338978652cec67ef7296951 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 19:33:38 -0700 Subject: [PATCH 05/14] Change OpenJDK installation from JDK to JRE to save space --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7efea95..de611cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM lscr.io/linuxserver/webtop:ubuntu-mate # Install OpenJDK 21 (or your required version) RUN sudo apt-get update && \ - sudo apt-get install -y openjdk-21-jdk expect && \ + sudo apt-get install -y openjdk-21-jre expect && \ sudo apt-get clean && \ sudo rm -rf /var/lib/apt/lists/* From 9fc3e6762e08be03e2229b586c480927ed89b7a3 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 03:23:12 +0000 Subject: [PATCH 06/14] move files --- .github/workflows/docker-publish.yml | 8 +++++++- Makefile | 2 +- Dockerfile => docker/Dockerfile | 0 .../thinkorswim_expect_script.sh | 0 tos.desktop => docker/tos.desktop | 0 5 files changed, 8 insertions(+), 2 deletions(-) rename Dockerfile => docker/Dockerfile (100%) rename thinkorswim_expect_script.sh => docker/thinkorswim_expect_script.sh (100%) rename tos.desktop => docker/tos.desktop (100%) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e4c3974..a2537d6 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -3,8 +3,14 @@ name: Build and Push Docker Image on: push: branches: [ main ] + paths: + - 'docker/**' + pull_request: branches: [ main ] + paths: + - 'docker/**' + release: types: [ published ] workflow_dispatch: @@ -95,7 +101,7 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - file: ./Dockerfile + file: ./docker/Dockerfile push: true tags: | ghcr.io/${{ env.LOWERCASE_REPO }}:${{ env.IMAGE_TAG }} diff --git a/Makefile b/Makefile index 43c946b..750a534 100644 --- a/Makefile +++ b/Makefile @@ -64,4 +64,4 @@ restore: docker compose up -d docker-build: - docker build -t $(DOCKER_IMAGE_NAME) . + docker build -t $(DOCKER_IMAGE_NAME) -f ./docker/Dockerfile ./docker diff --git a/Dockerfile b/docker/Dockerfile similarity index 100% rename from Dockerfile rename to docker/Dockerfile diff --git a/thinkorswim_expect_script.sh b/docker/thinkorswim_expect_script.sh similarity index 100% rename from thinkorswim_expect_script.sh rename to docker/thinkorswim_expect_script.sh diff --git a/tos.desktop b/docker/tos.desktop similarity index 100% rename from tos.desktop rename to docker/tos.desktop From 69f5b462cc15aa0a137031cda626ed32745d2d37 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 20:25:20 -0700 Subject: [PATCH 07/14] Update Docker publish workflow to modify test script Comment out MongoDB connection check in Docker test. --- .github/workflows/docker-publish.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a2537d6..aaceee2 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,13 +40,14 @@ jobs: - name: Test Docker image run: | docker run --rm tos-webtop:test > /tmp/test.log || true + cat /tmp/test.log - if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then - echo "Build successful" - else - echo "Build failed!" - exit 1 - fi + # if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then + # echo "Build successful" + # else + # echo "Build failed!" + # exit 1 + # fi push-to-ghcr: runs-on: ubuntu-latest @@ -99,7 +100,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v6 with: - context: . + context: ./docker platforms: linux/amd64,linux/arm64 file: ./docker/Dockerfile push: true From d52819f4c239db66430b792dac7207b9871700b1 Mon Sep 17 00:00:00 2001 From: gitricko Date: Mon, 27 Oct 2025 20:26:50 -0700 Subject: [PATCH 08/14] Update Docker build context and Dockerfile path --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index aaceee2..f10d5e9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -35,7 +35,7 @@ jobs: - name: Build Docker image run: | - docker build -f ./Dockerfile -t tos-webtop:test . + docker build -f ./docker/Dockerfile -t tos-webtop:test ./docker - name: Test Docker image run: | From e0540b2dcaa144965dc8c1a1a5edcd603b54d095 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:02:30 -0700 Subject: [PATCH 09/14] Update webtop image to use environment variable --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3257975..3565649 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ name: tos-webtop services: webtop: # Uses the specific Ubuntu-based MATE tag from LinuxServer.io - image: tos-webtop:latest + image: ${DOCKER_URI:-ghcr.io/gitricko/tos-webtop:latest} container_name: webtop-mate # Optional: Needed for some modern GUI apps to function properly on older hosts/kernels @@ -46,4 +46,4 @@ networks: volumes: tos-webtop-config: external: false - name: tos-webtop-config \ No newline at end of file + name: tos-webtop-config From 93c008e23262aa7605ddc709776a29961f5b036c Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:03:22 -0700 Subject: [PATCH 10/14] Add DOCKER_URI environment variable for Docker build --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f10d5e9..43ef457 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -35,7 +35,7 @@ jobs: - name: Build Docker image run: | - docker build -f ./docker/Dockerfile -t tos-webtop:test ./docker + DOCKER_URI=tos-webtop docker build -f ./docker/Dockerfile -t tos-webtop:test ./docker - name: Test Docker image run: | From 524b0edf444117b8ce54f696b635503c12f243ca Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:05:04 -0700 Subject: [PATCH 11/14] Comment out log output in Docker test step Comment out the log output for Docker image test. --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 43ef457..e561b8f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: - name: Test Docker image run: | docker run --rm tos-webtop:test > /tmp/test.log || true - cat /tmp/test.log + # cat /tmp/test.log # if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then # echo "Build successful" From 09c62e30d6880ddddf08eb7c3725dd68e851f0ec Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:09:43 -0700 Subject: [PATCH 12/14] Update Docker image test logic in workflow --- .github/workflows/docker-publish.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e561b8f..4e2b7e5 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -39,15 +39,15 @@ jobs: - name: Test Docker image run: | - docker run --rm tos-webtop:test > /tmp/test.log || true - # cat /tmp/test.log + docker run --rm tos-webtop:test > /tmp/test.log & + sleep 10 - # if grep -q "CONNECTING TO MONGODB" /tmp/test.log; then - # echo "Build successful" - # else - # echo "Build failed!" - # exit 1 - # fi + if grep -q "Data WebSocket Server listening on port 8082" /tmp/test.log; then + echo "Build successful" + else + echo "Build failed!" + exit 1 + fi push-to-ghcr: runs-on: ubuntu-latest From 07ede2fa2f0841e0ee43a09b4e0a2e2ec75b967c Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:15:17 -0700 Subject: [PATCH 13/14] Extend sleep duration in Docker image test Increased sleep duration to allow more time for the Docker image to start before testing. --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4e2b7e5..13afeea 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -40,7 +40,7 @@ jobs: - name: Test Docker image run: | docker run --rm tos-webtop:test > /tmp/test.log & - sleep 10 + sleep 60 if grep -q "Data WebSocket Server listening on port 8082" /tmp/test.log; then echo "Build successful" From a70a1b42487025f028114bce91edb335b2cc082c Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 28 Oct 2025 05:19:08 -0700 Subject: [PATCH 14/14] Comment out build check in docker-publish.yml Comment out the build success/failure check in the Docker publish workflow. --- .github/workflows/docker-publish.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 13afeea..1123bea 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -42,12 +42,12 @@ jobs: docker run --rm tos-webtop:test > /tmp/test.log & sleep 60 - if grep -q "Data WebSocket Server listening on port 8082" /tmp/test.log; then - echo "Build successful" - else - echo "Build failed!" - exit 1 - fi + # if grep -q "Data WebSocket Server listening on port 8082" /tmp/test.log; then + # echo "Build successful" + # else + # echo "Build failed!" + # exit 1 + # fi push-to-ghcr: runs-on: ubuntu-latest