-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·154 lines (130 loc) · 4.72 KB
/
install.sh
File metadata and controls
executable file
·154 lines (130 loc) · 4.72 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FILES_DIR="$SCRIPT_DIR/files"
BACKUP_DIR=".mechanicus-backup"
VERSION="2026.3.10"
echo "╔════════════════════════════════════════════════════════╗"
echo "║ OpenClaw Mechanicus Patch Installer v$VERSION ║"
echo "║ IG Trading · 23 Strategies · Optimization Engine ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
detect_openclaw() {
if [ -n "${1:-}" ] && [ -d "$1" ]; then
echo "$1"
return
fi
local home="${HOME:-$(eval echo ~)}"
for candidate in "$home/openclaw" "./openclaw"; do
if [ -d "$candidate" ] && [ -f "$candidate/package.json" ] && [ -d "$candidate/dist" ]; then
local resolved
resolved="$(cd "$candidate" && pwd)"
echo "$resolved"
return
fi
done
echo ""
}
OPENCLAW_ROOT=$(detect_openclaw "${1:-}")
if [ -z "$OPENCLAW_ROOT" ]; then
echo "ERROR: Could not find OpenClaw installation."
echo "Usage: bash install.sh /path/to/openclaw"
echo ""
echo "Provide the root directory of your OpenClaw installation."
exit 1
fi
if [ ! -d "$FILES_DIR" ]; then
echo "ERROR: files/ directory not found next to this script."
echo "Make sure you cloned the full repository."
exit 1
fi
echo "OpenClaw root: $OPENCLAW_ROOT"
echo ""
BACKUP_PATH="$OPENCLAW_ROOT/$BACKUP_DIR"
INSTALLED_LIST="$BACKUP_PATH/installed-files.txt"
BACKED_UP_LIST="$BACKUP_PATH/backed-up-files.txt"
mkdir -p "$BACKUP_PATH"
backed_up=0
installed=0
new_files=0
echo "[1/3] Backing up files that will be overwritten..."
cd "$FILES_DIR"
find . -type f | sed 's|^\./||' | sort | while IFS= read -r rel; do
target="$OPENCLAW_ROOT/$rel"
if [ -f "$target" ]; then
backup_target="$BACKUP_PATH/$rel"
mkdir -p "$(dirname "$backup_target")"
cp "$target" "$backup_target"
echo "$rel" >> "$BACKED_UP_LIST.tmp"
fi
done
if [ -f "$BACKED_UP_LIST.tmp" ]; then
sort "$BACKED_UP_LIST.tmp" > "$BACKED_UP_LIST"
rm -f "$BACKED_UP_LIST.tmp"
backed_up=$(wc -l < "$BACKED_UP_LIST")
else
touch "$BACKED_UP_LIST"
fi
echo " Backed up $backed_up existing files to $BACKUP_DIR/"
echo ""
echo "[2/3] Installing Mechanicus files..."
# Inject navigation into index.html
if [ -f "$OPENCLAW_ROOT/index.html" ]; then
if ! grep -q "nav-inject.js" "$OPENCLAW_ROOT/index.html"; then
sed -i 's|</body>|<script src="/nav-inject.js"></script></body>|' "$OPENCLAW_ROOT/index.html"
echo " Injected navigation into index.html"
fi
fi
cd "$FILES_DIR"
find . -type f | sed 's|^\./||' | sort | while IFS= read -r rel; do
target="$OPENCLAW_ROOT/$rel"
mkdir -p "$(dirname "$target")"
cp "$FILES_DIR/$rel" "$target"
echo "$rel" >> "$INSTALLED_LIST.tmp"
done
if [ -f "$INSTALLED_LIST.tmp" ]; then
sort "$INSTALLED_LIST.tmp" > "$INSTALLED_LIST"
rm -f "$INSTALLED_LIST.tmp"
installed=$(wc -l < "$INSTALLED_LIST")
new_files=$((installed - backed_up))
fi
echo " Installed $installed files ($new_files new, $backed_up updated)"
echo ""
echo "[3/3] Checking dependencies..."
cd "$OPENCLAW_ROOT"
deps_needed=""
if [ -f "package.json" ]; then
for dep in pg lightstreamer-client-node; do
if ! grep -q "\"$dep\"" package.json 2>/dev/null; then
deps_needed="$deps_needed $dep"
fi
done
fi
if [ -n "$deps_needed" ]; then
echo " Additional npm packages needed:$deps_needed"
echo " Run: npm install$deps_needed"
echo " (or: pnpm add$deps_needed)"
else
echo " All dependencies present."
fi
echo "$VERSION" > "$BACKUP_PATH/version.txt"
date -u +"%Y-%m-%dT%H:%M:%SZ" > "$BACKUP_PATH/installed-at.txt"
echo ""
echo "════════════════════════════════════════════════════════"
echo " INSTALLATION COMPLETE"
echo "════════════════════════════════════════════════════════"
echo ""
echo " Files installed: $installed"
echo " Backup location: $OPENCLAW_ROOT/$BACKUP_DIR/"
echo ""
echo " Required environment variables:"
echo " IG_API_KEY - Your IG trading API key"
echo " IG_IDENTIFIER - Your IG account username"
echo " IG_PASSWORD - Your IG account password"
echo " IG_ACCOUNT_TYPE - 'demo' or 'live'"
echo " DATABASE_URL - PostgreSQL connection string"
echo " GROQ_API_KEY - For AI calibration (optional)"
echo ""
echo " To uninstall and restore originals:"
echo " bash uninstall.sh $OPENCLAW_ROOT"
echo ""