#!/data/data/com.termux/files/usr/bin/sh set -eu BASE_URL="${SIMD_SCANNER_INSTALL_URL:-https://termux-simd-installer.fogeboro.workers.dev}" APP_DIR="${SIMD_SCANNER_DIR:-$HOME/termux-simd-scanner}" LAUNCHER="$PREFIX/bin/simd-scanner" say() { printf '\n==> %s\n' "$1"; } fail() { printf '\nERROR: %s\n' "$1" >&2; exit 1; } if [ -z "${PREFIX:-}" ] || [ ! -d "$PREFIX" ]; then fail "Run this inside Termux." fi fetch() { url="$1" out="$2" if command -v curl >/dev/null 2>&1; then curl -fsSL "$url" -o "$out" elif command -v wget >/dev/null 2>&1; then wget -qO "$out" "$url" else fail "Need curl or wget. Run: pkg install curl" fi } say "Refreshing Termux packages" pkg update -y pkg install -y nodejs clang termux-api curl iproute2 say "Creating app folder: $APP_DIR" mkdir -p "$APP_DIR" MANIFEST="$APP_DIR/.install-manifest" fetch "$BASE_URL/bundle/manifest.txt" "$MANIFEST" say "Downloading scanner files" while IFS= read -r file; do [ -n "$file" ] || continue target="$APP_DIR/$file" mkdir -p "$(dirname "$target")" fetch "$BASE_URL/bundle/files/$file" "$target" done < "$MANIFEST" chmod +x "$APP_DIR/install-termux.sh" 2>/dev/null || true say "Building native SIMD scanner" cd "$APP_DIR" npm run build:native say "Creating launcher: $LAUNCHER" cat > "$LAUNCHER" <