Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07c85d0016 | ||
|
|
f0b8ce9f20 | ||
|
|
fd6fb8fc18 | ||
|
|
cfa4c0f72c | ||
|
|
421956a704 | ||
|
|
91fe3880fa | ||
|
|
6f872c5ca4 |
No files matched your search
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: "🐛 Bug Report (RTX⚡)"
|
||||
about: "Report a technical issue with OpenClaw-On-Android."
|
||||
title: "[BUG] "
|
||||
labels: ["bug", "triage"]
|
||||
assignees: []
|
||||
|
||||
---
|
||||
|
||||
## 🛑 Describe the Bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## ⚙️ RTX⚡ Environment Details
|
||||
- **OCA Version**: [e.g., v010426]
|
||||
- **Android Device/VM**: [e.g., Pixel 7 / Termux 0.118]
|
||||
- **Tier Affected**: [RTX⚡1 / RTX⚡2 / RTX⚡3]
|
||||
- **Command Used**: [e.g., `oca health` or `ocaupdate`]
|
||||
|
||||
## 🚀 To Reproduce
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Error: '....'
|
||||
|
||||
## 📊 Expected Behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
## 📸 Screenshots
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
## 📝 Additional Context
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: "💡 Support & Discussions"
|
||||
url: "https://github.com/PsProsen-Dev/OpenClaw-On-Android/discussions"
|
||||
about: "For support, questions, and general community talk."
|
||||
- name: "⚡ GitHub Discussions (New Ideas)"
|
||||
url: "https://github.com/PsProsen-Dev/OpenClaw-On-Android/discussions/new?category=ideas"
|
||||
about: "Propose new Tier-level upgrades or Arsenal tools."
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: "🚀 Feature Request (RTX⚡)"
|
||||
about: "Suggest an improvement or new feature for OpenClaw-On-Android."
|
||||
title: "[FEATURE] "
|
||||
labels: ["enhancement", "planning"]
|
||||
assignees: []
|
||||
|
||||
---
|
||||
|
||||
## 🔥 Is your feature request related to a problem?
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
## ✨ Describe the Proposed Solution
|
||||
A clear and concise description of what you want to happen. How does it fit into the **RTX⚡ 3-Tier Architecture**?
|
||||
|
||||
## 🤖 Proposed Tier Implementation
|
||||
- [ ] **RTX⚡1 (Infra / Platform)** — Shell/Env changes
|
||||
- [ ] **RTX⚡2 (Engine / Core)** — Python/Node logic
|
||||
- [ ] **RTX⚡3 (Arsenal / Automation)** — New scrapers/tools
|
||||
|
||||
## 📊 Describe Alternatives Considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
## 📝 Additional Context
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,17 @@
|
||||
## ⚡ Description
|
||||
Brief description of the changes. Which **RTX⚡ Tier** does this affect?
|
||||
|
||||
## 🤖 Related Issue
|
||||
Closes # [issue_number]
|
||||
|
||||
## ✅ Checklist
|
||||
- [ ] My code follows the **RTX⚡ Protocol** (Infra, Engine, Arsenal).
|
||||
- [ ] I have linted my shell scripts (`shellcheck`) and Python code (`flake8/black`).
|
||||
- [ ] I have tested changes in a local Termux environment.
|
||||
- [ ] I have updated the documentation (`README.md`, `CONTRIBUTING.md`).
|
||||
|
||||
## 📸 Screenshots (if UI-related)
|
||||
Add screenshots of the command output or UI changes.
|
||||
|
||||
## 📝 Additional Notes
|
||||
Anything the maintainer should know?
|
||||
@@ -1,473 +1,190 @@
|
||||
<div align="center">
|
||||
# OpenClaw on Android (OCA)
|
||||
|
||||

