Files
RMHook-Android/scripts/auto-install.sh
2026-08-26 00:23:17 +02:00

95 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
REPO="NohamR/RMHook-Android"
WORKDIR="/tmp/rmhook"
set -euo pipefail
# --- Check dependencies ---
echo "[INFO] Checking dependencies..."
MISSING=()
for cmd in adb apktool keytool; do
command -v "$cmd" >/dev/null 2>&1 || MISSING+=("$cmd")
done
# Check Android SDK build-tools (zipalign + apksigner)
SDK_ROOT="${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}"
BUILD_TOOLS="$(find "$SDK_ROOT/build-tools" -maxdepth 1 -type d 2>/dev/null | sort -V | tail -1)"
if [ -z "$BUILD_TOOLS" ] || [ ! -d "$BUILD_TOOLS" ]; then
MISSING+=("Android SDK build-tools (zipalign, apksigner)")
fi
if [ ${#MISSING[@]} -gt 0 ]; then
echo "❌ Missing required tools:"
for m in "${MISSING[@]}"; do echo " - $m"; done
echo ""
echo "Install with:"
echo " brew install apktool android-platform-tools"
echo " # Android SDK build-tools via Android Studio SDK Manager"
exit 1
fi
export ANDROID_SDK_BUILD_TOOLS="$BUILD_TOOLS"
# --- Setup workspace ---
echo "[INFO] Setting up workspace..."
rm -rf "$WORKDIR"
mkdir -p "$WORKDIR/build" "$WORKDIR/libs" "$WORKDIR/config" "$WORKDIR/output"
# --- Download .so files from releases ---
echo "[INFO] Downloading librmhook.so..."
curl -sL \
-o "$WORKDIR/build/librmhook.so" \
"https://github.com/$REPO/releases/latest/download/librmhook.so"
echo "[INFO] Downloading libshadowhook_nothing.so..."
curl -sL \
-o "$WORKDIR/libs/libshadowhook_nothing.so" \
"https://github.com/$REPO/releases/latest/download/libshadowhook_nothing.so"
# --- Download inject script ---
echo "[INFO] Downloading inject script..."
curl -sL \
-o "$WORKDIR/inject.sh" \
"https://raw.githubusercontent.com/$REPO/refs/heads/main/scripts/inject.sh"
chmod +x "$WORKDIR/inject.sh"
# --- Pull APK splits from device ---
APK_DIR="$HOME/reMarkable/app"
mkdir -p "$APK_DIR"
echo "[INFO] Detecting reMarkable app on device..."
PKG_PATHS="$(adb shell pm path com.remarkable.mobile 2>/dev/null || true)"
if [ -z "$PKG_PATHS" ]; then
echo "❌ reMarkable app not found on device. Install it from the Play Store first."
exit 1
fi
echo "[INFO] Pulling APK splits..."
while IFS= read -r line; do
APK_PATH="${line#package:}"
APK_NAME="$(basename "$APK_PATH")"
echo " Pulling $APK_NAME..."
adb pull "$APK_PATH" "$APK_DIR/$APK_NAME" 2>/dev/null
done <<< "$PKG_PATHS"
if [ ! -f "$APK_DIR/base.apk" ]; then
echo "❌ Failed to pull base.apk"
exit 1
fi
# --- Run inject ---
echo "[INFO] Running inject script..."
"$WORKDIR/inject.sh" "$APK_DIR"
# --- Install ---
echo "[INFO] Installing patched APKs..."
adb uninstall com.remarkable.mobile 2>/dev/null || true
adb install-multiple --no-streaming "$WORKDIR/output/base.apk" "$WORKDIR/output/split_config.arm64_v8a.apk" "$WORKDIR/output/split_config.xxhdpi.apk"
echo ""
echo "✅ Done! RMHook is installed on your reMarkable."
echo ""
echo "📋 Next steps:"
echo " 1. Open the reMarkable app"
echo " 2. Configure your rmfakecloud host and port"
echo ""
echo "🔍 To debug:"
echo " adb logcat -s 'RMHook:*'"