forked from AidanPark/openclaw-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
191 lines (166 loc) · 6.81 KB
/
update.sh
File metadata and controls
191 lines (166 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
# update.sh - Lightweight updater for OpenClaw on Android (existing installations)
# Usage: curl -sL https://raw.githubusercontent.com/AidanPark/openclaw-android/main/update.sh | bash
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m'
REPO_BASE="https://raw.githubusercontent.com/AidanPark/openclaw-android/main"
OPENCLAW_DIR="$HOME/.openclaw-android"
echo ""
echo -e "${BOLD}========================================${NC}"
echo -e "${BOLD} OpenClaw on Android - Updater${NC}"
echo -e "${BOLD}========================================${NC}"
echo ""
step() {
echo ""
echo -e "${BOLD}[$1/5] $2${NC}"
echo "----------------------------------------"
}
# ─────────────────────────────────────────────
step 1 "Pre-flight Check"
# Check Termux
if [ -z "${PREFIX:-}" ]; then
echo -e "${RED}[FAIL]${NC} Not running in Termux (\$PREFIX not set)"
exit 1
fi
echo -e "${GREEN}[OK]${NC} Termux detected"
# Check existing OpenClaw installation
if ! command -v openclaw &>/dev/null; then
echo -e "${RED}[FAIL]${NC} openclaw command not found"
echo " Run the full installer first:"
echo " curl -sL $REPO_BASE/bootstrap.sh | bash"
exit 1
fi
echo -e "${GREEN}[OK]${NC} openclaw $(openclaw --version 2>/dev/null || echo "")"
# Migrate from old directory name (.openclaw-lite → .openclaw-android)
OLD_DIR="$HOME/.openclaw-lite"
if [ -d "$OLD_DIR" ] && [ ! -d "$OPENCLAW_DIR" ]; then
mv "$OLD_DIR" "$OPENCLAW_DIR"
echo -e "${GREEN}[OK]${NC} Migrated $OLD_DIR → $OPENCLAW_DIR"
elif [ -d "$OLD_DIR" ] && [ -d "$OPENCLAW_DIR" ]; then
# Both exist — merge old into new, then remove old
cp -rn "$OLD_DIR"/. "$OPENCLAW_DIR"/ 2>/dev/null || true
rm -rf "$OLD_DIR"
echo -e "${GREEN}[OK]${NC} Merged $OLD_DIR into $OPENCLAW_DIR"
else
mkdir -p "$OPENCLAW_DIR"
fi
# Check curl
if ! command -v curl &>/dev/null; then
echo -e "${RED}[FAIL]${NC} curl not found. Install it with: pkg install curl"
exit 1
fi
# ─────────────────────────────────────────────
step 2 "Installing New Packages"
# Install ttyd if not already installed
if command -v ttyd &>/dev/null; then
echo -e "${GREEN}[OK]${NC} ttyd already installed ($(ttyd --version 2>/dev/null || echo ""))"
else
echo "Installing ttyd..."
if pkg install -y ttyd; then
echo -e "${GREEN}[OK]${NC} ttyd installed"
else
echo -e "${YELLOW}[WARN]${NC} Failed to install ttyd (non-critical)"
fi
fi
# Install PyYAML if not already installed (required for .skill packaging)
if python -c "import yaml" 2>/dev/null; then
echo -e "${GREEN}[OK]${NC} PyYAML already installed"
else
echo "Installing PyYAML..."
if pip install pyyaml -q; then
echo -e "${GREEN}[OK]${NC} PyYAML installed"
else
echo -e "${YELLOW}[WARN]${NC} Failed to install PyYAML (non-critical)"
fi
fi
# ─────────────────────────────────────────────
step 3 "Downloading Latest Scripts"
# Download setup-env.sh (needed for .bashrc update)
TMPFILE=$(mktemp "$PREFIX/tmp/setup-env.XXXXXX.sh") || {
echo -e "${RED}[FAIL]${NC} Failed to create temporary file (disk full or $PREFIX/tmp missing?)"
exit 1
}
if curl -sfL "$REPO_BASE/scripts/setup-env.sh" -o "$TMPFILE"; then
echo -e "${GREEN}[OK]${NC} setup-env.sh downloaded"
else
echo -e "${RED}[FAIL]${NC} Failed to download setup-env.sh"
rm -f "$TMPFILE"
exit 1
fi
# Download bionic-compat.js (patches may have been updated)
mkdir -p "$OPENCLAW_DIR/patches"
if curl -sfL "$REPO_BASE/patches/bionic-compat.js" -o "$OPENCLAW_DIR/patches/bionic-compat.js"; then
echo -e "${GREEN}[OK]${NC} bionic-compat.js updated"
else
echo -e "${YELLOW}[WARN]${NC} Failed to download bionic-compat.js (non-critical)"
fi
# Download termux-compat.h (native build compatibility)
if curl -sfL "$REPO_BASE/patches/termux-compat.h" -o "$OPENCLAW_DIR/patches/termux-compat.h"; then
echo -e "${GREEN}[OK]${NC} termux-compat.h updated"
else
echo -e "${YELLOW}[WARN]${NC} Failed to download termux-compat.h (non-critical)"
fi
# Install spawn.h stub if missing (needed for koffi/native module builds)
if [ ! -f "$PREFIX/include/spawn.h" ]; then
if curl -sfL "$REPO_BASE/patches/spawn.h" -o "$PREFIX/include/spawn.h"; then
echo -e "${GREEN}[OK]${NC} spawn.h stub installed"
else
echo -e "${YELLOW}[WARN]${NC} Failed to download spawn.h (non-critical)"
fi
else
echo -e "${GREEN}[OK]${NC} spawn.h already exists"
fi
# Download update.sh itself for future use
if curl -sfL "$REPO_BASE/update.sh" -o "$OPENCLAW_DIR/update.sh"; then
chmod +x "$OPENCLAW_DIR/update.sh"
echo -e "${GREEN}[OK]${NC} update.sh saved to $OPENCLAW_DIR/"
else
echo -e "${YELLOW}[WARN]${NC} Failed to save update.sh (non-critical)"
fi
# Download build-sharp.sh
SHARP_TMPFILE=$(mktemp "$PREFIX/tmp/build-sharp.XXXXXX.sh") || {
echo -e "${YELLOW}[WARN]${NC} Failed to create temporary file for build-sharp.sh (non-critical)"
SHARP_TMPFILE=""
}
if curl -sfL "$REPO_BASE/scripts/build-sharp.sh" -o "$SHARP_TMPFILE"; then
echo -e "${GREEN}[OK]${NC} build-sharp.sh downloaded"
else
echo -e "${YELLOW}[WARN]${NC} Failed to download build-sharp.sh (non-critical)"
rm -f "$SHARP_TMPFILE"
SHARP_TMPFILE=""
fi
# ─────────────────────────────────────────────
step 4 "Updating Environment Variables"
# Run setup-env.sh to refresh .bashrc block
bash "$TMPFILE"
rm -f "$TMPFILE"
# Re-export for current session (setup-env.sh runs as subprocess, exports don't propagate)
export TMPDIR="$PREFIX/tmp"
export TMP="$TMPDIR"
export TEMP="$TMPDIR"
export NODE_OPTIONS="-r $HOME/.openclaw-android/patches/bionic-compat.js"
export CONTAINER=1
export CXXFLAGS="-include $HOME/.openclaw-android/patches/termux-compat.h"
export GYP_DEFINES="OS=linux android_ndk_path=$PREFIX"
export CPATH="$PREFIX/include/glib-2.0:$PREFIX/lib/glib-2.0/include"
# ─────────────────────────────────────────────
step 5 "Building sharp (image processing)"
if [ -n "$SHARP_TMPFILE" ]; then
bash "$SHARP_TMPFILE"
rm -f "$SHARP_TMPFILE"
else
echo -e "${YELLOW}[SKIP]${NC} build-sharp.sh was not downloaded"
fi
echo ""
echo -e "${BOLD}========================================${NC}"
echo -e "${GREEN}${BOLD} Update Complete!${NC}"
echo -e "${BOLD}========================================${NC}"
echo ""
echo -e "${YELLOW}Run this to apply changes to the current session:${NC}"
echo ""
echo " source ~/.bashrc"
echo ""