Add Android (Termux) support for shell scripts
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- android, shell, typescript
Hướng nghiên cứu
The proposed changes touch onboard.sh, openclaw.mjs, server.sh, and start-chrome-debug.sh. Read those scripts and trace their existing OS detection, Node launch, logging, browser opening, and Chrome debugging flows. Done means the Android and Termux paths described in the issue work while desktop behavior remains unchanged; the issue provides Android test evidence but no test file or command.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Enable onboard.sh, server.sh, start-chrome-debug.sh, and openclaw.mjs to run correctly inside Termux on Android.
Problem to solve
The current scripts are designed exclusively for macOS, Linux, and Windows. They fail under Termux on Android because of missing OS detection, hardcoded paths (e.g., /tmp), mismatched browser launch commands, and unknown process.platform. Users who want to run OpenClaw on a phone or tablet are forced to use a separate desktop machine. This significantly degrades the mobile experience and limits adoption.
Proposed solution
· OS detection – Add an android branch in detect_os() by inspecting /proc/version and uname -a.
· Node.js memory – Automatically append --max-old-space-size=4096 (configurable via OPENCLAW_NODE_MEMORY) to prevent OOM kills in Termux’s constrained memory.
· Log paths – In tmp_log(), fall back to $SCRIPT_DIR/logs/ when /tmp is absent or not writable.
· Browser opening – Use am start on Android instead of xdg-open / open.
· Chrome debugging – In start-chrome-debug.sh, detect adb, pick the first online device, forward port 9222 via adb forward, and launch authorization URLs with adb shell am start. No local Chrome binary is required.
· Platform spoofing – In openclaw.mjs, override process.platform from 'android' to 'linux' so that Playwright and other libraries don’t reject the unknown platform.
· All changes are gated behind OS checks and do not alter behaviour on desktop platforms.
Alternatives considered
· Instructing users to edit the scripts manually – error-prone and discourages non-technical users.
· Recommending a VNC/remote desktop setup – adds hardware requirements and latency.
· Leaving the scripts unsupported on Android – prevents a growing mobile user base from ever using OpenClaw conveniently.
Impact
· Affected users: Anyone attempting to run OpenClaw inside Termux on Android.
· Severity: Medium – completely blocks the workflow on this platform but does not affect desktop users.
· Frequency: Always – every invocation of the scripts fails or misbehaves without these patches.
· Consequences: Users either give up or have to reverse-engineer the scripts; increased community support requests; missed opportunity to onboard mobile-first users.
Evidence/examples
The following files were modified and tested on Android 13 with Termux:
· onboard.sh – Android OS branch + Node memory flag.
· openclaw.mjs – process.platform spoof at the top.
· server.sh – Android-aware logging, browser launch, and memory flag.
· start-chrome-debug.sh – Complete adb device selection, port forwarding, and URL opening via am start.
Working logs and screen captures can be provided if needed.
onboard.sh
--- 原版onboard.sh
+++ onboard.sh (修改版)
@@ detect_os() {
darwin*) echo "mac" ;;
msys*|cygwin*|mingw*) echo "win" ;;
*)
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
+ elif [ -n "$(uname -a 2>/dev/null | grep -i android)" ]; then
+ echo "android"
else
echo "linux"
fi
;;
@@ fi
+ # ─── Android 内存设置 ────────────────────────────────────
+ if [ "$OS" = "android" ]; then
+ NODE_MEMORY="--max-old-space-size=4096"
+ [ -n "$OPENCLAW_NODE_MEMORY" ] && NODE_MEMORY="--max-old-space-size=$OPENCLAW_NODE_MEMORY"
+ else
+ NODE_MEMORY=""
+ fi
+
@@ case "${1:-}" in
webauth)
...
- "$NODE" "$SCRIPT_DIR/openclaw.mjs" onboard webauth
+ $NODE $NODE_MEMORY "$SCRIPT_DIR/openclaw.mjs" onboard webauth
...
onboard)
- "$NODE" "$SCRIPT_DIR/openclaw.mjs" onboard "${@:2}"
+ $NODE $NODE_MEMORY "$SCRIPT_DIR/openclaw.mjs" onboard "${@:2}"
...
gateway)
- "$NODE" "$SCRIPT_DIR/openclaw.mjs" gateway "${@:2}"
+ $NODE $NODE_MEMORY "$SCRIPT_DIR/openclaw.mjs" gateway "${@:2}"
...
*)
- "$NODE" "$SCRIPT_DIR/openclaw.mjs" "$@"
+ $NODE $NODE_MEMORY "$SCRIPT_DIR/openclaw.mjs" "$@"
openclaw.mjs
--- 原版openclaw.mjs
+++ openclaw.mjs (修改版)
@@ #!/usr/bin/env node
+ // Termux / Android: 伪装为 Linux,让 Playwright 等库正常工作
+ if (process.platform === 'android') {
+ Object.defineProperty(process, 'platform', { value: 'linux' });
+ }
+
import module from "node:module";
...
server.sh
--- 原版server.sh
+++ server.sh (修改版)
@@ detect_os() {
darwin*) echo "mac" ;;
msys*|cygwin*|mingw*) echo "win" ;;
*)
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
+ elif [ -n "$(uname -a 2>/dev/null | grep -i android)" ]; then
+ echo "android"
else
echo "linux"
fi
;;
@@ open_browser() {
mac) open "$url" ;;
win) start "" "$url" 2>/dev/null || ... ;;
wsl) cmd.exe /c start "" "$url" 2>/dev/null ;;
+ android)
+ if command -v am >/dev/null 2>&1; then
+ am start -a android.intent.action.VIEW -d "$url" >/dev/null 2>&1 &
+ echo "已通过 am 命令打开浏览器访问 Gateway"
+ else
+ echo "请在手机浏览器中手动打开: $url"
+ fi
+ ;;
linux)
if command -v xdg-open >/dev/null 2>&1; then
xdg-open "$url" 2>/dev/null &
@@ tmp_log() {
- if [ -d /tmp ]; then
- echo "/tmp/openclaw-upstream-gateway.log"
+ if [ "$OS" = "android" ] || ! [ -d /tmp ] || ! [ -w /tmp ]; then
+ echo "$SCRIPT_DIR/logs/openclaw-upstream-gateway${OPENCLAW_INSTANCE_SUFFIX:-}.log"
else
- echo "$SCRIPT_DIR/logs/openclaw-upstream-gateway.log"
+ echo "/tmp/openclaw-upstream-gateway${OPENCLAW_INSTANCE_SUFFIX:-}.log"
fi
@@ start_gateway() {
...
+ # Android 内存优化
+ if [ "$OS" = "android" ]; then
+ NODE_MEMORY="--max-old-space-size=4096"
+ [ -n "$OPENCLAW_NODE_MEMORY" ] && NODE_MEMORY="--max-old-space-size=$OPENCLAW_NODE_MEMORY"
+ else
+ NODE_MEMORY=""
+ fi
+
- nohup "$NODE" "$SCRIPT_DIR/openclaw.mjs" gateway --port "$PORT" > "$TMP_LOG" 2>&1 &
+ nohup "$NODE" $NODE_MEMORY "$SCRIPT_DIR/openclaw.mjs" gateway --port "$PORT" > "$TMP_LOG" 2>&1 &
start-chrome-debug.sh
--- 原版start-chrome-debug.sh
+++ start-chrome-debug.sh (修改版)
@@ detect_os() {
Darwin*) echo "mac" ;;
MINGW*|MSYS*|CYGWIN*) echo "win" ;;
*)
+ if [ -n "$(uname -o 2>/dev/null | grep -i android)" ] || \
+ [ -n "$(uname -a 2>/dev/null | grep -i android)" ]; then
+ echo "android"
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
else
@@ detect_chrome() {
+ if [ "$OS" = "android" ]; then
+ command -v adb >/dev/null 2>&1 && echo "adb-chrome" || echo ""
+ return
+ fi
...
@@ detect_user_data_dir() {
+ if [ "$OS" = "android" ]; then
+ echo ""
+ return
+ fi
case "$OS" in
@@ # ─── 单实例管理(Android 下不杀 Chrome)────────────────────
+ if [ "$OS" != "android" ]; then
if pgrep -f "chrome.*remote-debugging-port=9222" > /dev/null 2>&1; then
...
fi
+ fi
@@ # ─── 启动 Chrome 并设置转发(Android)/直接启动(桌面)────────
+ if [ "$OS" = "android" ]; then
+ echo "正在启动手机 Chrome..."
+ adb -s "$ADB_DEVICE" shell am start -n com.android.chrome/org.chromium.chrome.browser.ChromeTabbedActivity
+ sleep 2
+ echo "正在设置 adb 转发 (tcp:9222 -> localabstract:chrome_devtools_remote)..."
+ adb -s "$ADB_DEVICE" forward --remove tcp:9222 2>/dev/null
+ if adb -s "$ADB_DEVICE" forward tcp:9222 localabstract:chrome_devtools_remote; then
+ echo "✓ 转发设置成功"
+ else
+ ...
+ exit 1
+ fi
+ else
"$CHROME_PATH" \
--remote-debugging-port=9222 \
... &
+ fi
@@ # ─── 打开网页(Android 分支)───────────────────────────────
WEB_URLS=(...)
+ if [ "$OS" = "android" ]; then
+ for url in "${WEB_URLS[@]}"; do
+ echo " 打开: $url"
+ adb -s "$ADB_DEVICE" shell am start -a android.intent.action.VIEW -d "$url" -n com.android.chrome/org.chromium.chrome.browser.ChromeTabbedActivity >/dev/null 2>&1 &
+ sleep 0.5
+ done
+ else
for url in "${WEB_URLS[@]}"; do
"$CHROME_PATH" --remote-debugging-port=9222 --user-data-dir="$USER_DATA_DIR" "$url" > /dev/null 2>&1 &
sleep 0.5
done
+ fi
@@ # ─── 停止提示 ─────────────────────────────────────────────
+ if [ "$OS" = "android" ]; then
+ echo "停止调试(移除转发):"
+ echo " adb -s $ADB_DEVICE forward --remove tcp:9222"
+ else
echo "停止调试模式:"
echo " pkill -f 'chrome.*remote-debugging-port=9222'"
+ fi
onboard.sh.txt
openclaw.mjs.txt
server.sh.txt
start-chrome-debug.sh.txt
Additional information
· All new code paths are strictly opt-in for the android OS identifier and do not touch existing logic.
· The changes follow the repository’s existing style and shell conventions.
· The modifications have been running stably for multiple days without side effects on both Android and desktop (macOS/Linux) machines.
- Ngôn ngữ chính
- TypeScript
- Star
- 5.2k
- Fork
- 1.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của linuxhsj/openclaw-zero-token
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
linuxhsj/openclaw-zero-token#302 ·
-
bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
linuxhsj/openclaw-zero-token#301 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 57/100
linuxhsj/openclaw-zero-token#300 ·
Tất cả issue của linuxhsj/openclaw-zero-token
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
liberation-data/drivine#826 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
【优化】“打开文件列表”,建议对当前文件进行高对比度标注Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
zhitongblog/solomd#623 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
aufwand: klein documentation Einsteiger-Familie freigegeben Haushalts-Admin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openwallet-foundation/eudiplo#1600 ·
-
docs(website): add a GitLab CI/CD button next to the GitHub Action button on the homepageCó thể đã có người làm @shryssssss-maker đã nhận hôm nay. Đang mởdocumentation enhancement first-timers-only good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
OWASP/cve-lite-cli#1739 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày