From c3494e338f39a42eddc9b52a7db75fb428199388 Mon Sep 17 00:00:00 2001 From: Paul Beltrani Date: Sun, 9 Mar 2025 22:27:48 -0400 Subject: [PATCH] Merge install scripts into a single, isntall.sh --- dist/install-linux.sh | 23 ------------ dist/install-mac.sh | 22 ------------ dist/{install-common.sh => install.sh} | 50 ++++++++++++++++++-------- 3 files changed, 36 insertions(+), 59 deletions(-) delete mode 100755 dist/install-linux.sh delete mode 100755 dist/install-mac.sh rename dist/{install-common.sh => install.sh} (69%) diff --git a/dist/install-linux.sh b/dist/install-linux.sh deleted file mode 100755 index 55204ab..0000000 --- a/dist/install-linux.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/env bash - -set -e -export SERIAL_PATH="./serial-ubuntu-latest/serial" - -if [ ! -x "$SERIAL_PATH" ]; then - echo "The serial binary cannot be found at $SERIAL_PATH. If you are running this from the git tree please instead run it from the latest release bundle https://github.com/EFForg/rayhunter/releases" - exit 1 -fi - -if ! command -v adb &> /dev/null; then - if [ ! -d ./platform-tools ] ; then - echo "adb not found, downloading local copy" - curl -O "https://dl.google.com/android/repository/platform-tools-latest-linux.zip" - unzip platform-tools-latest-linux.zip - fi - export ADB="./platform-tools/adb" -else - export ADB=`which adb` -fi - -. "$(dirname "$0")"/install-common.sh -install diff --git a/dist/install-mac.sh b/dist/install-mac.sh deleted file mode 100755 index 24dacdd..0000000 --- a/dist/install-mac.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -export SERIAL_PATH="./serial-macos-latest/serial" -if [ ! -x "$SERIAL_PATH" ]; then - echo "The serial binary cannot be found at $SERIAL_PATH. If you are running this from the git tree please instead run it from the latest release bundle at https://github.com/EFForg/rayhunter/releases" - exit 1 -fi - -if ! command -v adb &> /dev/null; then - if [ ! -d ./platform-tools ]; then - echo "adb not found, downloading local copy" - curl -O "https://dl.google.com/android/repository/platform-tools-latest-darwin.zip" - unzip platform-tools-latest-darwin.zip - fi - export ADB="./platform-tools/adb" -else - export ADB=`which adb` -fi - -. "$(dirname "$0")"/install-common.sh -install diff --git a/dist/install-common.sh b/dist/install.sh similarity index 69% rename from dist/install-common.sh rename to dist/install.sh index 60b194a..e70ea40 100755 --- a/dist/install-common.sh +++ b/dist/install.sh @@ -1,18 +1,5 @@ #!/usr/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 - if [[ -z "${ADB}" ]]; then - echo "\$ADB not set, did you run this from install-linux.sh or install-mac.sh?" - exit 1 - fi - force_debug_mode - setup_rootshell - setup_rayhunter - test_rayhunter -} +set -e force_debug_mode() { echo "Using adb at $ADB" @@ -108,3 +95,38 @@ test_rayhunter() { done echo "timeout reached! failed to reach rayhunter url $URL, something went wrong :(" } + +##### ##### ##### +##### Main ##### +##### ##### ##### +if [ `uname -s` = "Linux" ]; then + export SERIAL_PATH="./serial-ubuntu-latest/serial" + export PLATFORM_TOOLS="platform-tools-latest-linux.zip" +elif [ `uname -s` = "Darwin" ]; then + export SERIAL_PATH="./serial-macos-latest/serial" + export PLATFORM_TOOLS="platform-tools-latest-darwin.zip" +else + echo "This script only supports Linux or macOS" + exit 1 +fi + +if [ ! -x "$SERIAL_PATH" ]; then + echo "The serial binary cannot be found at $SERIAL_PATH. If you are running this from the git tree please instead run it from the latest release bundle https://github.com/EFForg/rayhunter/releases" + exit 1 +fi + +if ! command -v adb &> /dev/null; then + if [ ! -d ./platform-tools ] ; then + echo "adb not found, downloading local copy" + curl -O "https://dl.google.com/android/repository/${PLATFORM_TOOLS}" + unzip $PLATFORM_TOOLS + fi + export ADB="./platform-tools/adb" +else + export ADB=`which adb` +fi + +force_debug_mode +setup_rootshell +setup_rayhunter +test_rayhunter