From dc5c80048d45c327db2e1d4da00616be722de03b Mon Sep 17 00:00:00 2001 From: Will Greenberg Date: Wed, 22 May 2024 12:33:47 -0700 Subject: [PATCH] wip --- .github/workflows/build-release.yml | 32 +++++++++---- dist/install-common.sh | 56 ++++++++++++++++++++++ dist/install-linux.sh | 6 +++ dist/install-mac.sh | 6 +++ dist/install-windows.bat | 1 + {scripts => dist/scripts}/misc-daemon | 0 {scripts => dist/scripts}/rayhunter_daemon | 0 7 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 dist/install-common.sh create mode 100644 dist/install-linux.sh create mode 100644 dist/install-mac.sh create mode 100644 dist/install-windows.bat rename {scripts => dist/scripts}/misc-daemon (100%) rename {scripts => dist/scripts}/rayhunter_daemon (100%) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 00a719f..5c58038 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -16,11 +16,12 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build serial - run: cargo build --bin serial --release + run: cargo build --target-dir ./ --bin serial --release - uses: actions/upload-artifact@v4 with: name: serial-${{ matrix.os }} - path: target/release/serial + path: ./serial + if-no-files-found: error build_rootshell_and_rayhunter: runs-on: ubuntu-latest steps: @@ -31,10 +32,11 @@ jobs: - name: Install cross-compilation dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: build-essential \ - libc6-armhf-cross \ - libc6-dev-armhf-cross \ - gcc-arm-linux-gnueabihf + packages: + - build-essential + - libc6-armhf-cross + - libc6-dev-armhf-cross + - gcc-arm-linux-gnueabihf version: 1.0 - name: Build rootshell (arm32) run: cargo build --bin rootshell --target armv7-unknown-linux-gnueabihf --release @@ -44,10 +46,12 @@ jobs: with: name: rootshell path: target/armv7-unknown-linux-gnueabihf/release/rootshell + if-no-files-found: error - uses: actions/upload-artifact@v4 with: name: rayhunter-daemon path: target/armv7-unknown-linux-gnueabihf/release/rayhunter-daemon + if-no-files-found: error package_platform_zips: needs: - build_serial @@ -57,6 +61,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/download-artifact@v4 with: - path: artifacts - - name: ls -R - run: ls -R artifacts + path: dist + - name: Archive release + uses: thedoctor0/zip-release@0.7.5 + with: + type: 'zip' + filename: 'release.zip' + directory: 'dist' + - name: Upload release + uses: actions/upload-artifact@v4 + with: + name: release.zip + path: release.zip + if-no-files-found: error diff --git a/dist/install-common.sh b/dist/install-common.sh new file mode 100644 index 0000000..7e7fc32 --- /dev/null +++ b/dist/install-common.sh @@ -0,0 +1,56 @@ +#!/bin/env bash + +install() { + if [[ -z "${SERIAL_PATH}" ]]; then + echo "SERIAL_PATH not set, did you run this from install-linux.sh or install-mac.sh?" + exit 1 + fi + check_adb + force_debug_mode + setup_rootshell + setup_rayhunter +} + +check_adb() { + if ! command -v adb &> /dev/null + then + echo "adb not found, please ensure it's installed or check the README.md" + exit 1 + fi +} + +force_debug_mode() { + # Force a switch into the debug mode to enable ADB + $(SERIAL_PATH) AT + echo -n "adb enabled, waiting for reboot" + until adb shell true 2> /dev/null + do + echo -n . + sleep 1 + done + echo + echo "it's alive!" +} + +setup_rootshell() { + adb push target/armv7-unknown-linux-gnueabihf/release/rootshell /tmp/ + $(SERIAL_PATH) "AT+SYSCMD=mv /tmp/rootshell /bin/rootshell" + sleep 1 + $(SERIAL_PATH) "AT+SYSCMD=chown root /bin/rootshell" + sleep 1 + $(SERIAL_PATH) "AT+SYSCMD=chmod 4755 /bin/rootshell" + echo "we have root!" + adb shell /bin/rootshell -c id +} + +setup_rayhunter() { + adb shell '/bin/rootshell -c "mkdir /data/rayhunter"' + adb push config.toml.example /data/rayhunter/config.toml + adb push scripts/rayhunter_daemon /tmp/rayhunter_daemon + adb push scripts/misc-daemon /tmp/misc-daemon + adb shell '/bin/rootshell -c "mv /tmp/rayhunter_daemon /etc/init.d/rayhunter_daemon"' + adb shell '/bin/rootshell -c "mv /tmp/misc-daemon /etc/init.d/misc-daemon"' + adb shell '/bin/rootshell -c "chmod 755 /etc/init.d/rayhunter_daemon"' + adb shell '/bin/rootshell -c "chmod 755 /etc/init.d/misc-daemon"' + adb shell '/bin/rootshell -c "/etc/init.d/rayhunter_daemon start"' +} diff --git a/dist/install-linux.sh b/dist/install-linux.sh new file mode 100644 index 0000000..b188f9c --- /dev/null +++ b/dist/install-linux.sh @@ -0,0 +1,6 @@ +#!/bin/env bash + +set -e +export SERIAL_PATH="./serial-ubuntu-latest/serial" +. "$(dirname "$0")"/install-common.sh +install diff --git a/dist/install-mac.sh b/dist/install-mac.sh new file mode 100644 index 0000000..90c6064 --- /dev/null +++ b/dist/install-mac.sh @@ -0,0 +1,6 @@ +#!/bin/env bash + +set -e +export SERIAL_PATH="./serial-mac-latest/serial" +. "$(dirname "$0")"/install-common.sh +install diff --git a/dist/install-windows.bat b/dist/install-windows.bat new file mode 100644 index 0000000..05276bc --- /dev/null +++ b/dist/install-windows.bat @@ -0,0 +1 @@ +ECHO TODO diff --git a/scripts/misc-daemon b/dist/scripts/misc-daemon similarity index 100% rename from scripts/misc-daemon rename to dist/scripts/misc-daemon diff --git a/scripts/rayhunter_daemon b/dist/scripts/rayhunter_daemon similarity index 100% rename from scripts/rayhunter_daemon rename to dist/scripts/rayhunter_daemon