|
||||
Your old Android phone is not e-waste. It's an ARM64 server sitting in a drawer.
|
||||
|
||||
# 🤖 OpenClaw on Android (OCA)
|
||||
This repo turns any Termux device into a full OpenClaw AI server — native glibc, no proot, no VM, no excuses.
|
||||
|
||||
### 🚀 Turn any Android phone into a 24/7 AI server — one command, zero hassle.
|
||||
|
||||
**Native performance via Termux & glibc. No Proot. No VM. Pure ARM64 power.**
|
||||
|
||||
<br/>
|
||||
|
||||
[](https://github.com/PsProsen-Dev/OpenClaw-On-Android/releases)
|
||||
[](LICENSE)
|
||||
[](https://github.com/PsProsen-Dev/OpenClaw-On-Android/discussions)
|
||||
[](https://github.com/PsProsen-Dev/OpenClaw-On-Android/stargazers)
|
||||
[](https://github.com/PsProsen-Dev/OpenClaw-On-Android/network/members)
|
||||
|
||||
<br/>
|
||||
|
||||
[🚀 Quick Start](#-quick-start) • [⚡ Features](#-features) • [🦙 Local LLM](#-local-llm) • [📖 Docs](#-documentation) • [🏗 Architecture](#-project-architecture) • [🤝 Community](#-community)
|
||||
|
||||
</div>
|
||||
**Mirror** of [PsProsen-Dev/OpenClaw-On-Android](https://github.com/PsProsen-Dev/OpenClaw-On-Android) with audited install scripts. See [SAFE_INSTALL.md](SAFE_INSTALL.md) or the `safe/` directory for cleaned-up versions that don't blindly pipe things to bash.
|
||||
|
||||
---
|
||||
|
||||
## 🌟 The Vision
|
||||
## Quick Start
|
||||
|
||||
> **Your old Android phone is not e-waste. It's a powerful ARM64 server waiting to happen.**
|
||||
### 1. Install Termux from F-Droid
|
||||
|
||||
OCA seamlessly installs the **OpenClaw** AI ecosystem directly onto your device via Termux. This completely bypasses sluggish Linux distributions (like Ubuntu on Proot), running **natively** with full `glibc` compatibility instead of Android's default Bionic libraries.
|
||||
Play Store version is dead. Get it from [f-droid.org/packages/com.termux](https://f-droid.org/packages/com.termux/).
|
||||
|
||||
| Before OCA ❌ | After OCA ✅ |
|
||||
|--------------|-------------|
|
||||
| Slow Proot containers | **Native ARM64 execution** |
|
||||
| Bionic libc limitations | **Full glibc compatibility** |
|
||||
| Manual setup (hours) | **Zero-Prompt Auto-Install (2 mins)** |
|
||||
| Limited AI tools | **Optimized Qwen/Gemini Arsenal** |
|
||||
| Individual tool prompts | **Total Autonomous Deployment** |
|
||||
| Static installation | **Auto-updating ecosystem** |
|
||||
### 2. Phone prep
|
||||
|
||||
---
|
||||
- Turn on Developer Options
|
||||
- Enable "Stay Awake"
|
||||
- Set Termux battery optimization to "Unrestricted"
|
||||
- Run `termux-wake-lock` in the app
|
||||
|
||||
## 🚀 Quick Start
|
||||
Without this Android will kill your processes the moment the screen turns off.
|
||||
|
||||
<div align="center">
|
||||
|
||||
### Deploying OCA takes under 5 minutes
|
||||
|
||||
</div>
|
||||
|
||||
#### Step 1: Prepare Your Phone ⚙️
|
||||
|
||||
Configure Developer Options, Stay Awake, and battery optimization to prevent Android from killing Termux.
|
||||
|
||||
👉 **[Read Phone Setup Guide](https://openclawonandroid.mintlify.app/docs/introduction)** for step-by-step instructions.
|
||||
|
||||
#### Step 2: Install Termux 📱
|
||||
|
||||
> **⚠️ Important**: The Play Store version of Termux is **discontinued**. You **must** install from F-Droid.
|
||||
|
||||
1. Open browser and go to [f-droid.org](https://f-droid.org/packages/com.termux/)
|
||||
2. Search for **Termux** → Tap **Download APK**
|
||||
3. Install and allow "Install from unknown sources"
|
||||
|
||||
#### Step 3: Initial Setup 🔧
|
||||
|
||||
Open Termux and run:
|
||||
### 3. Install
|
||||
|
||||
```bash
|
||||
pkg update -y && pkg install -y curl
|
||||
curl -sL https://raw.githubusercontent.com/PsProsen-Dev/OpenClaw-On-Android/master/bootstrap.sh | bash
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
#### Step 4: Install OCA 🚀
|
||||
Takes 3-10 minutes. Want to know what this actually runs? [Read SAFE_INSTALL.md](SAFE_INSTALL.md).
|
||||
|
||||
```bash
|
||||
curl -sL https://raw.githubusercontent.com/PsProsen-Dev/OpenClaw-On-Android/master/bootstrap.sh | bash && source ~/.bashrc
|
||||
```
|
||||
|
||||
Takes 3-10 minutes depending on network and device.
|
||||
|
||||
#### Step 5: Automatic glibc extras layer
|
||||
|
||||
On the OpenClaw platform, OCA now installs **Homebrew (Linuxbrew)** and the **Go toolchain** automatically once the glibc runtime is ready.
|
||||
|
||||
> **Why automatic?** `glibc-runner` provides the glibc dynamic linker that standard Linux binaries need on Android. Since Homebrew and many Go-based helper tools depend on that same Linux-compatible layer, OCA treats them as part of the default glibc stack instead of separate opt-in extras.
|
||||
|
||||
After install completes, verify the extra toolchain:
|
||||
|
||||
```bash
|
||||
source ~/.bashrc && brew --version && go version
|
||||
```
|
||||
|
||||
#### Step 6: Start OpenClaw Setup
|
||||
### 4. Onboard
|
||||
|
||||
```bash
|
||||
openclaw onboard
|
||||
```
|
||||
|
||||
Follow the on-screen instructions.
|
||||
|
||||
#### Step 7: Start Gateway
|
||||
|
||||
```bash
|
||||
openclaw gateway
|
||||
```
|
||||
|
||||
> **⚠️ Important**: Run directly in Termux app, **not via SSH**. SSH session disconnect will stop the gateway.
|
||||
Run `openclaw gateway` directly in Termux, not over SSH — disconnecting the session kills it.
|
||||
|
||||
<div align="center">
|
||||
### 5. Verify
|
||||
|
||||
**That's it. You now have a full AI server on your phone.**
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Features
|
||||
|
||||
<div align="center">
|
||||
|
||||
| <g-emoji class="g-emoji" alias="iphone">📱</g-emoji> Native Execution | <g-emoji class="g-emoji" alias="cloud">☁️</g-emoji> Full Node.js v24 |
|
||||
|:---:|:---:|
|
||||
| OpenClaw runs bare-metal in Termux | glibc-patched Node.js v24.14.1 |
|
||||
| No Proot overhead | Official linux-arm64 binaries |
|
||||
| 100% ARM64 optimized | Bypasses Android linker restrictions |
|
||||
|
||||
| <g-emoji class="g-emoji" alias="robot">🤖</g-emoji> AI CLI Tools | <g-emoji class="g-emoji" alias="llama">🦙</g-emoji> Local LLM |
|
||||
|:---:|:---:|
|
||||
| Qwen Code, Gemini CLI, OpenCode | node-llama-cpp + Ollama support |
|
||||
| Zero-prompt auto-setup | Run models locally (experimental) |
|
||||
| Cloud API routing | **☁️ NEW: Ollama Cloud Models** |
|
||||
|
||||
| <g-emoji class="g-emoji" alias="globe_with_meridians">🌐</g-emoji> Remote Access | <g-emoji class="g-emoji" alias="shield">🛡️</g-emoji> Safe Root |
|
||||
|:---:|:---:|
|
||||
| SSH server on port 8022 | `oca-root` wrapper for rooted devices |
|
||||
| Remote terminal access | Selective root commands |
|
||||
| 24/7 headless operation | No system compromise |
|
||||
|
||||
| <g-emoji class="g-emoji" alias="arrows_counterclockwise">🔄</g-emoji> Auto-Updates | <g-emoji class="g-emoji" alias="wrench">🔧</g-emoji> Master CLI |
|
||||
|:---:|:---:|
|
||||
| One-command updates via `oca --update` | `oca` command for all operations |
|
||||
| Automatic security patches | Global status, health, & maintenance |
|
||||
| Rolling release model | Platform-aware architecture |
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 🔧 CLI Reference
|
||||
|
||||
After installation, use the `oca` command for managing your installation:
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `oca --update` | Update OpenClaw and Android patches |
|
||||
| `oca --status` | Show global installation health |
|
||||
| `oca --clean` | Purge caches and binary junk |
|
||||
| `oca --uninstall` | Clean removal of OCA ecosystem |
|
||||
| `oca --version` | Show version info |
|
||||
| `oca --help` | Show Jarvis-grade help |
|
||||
|
||||
**Update example:**
|
||||
```bash
|
||||
oca --update && source ~/.bashrc
|
||||
source ~/.bashrc
|
||||
brew --version
|
||||
go version
|
||||
openclaw --version
|
||||
```
|
||||
|
||||
This updates: OpenClaw core, code-server, OpenCode, AI CLI tools, Android patches
|
||||
---
|
||||
|
||||
## What You Get
|
||||
|
||||
| Thing | Details |
|
||||
|-------|---------|
|
||||
| **OpenClaw** | AI agent gateway with SSH, CLI tools, plugin system |
|
||||
| **glibc runtime** | Linux binaries running natively on Android via ld.so wrapper |
|
||||
| **Node.js v24** | Official linux-arm64 builds, glibc-patched |
|
||||
| **Homebrew** | Linuxbrew inside Debian proot-distro |
|
||||
| **Go 1.23** | glibc Go toolchain |
|
||||
| **code-server** | VS Code in the browser (via Debian FHS container) |
|
||||
| **Playwright** | Headless Chromium + xvfb for web automation |
|
||||
| **OpenCode** | AI code editor (bun-based) |
|
||||
| **AI CLIs** | Qwen Code, Gemini CLI, Claude Code, Codex (opt-in) |
|
||||
|
||||
---
|
||||
|
||||
## 🦙 Local LLM
|
||||
## Architecture
|
||||
|
||||
<div align="center">
|
||||
```
|
||||
Android (Termux)
|
||||
├─ glibc-runner (ld.so wrapper)
|
||||
│ └─ Node.js v24 (linux-arm64)
|
||||
│ ├─ OpenClaw Gateway
|
||||
│ │ ├─ AI CLIs
|
||||
│ │ ├─ SSH server (:8022)
|
||||
│ │ └─ clawdhub
|
||||
│ └─ Local LLM (optional)
|
||||
│ ├─ llama.cpp
|
||||
│ └─ Ollama + cloud models
|
||||
└─ proot-distro (Debian)
|
||||
├─ Homebrew / Linuxbrew
|
||||
├─ code-server
|
||||
└─ Playwright + Chromium + xvfb
|
||||
```
|
||||
|
||||
### Run AI models directly on your phone!
|
||||
The trick: Android uses Bionic libc, but Linux binaries expect glibc. OCA uses a `glibc-runner` wrapper that injects `ld-linux-aarch64.so.1` so standard Linux executables run directly on ARM64 Android. No proot overhead for the stuff that matters.
|
||||
|
||||
**☁️ NEW: Ollama Cloud Models** - No local resources needed!
|
||||
---
|
||||
|
||||
</div>
|
||||
## CLI
|
||||
|
||||
OCA now supports **local LLM inference** via `node-llama-cpp` and **Ollama** (including cloud models!).
|
||||
```
|
||||
oca --update Update OpenClaw and patches
|
||||
oca --status Global installation health
|
||||
oca --clean Purge caches
|
||||
oca --uninstall Remove everything
|
||||
oca --version Version info
|
||||
oca --help Full help
|
||||
```
|
||||
|
||||
### ☁️ Ollama Cloud Models (Recommended)
|
||||
---
|
||||
|
||||
Run powerful models in the cloud — zero local RAM/storage usage!
|
||||
## Local LLM
|
||||
|
||||
Run models on-device or route through cloud models via Ollama.
|
||||
|
||||
### Cloud models (recommended)
|
||||
|
||||
Zero RAM/STORAGE cost on your phone:
|
||||
|
||||
```bash
|
||||
# Pull and launch with cloud model
|
||||
ollama pull kimi-k2.5:cloud
|
||||
ollama launch openclaw --model kimi-k2.5:cloud
|
||||
```
|
||||
|
||||
**Recommended Cloud Models:**
|
||||
- `kimi-k2.5:cloud` - Multimodal reasoning (64k context)
|
||||
- `minimax-m2.5:cloud` - Fast coding (64k context)
|
||||
- `glm-5:cloud` - Reasoning & code generation
|
||||
- `gpt-oss:120b-cloud` - High-performance (128k context)
|
||||
### Local models (experimentation)
|
||||
|
||||
### 🏠 Local Models (Experimental)
|
||||
| Model | Size | RAM | Speed |
|
||||
|-------|------|-----|-------|
|
||||
| TinyLlama 1.1B | ~670MB | 2GB | Fast |
|
||||
| Phi-3 Mini | ~2.3GB | 4GB | OK |
|
||||
| Llama 3.2 1B | ~670MB | 2GB | Fast |
|
||||
| Mistral 7B | ~4.1GB | 8GB | Slow |
|
||||
|
||||
<details>
|
||||
<summary><b>⚠️ Important Constraints (click to expand)</b></summary>
|
||||
CPU only. No GPU offloading on Android. Keep your expectations in check.
|
||||
|
||||
| Constraint | Requirement | Reality Check |
|
||||
|------------|-------------|---------------|
|
||||
| **RAM** | 2-4GB free | Phone RAM is shared with Android |
|
||||
| **Storage** | 4-70GB+ | Model files are large |
|
||||
| **Speed** | CPU-only | No GPU offloading on Android |
|
||||
| **Use Case** | Testing/Experimentation | Cloud APIs for production |
|
||||
---
|
||||
|
||||
</details>
|
||||
## Remote Access
|
||||
|
||||
### Quick Start
|
||||
SSH tunnel from your PC:
|
||||
|
||||
```bash
|
||||
# Option 1: node-llama-cpp (Recommended)
|
||||
npm install -g node-llama-cpp --ignore-scripts
|
||||
|
||||
# Option 2: Ollama (Full Server)
|
||||
curl -fsSL https://ollama.com/install.sh | sh
|
||||
ssh -L 3000:localhost:3000 -L 8080:localhost:8080 [email protected] -p 8022
|
||||
```
|
||||
|
||||
### Model Recommendations
|
||||
|
||||
| Model | Size | RAM Needed | Speed | Best For |
|
||||
|-------|------|------------|-------|----------|
|
||||
| **TinyLlama 1.1B** | ~670MB | 2GB | ⚡⚡⚡ | Testing |
|
||||
| **Phi-3 Mini** | ~2.3GB | 4GB | ⚡⚡ | Light tasks |
|
||||
| **Llama 3.2 1B** | ~670MB | 2GB | ⚡⚡⚡ | Mobile-friendly |
|
||||
| **Mistral 7B** | ~4.1GB | 8GB | ⚡ | Advanced only |
|
||||
|
||||
> 📖 **[Read Full Local LLM Guide](docs/local-llm.mdx)** for detailed setup, troubleshooting, and cloud comparison.
|
||||
Then open `localhost:3000` in your browser.
|
||||
|
||||
---
|
||||
|
||||
## 🏗 Project Architecture
|
||||
## Android 12+ Phantom Process Fix
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
### How OCA Works
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ Android Device (Termux) │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌──────────────────┐ │
|
||||
│ │ glibc-runner │ │
|
||||
│ │ (ld.so wrapper) │ │
|
||||
│ └────────┬─────────┘ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌──────────────────┐ │
|
||||
│ │ Node.js v24 │ │
|
||||
│ │ linux-arm64 │ │
|
||||
│ └────────┬─────────┘ │
|
||||
│ │ │
|
||||
│ ┌─────────────┴──────────────┐ │
|
||||
│ ▼ ▼ │
|
||||
│ ┌──────────────┐ ┌──────────────┐ │
|
||||
│ │ OpenClaw │ │ Local LLM │ │
|
||||
│ │ Gateway │ │ (Optional) │ │
|
||||
│ │ │ │ │ │
|
||||
│ │ • AI CLIs │ │ • llama.cpp │ │
|
||||
│ │ • SSH │ │ • Ollama │ │
|
||||
│ │ • clawdhub │ │ • GGUF │ │
|
||||
│ └──────────────┘ └──────────────┘ │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Technical Highlights
|
||||
|
||||
1. **Pacman `glibc-runner`**: Injects `ld-linux-aarch64.so.1` to bypass Android's restricted linker
|
||||
2. **Path Rewriting**: UNIX paths (`/tmp`, `/bin/sh`) dynamically mapped to Termux prefixes
|
||||
3. **JS Runtime Shims**: `glibc-compat.js` polyfills `os.cpus()` and `os.networkInterfaces()` for V8
|
||||
|
||||
---
|
||||
|
||||
## 📖 Documentation
|
||||
|
||||
<div align="center">
|
||||
|
||||
### Everything you need to run OCA like a pro
|
||||
|
||||
</div>
|
||||
|
||||
| 📚 Guide | Description |
|
||||
|----------|-------------|
|
||||
| [🚀 Quick Start](docs/quickstart.mdx) | Get running in 5 minutes |
|
||||
| [📱 Phone Setup](docs/phone-setup.mdx) | Developer Options, Stay Awake, Battery |
|
||||
| [🔧 Installation](docs/installation.mdx) | Full 8-step installer breakdown |
|
||||
| [🤖 AI CLI Tools](docs/ai-cli-tools.mdx) | Qwen, Claude, Gemini, Codex setup |
|
||||
| [🦙 Local LLM](docs/local-llm.mdx) | Run models locally (node-llama-cpp, Ollama) |
|
||||
| [🌐 Dashboard Connect](docs/dashboard-connect.mdx) | Multi-device management from PC |
|
||||
| [🔐 SSH Setup](docs/ssh-guide.mdx) | Remote access configuration |
|
||||
| [⚙️ Configuration](docs/configuration.mdx) | Manage settings and preferences |
|
||||
| [🔧 Troubleshooting](docs/troubleshooting.mdx) | Common errors and fixes |
|
||||
| [👻 Phantom Process Killer](docs/disable-phantom-process-killer.mdx) | Android 12+ fix |
|
||||
|
||||
> 📑 **Browse all docs:** [`docs/`](docs/)
|
||||
|
||||
---
|
||||
|
||||
## 🛑 Important: Android 12+ Users
|
||||
|
||||
If you see `[Process completed (signal 9)]`, Android's Phantom Process Killer has terminated Termux.
|
||||
|
||||
**Fix it in 30 seconds:**
|
||||
If you get `Process completed (signal 9)`, Android is killing Termux background processes:
|
||||
|
||||
```bash
|
||||
adb shell settings put global development_settings_enabled 1
|
||||
adb shell settings put global max_phantom_processes 64
|
||||
```
|
||||
|
||||
📖 **[Read Full Fix Guide](docs/disable-phantom-process-killer.mdx)**
|
||||
---
|
||||
|
||||
## Audit & Safe Install
|
||||
|
||||
The upstream project uses `curl | bash` for several tool installers. We audited every external download and wrote safe replacements in the `safe/` directory:
|
||||
|
||||
- **[SAFE_INSTALL.md](SAFE_INSTALL.md)** — What each script actually downloads and runs
|
||||
- **`safe/install-code-server.sh`** — Downloads release tarball from GitHub, no pipe
|
||||
- **`safe/install-bun.sh`** — Downloads bun zip from oven-sh/bun releases, no pipe
|
||||
- **`safe/install-nodesource.sh`** — Manual NodeSource apt repo setup, no pipe
|
||||
- **`safe/install-opencode.sh`** — Safe bun + opencode-ai install
|
||||
- **`safe/install-playwright.sh`** — Safe NodeSource + playwright install
|
||||
- **`safe/install-homebrew.sh`** — Git clone (has integrity checks, not curl|bash)
|
||||
|
||||
Same tools. Just no blind piping.
|
||||
|
||||
---
|
||||
|
||||
## 📱 Phone Preparation
|
||||
## Docs
|
||||
|
||||
<div align="center">
|
||||
|
||||
### Essential for 24/7 Operation
|
||||
|
||||
</div>
|
||||
|
||||
Android may kill background processes or throttle them when the screen is off. For 24/7 operation:
|
||||
|
||||
| Setting | Purpose | How To |
|
||||
|---------|---------|--------|
|
||||
| **Developer Options** | Enable advanced controls | Settings → About → Tap Build Number 7x |
|
||||
| **Stay Awake** | Prevent CPU throttling | Developer Options → Stay Awake |
|
||||
| **Battery Optimization** | Prevent app killing | Settings → Apps → Termux → Battery → Unrestricted |
|
||||
| **Charge Limit** | Protect battery during 24/7 use | Use AccuBattery or similar |
|
||||
|
||||
📖 **[Read Complete Phone Setup Guide](docs/phone-setup.mdx)** for detailed instructions.
|
||||
| Guide | What it covers |
|
||||
|-------|---------------|
|
||||
| [Quick Start](docs/quickstart.mdx) | 5-minute walkthrough |
|
||||
| [Phone Setup](docs/phone-setup.mdx) | Battery, dev options, wakelock |
|
||||
| [Installation](docs/installation.mdx) | Full installer breakdown |
|
||||
| [AI CLI Tools](docs/ai-cli-tools.mdx) | Qwen, Claude, Gemini, Codex |
|
||||
| [Local LLM](docs/local-llm.mdx) | Models, cloud vs local |
|
||||
| [SSH Setup](docs/ssh-guide.mdx) | Remote access |
|
||||
| [Troubleshooting](docs/troubleshooting.mdx) | Common errors |
|
||||
| [Phantom Process Killer](docs/disable-phantom-process-killer.mdx) | Android 12+ fix |
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Dashboard & Remote Access
|
||||
|
||||
### SSH Setup
|
||||
|
||||
Access your OCA dashboard from PC browser via SSH tunnel:
|
||||
|
||||
```bash
|
||||
# From your PC terminal
|
||||
ssh -L 3000:localhost:3000 -L 8080:localhost:8080 [email protected] -p 8022
|
||||
```
|
||||
|
||||
📖 **[Read SSH Setup Guide](docs/ssh-guide.mdx)** for complete instructions.
|
||||
|
||||
### Dashboard Connect (Multi-Device)
|
||||
|
||||
Running OCA on multiple devices? Use **Dashboard Connect** to manage them from your PC:
|
||||
|
||||
- Save connection settings (IP, token, ports) for each device with a nickname
|
||||
- Generates SSH tunnel commands automatically
|
||||
- Switch between devices with one click
|
||||
- **Your data stays local** — Settings saved only in browser localStorage
|
||||
|
||||
> 💡 **Tip**: Name your devices (e.g., "Old Pixel", "Bedroom Phone") for easy identification.
|
||||
|
||||
---
|
||||
|
||||
## 🏗 Platform Architecture (Developer Info)
|
||||
|
||||
<div align="center">
|
||||
|
||||
### RTX⚡1/RTX⚡2/RTX⚡3 Dependency Layers
|
||||
|
||||
</div>
|
||||
|
||||
OCA uses a **platform-plugin architecture** that separates platform-agnostic infrastructure from platform-specific code:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Orchestrators (install.sh, update-core.sh, uninstall.sh) │
|
||||
│ ── Platform-agnostic. Read config.env and delegate. │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Shared Scripts (scripts/) │
|
||||
│ ── RTX⚡1: install-infra-deps.sh (always) │
|
||||
│ ── RTX⚡2: install-glibc.sh, install-nodejs.sh (conditional)│
|
||||
│ ── RTX⚡3: Optional tools (user-selected) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Platform Plugins (platforms/<platform>/) │
|
||||
│ ── config.env: declares dependencies │
|
||||
│ ── install.sh / update.sh / uninstall.sh / ... │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Dependency layers:**
|
||||
|
||||
| Layer | Scope | Examples | Controlled by |
|
||||
|-------|-------|----------|---------------|
|
||||
| **RTX⚡1** | Infrastructure (always) | git, pkg update | Orchestrator |
|
||||
| **RTX⚡2** | Platform runtime (conditional) | glibc, Node.js, build tools | config.env flags |
|
||||
| **RTX⚡3** | Optional tools (user-selected) | tmux, code-server, AI CLIs | User prompts |
|
||||
|
||||
### Installed Components
|
||||
|
||||
**Core Infrastructure (RTX⚡1):** git
|
||||
|
||||
**Platform Runtime (RTX⚡2):** pacman, glibc-runner, Node.js v24, python, make, cmake, clang, binutils
|
||||
|
||||
**OpenClaw Platform:** OpenClaw, clawdhub, PyYAML, libvips
|
||||
|
||||
**Optional Tools (RTX⚡3):** tmux, ttyd, dufs, android-tools, code-server, OpenCode, Qwen Code CLI, Gemini CLI.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 What's New in v01.04.2026
|
||||
|
||||
</div>
|
||||
|
||||
| Feature | Description |
|
||||
|---------|-------------|
|
||||
| **RTX⚡ Protocol** | New tiered 3-tier architecture (Infra, Engine, Arsenal) |
|
||||
| **Master CLI (`oca`)** | Updated for protocol-aware health & sync |
|
||||
| **Playwright Arsenal** | Native Chromium FHS automation suite |
|
||||
| **Repo Cleanup** | Optimized infrastructure for 0% crash rate |
|
||||
|
||||
📦 **[View Release Notes](RELEASES/01.04.2026.md)**
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Community
|
||||
|
||||
<div align="center">
|
||||
|
||||
**Join the discussion!** Ask questions, share your Android setup, or request features.
|
||||
|
||||
[💬 GitHub Discussions](https://github.com/PsProsen-Dev/OpenClaw-On-Android/discussions)
|
||||
 • 
|
||||
[🐛 Report an Issue](https://github.com/PsProsen-Dev/OpenClaw-On-Android/issues)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 🙏 Credits & License
|
||||
|
||||
<div align="center">
|
||||
|
||||
**Built with ⚡ by [PsProsen-Dev](https://github.com/PsProsen-Dev)**
|
||||
|
||||
Using _Jarvis (RTX⚡)_
|
||||
|
||||
<br/>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/PsProsen-Dev)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
### 🚀 Ready to transform your Android phone?
|
||||
|
||||
```bash
|
||||
curl -sL https://raw.githubusercontent.com/PsProsen-Dev/OpenClaw-On-Android/master/bootstrap.sh | bash
|
||||
```
|
||||
|
||||
**Your phone is now an AI server.** ⚡
|
||||
|
||||
</div>
|
||||
*Fork maintained by Dragon on [git.rewr.ca](https://git.rewr.ca/Dragon/OpenClaw-On-Android)*
|
||||
*Original by [PsProsen-Dev](https://github.com/PsProsen-Dev/OpenClaw-On-Android)*
|
||||
*MIT License*
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
# Safe Installation Audit — OpenClaw-On-Android
|
||||
|
||||
> Every external curl|bash pattern has been audited. Here's what actually runs, and the safe alternatives that replace it.
|
||||
|
||||
---
|
||||
|
||||
## The Three Dangerous Patterns
|
||||
|
||||
### 1. `curl -fsSL https://code-server.dev/install.sh | sh`
|
||||
**Found in:** `scripts/install-code-server.sh` (inside proot-distro Debian)
|
||||
|
||||
**What it actually does:**
|
||||
1. Fetches latest version from GitHub API
|
||||
2. Downloads `code-server-${VERSION}-linux-arm64.tar.gz` from `github.com/coder/code-server/releases`
|
||||
3. Extracts to `~/.local/lib/code-server-${VERSION}`
|
||||
4. Symlinks `code-server` binary to `~/.local/bin/`
|
||||
|
||||
**Safe alternative — download directly:**
|
||||
```bash
|
||||
VERSION=$(curl -fsSL https://api.github.com/repos/coder/code-server/releases/latest | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/')
|
||||
curl -fsSL "https://github.com/coder/code-server/releases/download/v${VERSION}/code-server-${VERSION}-linux-arm64.tar.gz" -o /tmp/code-server.tar.gz
|
||||
tar -xzf /tmp/code-server.tar.gz -C ~/.local/lib
|
||||
mv ~/.local/lib/code-server-${VERSION}-linux-arm64 ~/.local/lib/code-server-${VERSION}
|
||||
ln -sf ~/.local/lib/code-server-${VERSION}/bin/code-server ~/.local/bin/code-server
|
||||
```
|
||||
|
||||
**Risk level:** Medium. The install script is legitimate, but piping curl to sh is never safe.
|
||||
|
||||
---
|
||||
|
||||
### 2. `curl -fsSL https://bun.sh/install | bash`
|
||||
**Found in:** `scripts/install-opencode.sh`
|
||||
|
||||
**What it actually does:**
|
||||
1. Detects platform (`linux-aarch64` for Termux)
|
||||
2. Downloads `bun-linux-aarch64.zip` from `github.com/oven-sh/bun/releases`
|
||||
3. Extracts to `$BUN_INSTALL/bin` (default: `~/.bun/bin`)
|
||||
4. chmods +x the binary
|
||||
|
||||
**Safe alternative — download directly:**
|
||||
```bash
|
||||
BUN_URI="https://github.com/oven-sh/bun/releases/latest/download/bun-linux-aarch64.zip"
|
||||
curl --fail --location --progress-bar -o /tmp/bun.zip "$BUN_URI"
|
||||
unzip -oqd ~/.bun /tmp/bun.zip
|
||||
chmod +x ~/.bun/bun
|
||||
```
|
||||
|
||||
**Risk level:** Medium. Bun's install script is clean, but the curl|bash pattern is not auditable without downloading first.
|
||||
|
||||
---
|
||||
|
||||
### 3. `curl -fsSL https://deb.nodesource.com/setup_22.x | bash -`
|
||||
**Found in:** `scripts/install-playwright.sh` (inside proot-distro Debian)
|
||||
|
||||
**What it actually does:**
|
||||
1. Installs `apt-transport-https ca-certificates curl gnupg`
|
||||
2. Downloads GPG key from `deb.nodesource.com/gpgkey/nodesource-repo.gpg.key`
|
||||
3. Imports with `gpg --dearmor` to `/usr/share/keyrings/nodesource.gpg`
|
||||
4. Creates `/etc/apt/sources.list.d/nodesource.sources` with Node.js 22.x repo
|
||||
5. Runs `apt update`
|
||||
|
||||
**Safe alternative — manual repo setup:**
|
||||
```bash
|
||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
|
||||
echo "Types: deb
|
||||
URIs: https://deb.nodesource.com/node_22.x
|
||||
Suites: nodistro
|
||||
Architectures: arm64
|
||||
Signed-By: /usr/share/keyrings/nodesource.gpg" > /etc/apt/sources.list.d/nodesource.sources
|
||||
apt update
|
||||
apt install -y nodejs
|
||||
```
|
||||
|
||||
**Risk level:** Low-Medium. Nodesource is a trusted source, but the install script also modifies apt preferences in ways that may surprise you (nsolid pinning).
|
||||
|
||||
---
|
||||
|
||||
## Clean Downloads (No curl|bash)
|
||||
|
||||
These are direct downloads and are safe:
|
||||
|
||||
| URL | What it is | Verified by |
|
||||
|-----|-----------|-------------|
|
||||
| `https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-linux-arm64.tar.xz` | Node.js official tarball | Checksum optional, official source |
|
||||
| `https://go.dev/dl/go${VERSION}.linux-arm64.tar.gz` | Go official tarball | Official source |
|
||||
| `https://packages-cf.termux.dev/apt/termux-main/...` | Termux .deb packages | Termux official CDN |
|
||||
| `https://service.termux-pacman.dev/gpkg/aarch64/...` | Termux pacman packages | Termux official |
|
||||
| `https://github.com/coder/code-server/releases/...` | code-server GitHub releases | GitHub |
|
||||
| `https://github.com/oven-sh/bun/releases/...` | Bun GitHub releases | GitHub |
|
||||
|
||||
---
|
||||
|
||||
## npm installs (also clean)
|
||||
|
||||
These use `npm install -g` for:
|
||||
- `@qwen-code/qwen-code@latest`
|
||||
- `@google/gemini-cli`
|
||||
- `@anthropic-ai/claude-code`
|
||||
- `opencode-ai`
|
||||
- `playwright` / `playwright-core`
|
||||
- `code-server`
|
||||
|
||||
npm is a package manager with its own integrity checks. Risk is in the packages themselves, not the install mechanism.
|
||||
|
||||
---
|
||||
|
||||
## Mirror Fallback Risk
|
||||
|
||||
`lib.sh` falls back to third-party GitHub proxies if GitHub is unreachable:
|
||||
- `ghfast.top`
|
||||
- `ghproxy.net`
|
||||
- `mirror.ghproxy.com`
|
||||
|
||||
These proxies see all downloaded script content. This is a network-level risk, not a code-malicious risk, but worth noting.
|
||||
|
||||
---
|
||||
|
||||
## Our Rewrite Approach
|
||||
|
||||
All three dangerous patterns have been replaced in the `safe/` directory:
|
||||
|
||||
- `safe/install-code-server.sh` — downloads directly from GitHub, no curl|bash
|
||||
- `safe/install-bun.sh` — downloads bun zip directly, no curl|bash
|
||||
- `safe/install-nodesource.sh` — sets up NodeSource repo manually, no pipe to bash
|
||||
|
||||
Each script:
|
||||
1. Downloads to a local file first
|
||||
2. Prints what it is about to do
|
||||
3. Shows the URL and file being downloaded
|
||||
4. Executes only after showing the command
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
# Usage: curl -sL https://raw.githubusercontent.com/PsProsen-Dev/OpenClaw-On-Android/main/bootstrap.sh | bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_TARBALL="https://github.com/PsProsen-Dev/OpenClaw-On-Android/archive/refs/heads/main.tar.gz"
|
||||
REPO_TARBALL="https://github.com/PsProsen-Dev/OpenClaw-On-Android/archive/refs/heads/master.tar.gz"
|
||||
INSTALL_DIR="$HOME/.oca/installer"
|
||||
|
||||
RED='\033[0;31m'
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env bash
|
||||
# safe/install-bun.sh
|
||||
# Replaces: curl -fsSL https://bun.sh/install | bash
|
||||
#
|
||||
# What this does:
|
||||
# 1. Detects platform: linux-aarch64 for Termux
|
||||
# 2. Downloads bun-linux-aarch64.zip from oven-sh/bun releases
|
||||
# 3. Extracts to $BUN_INSTALL/bin (default: ~/.bun/bin)
|
||||
# 4. Sets executable permission
|
||||
#
|
||||
# No curl|bash. No pipe. No blind trust.
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
BUN_VERSION="${1:-}" # Optional: specific version/tag
|
||||
BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
|
||||
BIN_DIR="$BUN_INSTALL/bin"
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}=== Safe Bun install ===${NC}"
|
||||
echo " This script downloads Bun directly from GitHub releases."
|
||||
echo ""
|
||||
|
||||
# Detect platform
|
||||
platform=$(uname -ms)
|
||||
case "$platform" in
|
||||
'Linux aarch64'|'Linux arm64') target="linux-aarch64" ;;
|
||||
'Linux x86_64'|'Linux'*) target="linux-x64" ;;
|
||||
'Darwin arm64') target="darwin-aarch64" ;;
|
||||
'Darwin x86_64') target="darwin-x64" ;;
|
||||
*) target="linux-aarch64" ;;
|
||||
esac
|
||||
|
||||
# Check for AVX2 on x86_64 (bun uses -baseline if not available)
|
||||
if [ "$target" = "linux-x64" ]; then
|
||||
if [ -z "$(cat /proc/cpuinfo | grep avx2)" ]; then
|
||||
target="linux-x64-baseline"
|
||||
echo -e "${CYAN}[INFO]${NC} AVX2 not detected, using baseline build"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}[INFO]${NC} Platform: $target"
|
||||
|
||||
# Determine URL
|
||||
github_repo="https://github.com/oven-sh/bun"
|
||||
if [ -n "$BUN_VERSION" ]; then
|
||||
# Specific version/tag provided
|
||||
zip_url="${github_repo}/releases/download/${BUN_VERSION}/bun-${target}.zip"
|
||||
echo -e "${CYAN}[INFO]${NC} Version: $BUN_VERSION (user-specified)"
|
||||
else
|
||||
# Latest
|
||||
echo -e "${CYAN}[INFO]${NC} Fetching latest version from GitHub..."
|
||||
latest_url="${github_repo}/releases/latest"
|
||||
redirect_url=$(curl -fsSL -o /dev/null -w "%{url_effective}" "$latest_url")
|
||||
BUN_VERSION=$(echo "$redirect_url" | sed 's/.*\/tag\/\([^}]*\).*/\1/')
|
||||
zip_url="${github_repo}/releases/download/${BUN_VERSION}/bun-${target}.zip"
|
||||
echo -e "${GREEN}[OK]${NC} Latest version: $BUN_VERSION"
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if [ -x "$BIN_DIR/bun" ]; then
|
||||
CURRENT=$("$BIN_DIR/bun" --version 2>/dev/null || echo "unknown")
|
||||
echo -e "${CYAN}[INFO]${NC} Already installed: bun $CURRENT"
|
||||
echo -e "${CYAN}[INFO]${NC} To upgrade: remove $BIN_DIR/bun and run this script again"
|
||||
echo -e "${CYAN}[INFO]${NC} Skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Download
|
||||
TMP_ZIP="/tmp/bun-${target}.zip"
|
||||
echo ""
|
||||
echo -e "${CYAN}[DOWNLOAD]${NC} ${zip_url}"
|
||||
echo " -> $TMP_ZIP"
|
||||
|
||||
curl --fail --location --progress-bar -o "$TMP_ZIP" "$zip_url"
|
||||
|
||||
# Extract
|
||||
echo ""
|
||||
echo -e "${CYAN}[EXTRACT]${NC} Extracting to $BIN_DIR..."
|
||||
mkdir -p "$BIN_DIR"
|
||||
unzip -oqd "$BIN_DIR" "$TMP_ZIP"
|
||||
|
||||
# The zip contains bun-${target}/bun — move it up
|
||||
if [ -d "$BIN_DIR/bun-${target}" ]; then
|
||||
mv "$BIN_DIR/bun-${target}/bun" "$BIN_DIR/bun"
|
||||
rm -rf "$BIN_DIR/bun-${target}"
|
||||
fi
|
||||
|
||||
chmod +x "$BIN_DIR/bun"
|
||||
|
||||
# Cleanup
|
||||
rm -f "$TMP_ZIP"
|
||||
|
||||
# Verify
|
||||
if [ -x "$BIN_DIR/bun" ]; then
|
||||
echo ""
|
||||
echo -e "${GREEN}[OK]${NC} Bun installed: $("$BIN_DIR/bun" --version)"
|
||||
echo " Binary: $BIN_DIR/bun"
|
||||
else
|
||||
echo -e "${RED}[FAIL]${NC} Binary not found at expected path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}Done.${NC} Run 'bun --help' to get started."
|
||||
echo ""
|
||||
echo "Add to your PATH:"
|
||||
echo " export BUN_INSTALL=\"$BUN_INSTALL\""
|
||||
echo " export PATH=\"\$BUN_INSTALL/bin:\$PATH\""
|
||||
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/install-code-server.sh - SAFE REWRITE
|
||||
# Replaces: curl -fsSL https://code-server.dev/install.sh | sh
|
||||
#
|
||||
# What it does (safe version):
|
||||
# 1. Inside proot-distro Debian: download arm64 tarball directly from GitHub
|
||||
# 2. Extract to /usr/local/lib/code-server
|
||||
# 3. Symlink binary to /usr/local/bin/code-server
|
||||
#
|
||||
# No curl|bash pipe. Download to file first, then extract.
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
MODE="${1:-install}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
IS_ROOTED=false
|
||||
if command -v su >/dev/null 2>&1 && su -c true >/dev/null 2>&1; then
|
||||
IS_ROOTED=true
|
||||
fi
|
||||
|
||||
fail_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "=== RTX⚡3 — Installing code-server (Safe, no curl|bash) ==="
|
||||
echo ""
|
||||
|
||||
# Detect if already installed
|
||||
if command -v code-server &>/dev/null 2>&1; then
|
||||
CURRENT=$(code-server --version 2>/dev/null | head -1 || echo "unknown")
|
||||
echo -e "${GREEN}[OK]${NC} code-server already installed: $CURRENT"
|
||||
if [ "$MODE" = "install" ]; then
|
||||
echo " Run with 'code-server' or update via 'oca --update'"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Determine install method based on environment ──────
|
||||
if [ -d "$ROOTFS" ]; then
|
||||
# Inside Debian container (proot-distro)
|
||||
echo -e "${CYAN}[INFO]${NC} Installing inside Debian FHS container..."
|
||||
|
||||
# The safe install runs inside the container using the safe script
|
||||
# It downloads the tarball from GitHub directly inside Debian
|
||||
proot-distro login debian --shared-tmp --bind "$PREFIX:/termux" --user root -- bash -c '
|
||||
set -euo pipefail
|
||||
|
||||
echo "[1/4] Detecting architecture..."
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
echo " ARCH=$ARCH"
|
||||
|
||||
echo "[2/4] Fetching latest version..."
|
||||
VERSION_JSON=$(curl -fsSL "https://api.github.com/repos/coder/code-server/releases/latest")
|
||||
VERSION=$(echo "$VERSION_JSON" | grep "\"tag_name\"" | sed "s/.*\"v\([^»]*\)\".*/\1/")
|
||||
echo " VERSION=$VERSION"
|
||||
|
||||
echo "[3/4] Downloading code-server..."
|
||||
TARBALL="code-server-${VERSION}-linux-${ARCH}.tar.gz"
|
||||
URL="https://github.com/coder/code-server/releases/download/v${VERSION}/${TARBALL}"
|
||||
curl --fail --location --progress-bar -o "/tmp/${TARBALL}" "${URL}"
|
||||
echo " Downloaded to /tmp/${TARBALL}"
|
||||
|
||||
echo "[4/4] Extracting to /usr/local/lib..."
|
||||
mkdir -p /usr/local/lib
|
||||
tar -xzf "/tmp/${TARBALL}" -C /usr/local/lib --strip-components=1
|
||||
|
||||
# Symlink binary
|
||||
mkdir -p /usr/local/bin
|
||||
rm -f /usr/local/bin/code-server
|
||||
ln -sf "/usr/local/lib/bin/code-server" /usr/local/bin/code-server
|
||||
chmod +x /usr/local/lib/bin/code-server 2>/dev/null || true
|
||||
|
||||
rm -f "/tmp/${TARBALL}"
|
||||
echo " Installed code-server $VERSION to /usr/local/bin/code-server"
|
||||
/usr/local/bin/code-server --version | head -1
|
||||
' || fail_warn "code-server installation failed inside container"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} code-server installed inside Debian FHS container."
|
||||
|
||||
else
|
||||
# Outside container (Termux native or no proot-distro)
|
||||
echo -e "${CYAN}[INFO]${NC} Installing code-server natively..."
|
||||
|
||||
# Fetch latest version
|
||||
ARCH="arm64" # Termux is always arm64
|
||||
VERSION_JSON=$(curl -fsSL "https://api.github.com/repos/coder/code-server/releases/latest")
|
||||
VERSION=$(echo "$VERSION_JSON" | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/')
|
||||
echo " VERSION=$VERSION"
|
||||
|
||||
TARBALL="code-server-${VERSION}-linux-${ARCH}.tar.gz"
|
||||
URL="https://github.com/coder/code-server/releases/download/v${VERSION}/${TARBALL}"
|
||||
TMP_DIR=$(mktemp -d "$PREFIX/tmp/cs-install.XXXXXX")
|
||||
|
||||
curl --fail --location --progress-bar -o "${TMP_DIR}/${TARBALL}" "${URL}"
|
||||
mkdir -p "$PREFIX/lib/code-server"
|
||||
tar -xzf "${TMP_DIR}/${TARBALL}" -C "$PREFIX/lib" --strip-components=1
|
||||
mkdir -p "$PREFIX/bin"
|
||||
rm -f "$PREFIX/bin/code-server"
|
||||
ln -sf "$PREFIX/lib/code-server/bin/code-server" "$PREFIX/bin/code-server"
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} code-server $VERSION installed natively."
|
||||
fi
|
||||
|
||||
# ── Create wrapper (same as original, no changes needed) ──
|
||||
WRAPPER="$PREFIX/bin/code-server"
|
||||
|
||||
cat > "$WRAPPER" << 'WRAPPER_EOF'
|
||||
#!/usr/bin/env bash
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
IS_ROOTED=false
|
||||
if command -v su >/dev/null 2>&1 && su -c true >/dev/null 2>&1; then
|
||||
IS_ROOTED=true
|
||||
fi
|
||||
args_escaped=()
|
||||
for arg in "$@"; do
|
||||
args_escaped+=("$(printf '%q' "$arg")")
|
||||
done
|
||||
if [ "$IS_ROOTED" = true ]; then
|
||||
su -c "
|
||||
if ! mountpoint -q \"$ROOTFS/proc\"; then mount -t proc proc \"$ROOTFS/proc\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/sys\"; then mount -t sysfs sysfs \"$ROOTFS/sys\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/dev\"; then mount --bind /dev \"$ROOTFS/dev\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/data/data/com.termux\"; then
|
||||
mkdir -p \"$ROOTFS/data/data/com.termux\"
|
||||
mount --bind /data/data/com.termux \"$ROOTFS/data/data/com.termux\"
|
||||
fi
|
||||
[ -d /sdcard ] && ! mountpoint -q \"$ROOTFS/sdcard\" && { mkdir -p \"$ROOTFS/sdcard\"; mount --bind /sdcard \"$ROOTFS/sdcard\"; } 2>/dev/null
|
||||
mkdir -p \"$ROOTFS/tmp\"; chmod 1777 \"$ROOTFS/tmp\"
|
||||
" >/dev/null 2>&1
|
||||
su -c "chroot \"$ROOTFS\" /bin/su - debian -c \"export HOME=$HOME; export PATH=/usr/local/bin:/usr/bin:/bin; cd \\\"$(pwd)\\\"; /usr/local/bin/code-server --bind-addr 127.0.0.1:8080 --auth none ${args_escaped[*]}\""
|
||||
else
|
||||
export PROOT_NO_SECCOMP=1
|
||||
SDCARD_BIND=""
|
||||
[ -d /sdcard ] && SDCARD_BIND="--bind /sdcard:/sdcard"
|
||||
proot-distro login debian --shared-tmp \
|
||||
--bind "$PREFIX:/termux" \
|
||||
--bind "$HOME:$HOME" \
|
||||
$SDCARD_BIND \
|
||||
--bind "$(pwd)":"$(pwd)" \
|
||||
--user debian -- bash -c "export HOME=$HOME; cd \"$(pwd)\"; /usr/local/bin/code-server --bind-addr 127.0.0.1:8080 --auth none ${args_escaped[*]}"
|
||||
fi
|
||||
WRAPPER_EOF
|
||||
chmod +x "$WRAPPER"
|
||||
echo -e "${GREEN}[OK]${NC} Dual-Engine wrapper created at $WRAPPER"
|
||||
echo ""
|
||||
echo -e "${GREEN}code-server installation complete.${NC}"
|
||||
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env bash
|
||||
# safe/install-homebrew.sh
|
||||
# Replaces the git clone + brew setup inside proot-distro Debian
|
||||
#
|
||||
# What it does:
|
||||
# 1. Installs proot-distro if needed
|
||||
# 2. Installs Debian minimal rootfs
|
||||
# 3. Inside Debian: apt-get install build-essential curl git bash
|
||||
# 4. git clone Homebrew into /home/linuxbrew
|
||||
# 5. Creates debian user with sudo access
|
||||
# 6. Creates Dual-Engine brew wrapper (chroot or proot)
|
||||
#
|
||||
# Note: Uses git clone, not curl|bash. Git has built-in integrity checks.
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "=== RTX⚡3 — Installing Homebrew via Safe Git Clone ==="
|
||||
echo ""
|
||||
echo " This script clones Homebrew via git (not curl|bash)."
|
||||
echo " Homebrew is installed inside the Debian FHS container."
|
||||
echo ""
|
||||
|
||||
if [ -z "${PREFIX:-}" ]; then
|
||||
echo -e "${RED}[FAIL]${NC} Not running in Termux (\$PREFIX not set)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v proot-distro >/dev/null 2>&1; then
|
||||
echo -e "${CYAN}[INFO]${NC} Installing proot-distro..."
|
||||
pkg install -y proot-distro || {
|
||||
echo -e "${RED}[FAIL]${NC} Could not install proot-distro"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
|
||||
# Install Debian rootfs if not present
|
||||
if ! proot-distro list | grep -q 'debian' 2>/dev/null; then
|
||||
echo -e "${CYAN}[INFO]${NC} Downloading Debian base (~50MB download, ~150MB extracted)..."
|
||||
proot-distro install debian || {
|
||||
echo -e "${RED}[FAIL]${NC} Failed to install Debian guest via proot-distro"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo -e "${GREEN}[OK]${NC} Debian minimal rootfs already present."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}[1/2] Provisioning Homebrew inside Debian guest${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Create initialization script (no curl|bash, pure git + apt)
|
||||
INIT_SCRIPT=$(mktemp "$PREFIX/tmp/brew-init.XXXXXX")
|
||||
cat > "$INIT_SCRIPT" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update -qq
|
||||
apt-get install -yq build-essential procps curl file git bash gcc sudo locales
|
||||
|
||||
# Generate locale
|
||||
locale-gen en_US.UTF-8 2>/dev/null || true
|
||||
update-locale LANG=en_US.UTF-8 2>/dev/null || true
|
||||
|
||||
# Create debian user
|
||||
if ! id "debian" &>/dev/null; then
|
||||
useradd -m -s /bin/bash debian
|
||||
usermod -aG sudo debian
|
||||
echo "debian ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/debian
|
||||
fi
|
||||
|
||||
# Clone Homebrew (git clone, not curl|bash)
|
||||
echo "Cloning Homebrew/brew..."
|
||||
mkdir -p /home/linuxbrew
|
||||
chown debian:debian /home/linuxbrew
|
||||
su - debian -c "
|
||||
git clone --depth=1 https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew 2>&1
|
||||
mkdir -p ~/.linuxbrew/bin
|
||||
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin/brew
|
||||
echo 'Homebrew cloned successfully'
|
||||
"
|
||||
|
||||
# Verify
|
||||
su - debian -c "~/.linuxbrew/bin/brew --version" 2>&1 || true
|
||||
EOF
|
||||
|
||||
chmod +x "$INIT_SCRIPT"
|
||||
proot-distro login debian --shared-tmp --bind "$PREFIX:/termux" -- /bin/bash "$INIT_SCRIPT" || {
|
||||
echo -e "${RED}[FAIL]${NC} Guest provisioning failed."
|
||||
rm -f "$INIT_SCRIPT"
|
||||
exit 1
|
||||
}
|
||||
rm -f "$INIT_SCRIPT"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} Homebrew cloned inside container."
|
||||
|
||||
# ── Create brew wrapper ─────────────────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[2/2] Creating brew wrapper${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
WRAPPER="$PREFIX/bin/brew"
|
||||
cat > "$WRAPPER" << 'WRAPPER_EOF'
|
||||
#!/usr/bin/env bash
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
IS_ROOTED=false
|
||||
if command -v su >/dev/null 2>&1 && su -c true >/dev/null 2>&1; then
|
||||
IS_ROOTED=true
|
||||
fi
|
||||
|
||||
args_escaped=()
|
||||
for arg in "$@"; do
|
||||
args_escaped+=("$(printf '%q' "$arg")")
|
||||
done
|
||||
|
||||
if [ "$IS_ROOTED" = true ]; then
|
||||
su -c "
|
||||
if ! mountpoint -q \"$ROOTFS/proc\"; then mount -t proc proc \"$ROOTFS/proc\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/sys\"; then mount -t sysfs sysfs \"$ROOTFS/sys\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/dev\"; then mount --bind /dev \"$ROOTFS/dev\"; fi
|
||||
mkdir -p \"$ROOTFS/tmp\"; chmod 1777 \"$ROOTFS/tmp\"
|
||||
" >/dev/null 2>&1
|
||||
su -c "chroot \"$ROOTFS\" /bin/su - debian -c \"export PATH=/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin; brew ${args_escaped[*]}\""
|
||||
else
|
||||
export PROOT_NO_SECCOMP=1
|
||||
proot-distro login debian --shared-tmp --bind "$PREFIX:/termux" --bind "$(pwd)":"$(pwd)" --user debian -- bash -c "eval \"\$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" && brew ${args_escaped[*]}"
|
||||
fi
|
||||
|
||||
# Auto-shim newly installed binaries
|
||||
if [[ " $* " == *" install "* ]] || [[ " $* " == *" upgrade "* ]] || [[ " $* " == *" link "* ]]; then
|
||||
SHIM_DIR="$HOME/.oca/brew-bin"
|
||||
mkdir -p "$SHIM_DIR"
|
||||
BREW_BIN="$ROOTFS/home/linuxbrew/.linuxbrew/bin"
|
||||
if [ -d "$BREW_BIN" ]; then
|
||||
for bin_path in "$BREW_BIN"/*; do
|
||||
[ -f "$bin_path" ] && [ -x "$bin_path" ] || continue
|
||||
base_name=$(basename "$bin_path")
|
||||
[ "$base_name" = "brew" ] && continue
|
||||
cat > "$SHIM_DIR/$base_name" << SHIM_EOF
|
||||
#!/usr/bin/env bash
|
||||
ROOTFS=\$PREFIX/var/lib/proot-distro/installed-rootfs/debian
|
||||
args_escaped=()
|
||||
for arg in "\$@"; do
|
||||
args_escaped+=("\$(printf '%q' "\$arg")")
|
||||
done
|
||||
if command -v su >/dev/null 2>&1 && su -c true >/dev/null 2>&1; then
|
||||
su -c "chroot \\"\$ROOTFS\\" /bin/su - debian -c \\"export PATH=/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin; exec $base_name \${args_escaped[*]}\\""
|
||||
else
|
||||
export PROOT_NO_SECCOMP=1
|
||||
exec proot-distro login debian --shared-tmp --bind "\$PREFIX:/termux" --bind "\$(pwd)":"\$(pwd)" --user debian -- bash -c "eval \\\\"\$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\\\\" && exec \\"$base_name\\" \${args_escaped[*]}"
|
||||
fi
|
||||
SHIM_EOF
|
||||
chmod +x "$SHIM_DIR/$base_name"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
WRAPPER_EOF
|
||||
chmod +x "$WRAPPER"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} Homebrew wrapper created at $WRAPPER"
|
||||
echo -e "${GREEN}[OK]${NC} Homebrew successfully integrated via proot virtualization!"
|
||||
echo ""
|
||||
echo -e "${CYAN}[INFO]${NC} Run 'brew' from anywhere in Termux."
|
||||
echo " It transparently executes inside the FHS Debian container."
|
||||
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env bash
|
||||
# safe/install-nodesource.sh
|
||||
# Replaces: curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
#
|
||||
# What this does:
|
||||
# 1. Installs prerequisites (apt-transport-https, ca-certificates, curl, gnupg)
|
||||
# 2. Downloads and imports NodeSource GPG key
|
||||
# 3. Creates apt sources file for Node.js 22.x nodistro suite
|
||||
# 4. Runs apt update
|
||||
# 5. Installs nodejs package
|
||||
#
|
||||
# No pipe to bash. Each step is explicit and auditable.
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
NODE_VERSION="${1:-22.x}" # Default: Node.js 22.x
|
||||
ARCH="${2:-$(dpkg --print-architecture)}"
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}=== Safe NodeSource Node.js ${NODE_VERSION} setup ===${NC}"
|
||||
echo " This script sets up the NodeSource apt repository manually."
|
||||
echo " No curl|bash piping. Every step is shown."
|
||||
echo ""
|
||||
|
||||
# Pre-flight
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo -e "${YELLOW}[WARN]${NC} Not running as root. Some steps may fail."
|
||||
echo " Run with sudo or as root."
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/debian_version ]; then
|
||||
echo -e "${RED}[FAIL]${NC} This script is only supported on Debian-based systems."
|
||||
echo " /etc/debian_version not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$ARCH" != "amd64" ] && [ "$ARCH" != "arm64" ]; then
|
||||
echo -e "${RED}[FAIL]${NC} Unsupported architecture: $ARCH"
|
||||
echo " Only amd64 and arm64 are supported by NodeSource."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${CYAN}[INFO]${NC} Target: Node.js $NODE_VERSION on $ARCH"
|
||||
echo ""
|
||||
|
||||
# ── Step 1: Install prerequisites ──────────────────────────
|
||||
echo -e "${BOLD}[1/5] Installing prerequisites${NC}"
|
||||
echo "----------------------------------------"
|
||||
echo " apt-get update"
|
||||
apt-get update -qq
|
||||
|
||||
echo " apt-get install -y apt-transport-https ca-certificates curl gnupg"
|
||||
apt-get install -y apt-transport-https ca-certificates curl gnupg
|
||||
|
||||
# ── Step 2: Import GPG key ──────────────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[2/5] Importing NodeSource GPG key${NC}"
|
||||
echo "----------------------------------------"
|
||||
GPG_KEY_URL="https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key"
|
||||
GPG_KEY_FILE="/tmp/nodesource-repo.gpg.key"
|
||||
GPG_KEYRING="/usr/share/keyrings/nodesource.gpg"
|
||||
|
||||
echo " Download: $GPG_KEY_URL"
|
||||
echo " -> $GPG_KEY_FILE"
|
||||
curl -fsSL "$GPG_KEY_URL" -o "$GPG_KEY_FILE"
|
||||
|
||||
echo " Import: gpg --dearmor -o $GPG_KEYRING"
|
||||
gpg --dearmor -o "$GPG_KEYRING" "$GPG_KEY_FILE"
|
||||
chmod 644 "$GPG_KEYRING"
|
||||
|
||||
rm -f "$GPG_KEY_FILE"
|
||||
echo -e "${GREEN}[OK]${NC} GPG key imported to $GPG_KEYRING"
|
||||
|
||||
# ── Step 3: Create apt sources file ─────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[3/5] Creating apt sources file${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Convert NODE_VERSION like "22.x" to nodistro suite name
|
||||
# NodeSource uses "nodistro" suite, not the actual version string
|
||||
nodistro_version=$(echo "$NODE_VERSION" | sed 's/\.x$//') # "22.x" -> "22"
|
||||
NODE_SUITE="nodistro"
|
||||
|
||||
SOURCES_FILE="/etc/apt/sources.list.d/nodesource.sources"
|
||||
echo " File: $SOURCES_FILE"
|
||||
echo ""
|
||||
echo " Content:"
|
||||
cat << SOURCES_EOF | tee "$SOURCES_FILE"
|
||||
Types: deb
|
||||
URIs: https://deb.nodesource.com/node_${nodistro_version}
|
||||
Suites: ${NODE_SUITE}
|
||||
Components: main
|
||||
Architectures: ${ARCH}
|
||||
Signed-By: ${GPG_KEYRING}
|
||||
SOURCES_EOF
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}[OK]${NC} Sources file created"
|
||||
|
||||
# ── Step 4: apt update ─────────────────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[4/5] Refreshing package lists${NC}"
|
||||
echo "----------------------------------------"
|
||||
echo " apt-get update"
|
||||
apt-get update -qq
|
||||
echo -e "${GREEN}[OK]${NC} Package lists refreshed"
|
||||
|
||||
# ── Step 5: Install Node.js ─────────────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[5/5] Installing Node.js${NC}"
|
||||
echo "----------------------------------------"
|
||||
echo " apt-get install -y nodejs"
|
||||
apt-get install -y nodejs
|
||||
|
||||
# Verify
|
||||
NODE_VER=$(node --version 2>/dev/null || echo "not found")
|
||||
NPM_VER=$(npm --version 2>/dev/null || echo "not found")
|
||||
|
||||
if [ "$NODE_VER" != "not found" ]; then
|
||||
echo ""
|
||||
echo -e "${GREEN}[OK]${NC} Node.js installed:"
|
||||
echo " Node: $NODE_VER"
|
||||
echo " npm: $NPM_VER"
|
||||
else
|
||||
echo -e "${RED}[FAIL]${NC} Node.js installation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}Done.${NC} Node.js $NODE_VER is ready."
|
||||
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/install-opencode.sh - SAFE REWRITE
|
||||
# Replaces: curl -fsSL https://bun.sh/install | bash
|
||||
#
|
||||
# What it does (safe version):
|
||||
# 1. Downloads bun-linux-aarch64.zip directly from oven-sh/bun releases
|
||||
# 2. Extracts to $HOME/.bun/bin
|
||||
# 3. Uses bun to install opencode-ai globally
|
||||
#
|
||||
# No curl|bash pipe. Downloads to file first.
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
OPENCLAW_DIR="$HOME/.oca"
|
||||
GLIBC_LDSO="$PREFIX/glibc/lib/ld-linux-aarch64.so.1"
|
||||
BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
|
||||
BUN_DIR="$BUN_INSTALL/bin"
|
||||
BUN_VERSION="${1:-}" # Optional: specific version
|
||||
|
||||
fail_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "=== RTX⚡3 — Installing OpenCode (Safe, no curl|bash) ==="
|
||||
echo ""
|
||||
|
||||
if [ ! -f "$OPENCLAW_DIR/.glibc-arch" ]; then
|
||||
fail_warn "glibc environment not installed — skipping OpenCode install"
|
||||
fi
|
||||
|
||||
if [ ! -x "$GLIBC_LDSO" ]; then
|
||||
fail_warn "glibc dynamic linker not found — skipping OpenCode install"
|
||||
fi
|
||||
|
||||
if ! command -v proot &>/dev/null; then
|
||||
echo "Installing proot..."
|
||||
if ! pkg install -y proot; then
|
||||
fail_warn "Failed to install proot — skipping OpenCode install"
|
||||
fi
|
||||
fi
|
||||
|
||||
PROOT_ROOT="$OPENCLAW_DIR/proot-root"
|
||||
|
||||
# ── Step 1: Install Bun safely ──────────────────────────
|
||||
echo -e "${BOLD}[1/3] Installing Bun (direct download, no curl|bash)${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
if [ -x "$BUN_DIR/bun" ]; then
|
||||
echo -e "${GREEN}[OK]${NC} Bun already installed: $($BUN_DIR/bun --version 2>/dev/null || echo 'unknown')"
|
||||
else
|
||||
# Detect latest version from GitHub
|
||||
if [ -z "$BUN_VERSION" ]; then
|
||||
echo -e "${CYAN}[INFO]${NC} Fetching latest Bun version from GitHub..."
|
||||
redirect=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/oven-sh/bun/releases/latest")
|
||||
BUN_VERSION=$(echo "$redirect" | sed 's/.*\/tag\/\([^?]*\).*/\1/')
|
||||
echo -e "${GREEN}[OK]${NC} Latest: $BUN_VERSION"
|
||||
fi
|
||||
|
||||
TARGET="linux-aarch64"
|
||||
ZIP_NAME="bun-${TARGET}.zip"
|
||||
URL="https://github.com/oven-sh/bun/releases/download/${BUN_VERSION}/${ZIP_NAME}"
|
||||
TMP_ZIP="/tmp/bun-${TARGET}.zip"
|
||||
|
||||
echo -e "${CYAN}[DOWNLOAD]${NC} ${URL}"
|
||||
echo " -> $TMP_ZIP"
|
||||
curl --fail --location --progress-bar -o "$TMP_ZIP" "$URL"
|
||||
|
||||
echo -e "${CYAN}[EXTRACT]${NC} Extracting to $BUN_DIR..."
|
||||
mkdir -p "$BUN_DIR"
|
||||
unzip -oqd "$BUN_DIR" "$TMP_ZIP"
|
||||
|
||||
# Move bun binary up from subdir if needed
|
||||
if [ -d "$BUN_DIR/bun-${TARGET}" ]; then
|
||||
mv "$BUN_DIR/bun-${TARGET}/bun" "$BUN_DIR/bun"
|
||||
rm -rf "$BUN_DIR/bun-${TARGET}"
|
||||
fi
|
||||
chmod +x "$BUN_DIR/bun"
|
||||
rm -f "$TMP_ZIP"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} Bun installed: $($BUN_DIR/bun --version)"
|
||||
fi
|
||||
|
||||
# ── Step 2: Create glibc wrapper for Bun ───────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[2/3] Creating glibc wrapper for Bun${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Bun is a glibc binary, needs ld.so wrapper on Termux
|
||||
BUN_WRAPPER=$(mktemp "$PREFIX/tmp/bun-wrapper.XXXXXX")
|
||||
cat > "$BUN_WRAPPER" << 'WRAPPER'
|
||||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
unset LD_PRELOAD
|
||||
exec "$PREFIX/glibc/lib/ld-linux-aarch64.so.1" "$HOME/.bun/bin/bun" "$@"
|
||||
WRAPPER
|
||||
chmod +x "$BUN_WRAPPER"
|
||||
|
||||
BUN_VER=$("$BUN_WRAPPER" --version 2>/dev/null) || {
|
||||
rm -f "$BUN_WRAPPER"
|
||||
fail_warn "Bun verification failed"
|
||||
}
|
||||
echo -e "${GREEN}[OK]${NC} Bun $BUN_VER verified via glibc ld.so"
|
||||
|
||||
# ── Step 3: Install opencode-ai via Bun ────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[3/3] Installing OpenCode via Bun${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
"$BUN_WRAPPER" install -g opencode-ai 2>&1 || true
|
||||
rm -f "$HOME/.bun/bin/opencode" # Remove bun global shim
|
||||
|
||||
# Find the installed binary
|
||||
OPENCODE_BIN=""
|
||||
for pattern in \
|
||||
"$HOME/.bun/install/cache/opencode-linux-arm64@*/bin/opencode" \
|
||||
"$HOME/.bun/install/global/node_modules/opencode-linux-arm64/bin/opencode"; do
|
||||
FOUND=$(ls $pattern 2>/dev/null | sort -V | tail -1 || true)
|
||||
if [ -n "$FOUND" ] && [ -f "$FOUND" ]; then
|
||||
OPENCODE_BIN="$FOUND"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$OPENCODE_BIN" ]; then
|
||||
rm -f "$BUN_WRAPPER"
|
||||
fail_warn "OpenCode binary not found after installation"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} OpenCode binary found: $OPENCODE_BIN"
|
||||
|
||||
# ── Step 4: Create ld.so concatenation ──────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[4/4] Creating ld.so concatenation (chroot/proot)${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
mkdir -p "$OPENCLAW_DIR/bin"
|
||||
LDSO_OPENCODE="$OPENCLAW_DIR/bin/ld.so.opencode"
|
||||
|
||||
echo -e "${CYAN}[INFO]${NC} Prepending glibc ld.so to OpenCode binary..."
|
||||
cp "$GLIBC_LDSO" "$LDSO_OPENCODE"
|
||||
cat "$OPENCODE_BIN" >> "$LDSO_OPENCODE"
|
||||
chmod +x "$LDSO_OPENCODE"
|
||||
echo -e "${GREEN}[OK]${NC} ld.so concatenation created ($(du -h "$LDSO_OPENCODE" | cut -f1))"
|
||||
|
||||
# ── Step 5: Create proot wrapper ────────────────────────
|
||||
echo ""
|
||||
echo -e "${BOLD}[5/5] Creating proot wrapper${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
create_proot_wrapper() {
|
||||
local wrapper_path="$1"
|
||||
local ldso_path="$2"
|
||||
local bin_path="$3"
|
||||
local name="$4"
|
||||
|
||||
cat > "$wrapper_path" << WRAPPER
|
||||
#!/data/data/com.termux/files/usr/bin/bash
|
||||
unset LD_PRELOAD
|
||||
exec proot \
|
||||
-R "$PROOT_ROOT" \
|
||||
-b "\$PREFIX:\$PREFIX" \
|
||||
-b /system:/system \
|
||||
-b /apex:/apex \
|
||||
-w "\$(pwd)" \
|
||||
"$ldso_path" "$bin_path" "\$@"
|
||||
WRAPPER
|
||||
chmod +x "$wrapper_path"
|
||||
}
|
||||
|
||||
create_proot_wrapper "$PREFIX/bin/opencode" "$LDSO_OPENCODE" "$OPENCODE_BIN" "OpenCode"
|
||||
echo -e "${GREEN}[OK]${NC} Proot wrapper created at $PREFIX/bin/opencode"
|
||||
|
||||
# Cleanup
|
||||
rm -f "$BUN_WRAPPER"
|
||||
|
||||
# Verify
|
||||
echo ""
|
||||
echo -e "${BOLD}Verification${NC}"
|
||||
echo "----------------------------------------"
|
||||
OC_VER=$("$PREFIX/bin/opencode" --version 2>/dev/null) || true
|
||||
if [ -n "$OC_VER" ]; then
|
||||
echo -e "${GREEN}[OK]${NC} OpenCode v$OC_VER verified"
|
||||
else
|
||||
echo -e "${YELLOW}[WARN]${NC} OpenCode --version check failed (may work in interactive mode)"
|
||||
fi
|
||||
|
||||
# Create config
|
||||
mkdir -p "$HOME/.config/opencode"
|
||||
if [ ! -f "$HOME/.config/opencode/opencode.json" ]; then
|
||||
cat > "$HOME/.config/opencode/opencode.json" << 'CONFIG'
|
||||
{
|
||||
"$schema": "https://opencode.ai/config.json"
|
||||
}
|
||||
CONFIG
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}OpenCode installation complete.${NC}"
|
||||
echo " Run: opencode"
|
||||
@@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/install-playwright.sh - SAFE REWRITE
|
||||
# Replaces: curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
#
|
||||
# What it does (safe version):
|
||||
# 1. Sets up NodeSource repo MANUALLY (no curl|bash pipe)
|
||||
# 2. Installs nodejs via apt
|
||||
# 3. Installs playwright via npm globally
|
||||
# 4. Runs playwright install --with-deps chromium
|
||||
set -euo pipefail
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
fail_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "=== RTX⚡3 — Installing Playwright Suite (Safe, no curl|bash) ==="
|
||||
echo ""
|
||||
|
||||
if [ -z "${PREFIX:-}" ]; then
|
||||
fail_warn "Not running in Termux (\$PREFIX not set)"
|
||||
fi
|
||||
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
if [ ! -d "$ROOTFS" ]; then
|
||||
echo -e "${YELLOW}[INFO]${NC} Base Debian container not found. Initializing..."
|
||||
bash "$SCRIPT_DIR/install-homebrew.sh" || { echo "Failed to init container"; exit 0; }
|
||||
fi
|
||||
|
||||
# ── The dangerous part: nodesource setup is now replaced ──
|
||||
# Instead of: curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
# We do it manually, step by step
|
||||
|
||||
echo -e "${BOLD}[1/3] Setting up NodeSource repo (manual, no curl|bash)${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
export PROOT_NO_SECCOMP=1
|
||||
proot-distro login debian --shared-tmp --bind "$PREFIX:/termux" --user root -- bash -c '
|
||||
set -euo pipefail
|
||||
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
echo "[INFO] Architecture: $ARCH"
|
||||
|
||||
# Install prerequisites
|
||||
apt-get update -qq
|
||||
apt-get install -y apt-transport-https ca-certificates curl gnupg
|
||||
|
||||
# Download and import GPG key (no pipe to bash!)
|
||||
GPG_KEY_FILE="/tmp/nodesource.gpg.key"
|
||||
curl -fsSL "https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key" -o "$GPG_KEY_FILE"
|
||||
gpg --dearmor -o "/usr/share/keyrings/nodesource.gpg" "$GPG_KEY_FILE"
|
||||
chmod 644 /usr/share/keyrings/nodesource.gpg
|
||||
rm -f "$GPG_KEY_FILE"
|
||||
echo "[OK] GPG key imported"
|
||||
|
||||
# Create apt sources file (not curl|bash, just cat redirection)
|
||||
cat > /etc/apt/sources.list.d/nodesource.sources << 'NODESOURCES'
|
||||
Types: deb
|
||||
URIs: https://deb.nodesource.com/node_22.x
|
||||
Suites: nodistro
|
||||
Architectures: ARCH_PLACEHOLDER
|
||||
Signed-By: /usr/share/keyrings/nodesource.gpg
|
||||
NODESOURCES
|
||||
sed -i "s/ARCH_PLACEHOLDER/$ARCH/" /etc/apt/sources.list.d/nodesource.sources
|
||||
echo "[OK] apt sources created"
|
||||
cat /etc/apt/sources.list.d/nodesource.sources
|
||||
|
||||
# apt update and install nodejs
|
||||
apt-get update -qq
|
||||
apt-get install -y nodejs
|
||||
|
||||
NODE_VER=$(node --version 2>/dev/null)
|
||||
NPM_VER=$(npm --version 2>/dev/null)
|
||||
echo "[OK] Node.js $NODE_VER / npm $NPM_VER installed"
|
||||
'
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}[2/3] Installing Playwright + browsers inside Debian${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Install playwright and browsers
|
||||
proot-distro login debian --shared-tmp --bind "$PREFIX:/termux" --user root -- bash -c '
|
||||
set -euo pipefail
|
||||
|
||||
# Install system dependencies for Playwright Chromium
|
||||
apt-get install -yq libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
|
||||
libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
||||
libxfixes3 libxrandr2 libgbm1 libasound2 xvfb 2>/dev/null || true
|
||||
|
||||
# Install playwright via npm (no curl|bash involved)
|
||||
npm install -g playwright 2>&1 | tail -3
|
||||
|
||||
# Install Chromium browser with dependencies
|
||||
npx playwright install --with-deps chromium 2>&1 | tail -5
|
||||
'
|
||||
|
||||
echo ""
|
||||
echo -e "${BOLD}[3/3] Creating Dual-Engine Playwright wrapper${NC}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
WRAPPER="$PREFIX/bin/playwright-node"
|
||||
cat > "$WRAPPER" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
ROOTFS="$PREFIX/var/lib/proot-distro/installed-rootfs/debian"
|
||||
IS_ROOTED=false
|
||||
if command -v su >/dev/null 2>&1 && su -c true >/dev/null 2>&1; then
|
||||
IS_ROOTED=true
|
||||
fi
|
||||
|
||||
args_escaped=()
|
||||
for arg in "$@"; do
|
||||
args_escaped+=("$(printf '%q' "$arg")")
|
||||
done
|
||||
|
||||
SCRIPT_CMD="xvfb-run -a node ${args_escaped[*]}"
|
||||
|
||||
if [ "$IS_ROOTED" = true ]; then
|
||||
su -c "
|
||||
if ! mountpoint -q \"$ROOTFS/proc\"; then mount -t proc proc \"$ROOTFS/proc\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/sys\"; then mount -t sysfs sysfs \"$ROOTFS/sys\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/dev\"; then mount --bind /dev \"$ROOTFS/dev\"; fi
|
||||
if ! mountpoint -q \"$ROOTFS/data/data/com.termux\"; then
|
||||
mkdir -p \"$ROOTFS/data/data/com.termux\"
|
||||
mount --bind /data/data/com.termux \"$ROOTFS/data/data/com.termux\"
|
||||
fi
|
||||
[ -d /sdcard ] && ! mountpoint -q \"$ROOTFS/sdcard\" && { mkdir -p \"$ROOTFS/sdcard\"; mount --bind /sdcard \"$ROOTFS/sdcard\"; } 2>/dev/null
|
||||
mkdir -p \"$ROOTFS/tmp\"; chmod 1777 \"$ROOTFS/tmp\"
|
||||
" >/dev/null 2>&1
|
||||
su -c "chroot \"$ROOTFS\" /bin/su - debian -c \"export HOME=$HOME; export PATH=/usr/local/bin:/usr/bin:/bin; cd \\\"$(pwd)\\\"; $SCRIPT_CMD\""
|
||||
else
|
||||
export PROOT_NO_SECCOMP=1
|
||||
SDCARD_BIND=""
|
||||
[ -d /sdcard ] && SDCARD_BIND="--bind /sdcard:/sdcard"
|
||||
proot-distro login debian --shared-tmp \
|
||||
--bind "$PREFIX:/termux" \
|
||||
--bind "$HOME:$HOME" \
|
||||
$SDCARD_BIND \
|
||||
--bind "$(pwd)":"$(pwd)" \
|
||||
--user debian -- bash -c "export HOME=$HOME; cd \"$(pwd)\"; $SCRIPT_CMD"
|
||||
fi
|
||||
EOF
|
||||
chmod +x "$WRAPPER"
|
||||
|
||||
echo -e "${GREEN}[OK]${NC} Playwright wrapper created at $WRAPPER"
|
||||
echo ""
|
||||
echo -e "${GREEN}Playwright installation complete.${NC}"
|
||||
echo " Run: playwright-node my-scraper.js"
|
||||
echo ""
|
||||
echo -e "${YELLOW}[NOTE]${NC} Chromium uses ~300-500MB RAM. Devices with <4GB RAM may struggle."
|
||||
@@ -10,7 +10,7 @@ echo "=== RTX⚡2 — Installing Build Tools ==="
|
||||
echo ""
|
||||
|
||||
PACKAGES=(
|
||||
python=3.13.12
|
||||
python
|
||||
make
|
||||
cmake
|
||||
clang
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
|
||||
Reference in new issue
Block a user