fix(portable): node-extract path + unreachable legacy-config sync

Two real bugs in the portable launchers:

1. Windows-Install.bat: xcopy reads from %TEMP%\node-<ver>-win-x64
   but Expand-Archive extracts into %TEMP%\node-extract\node-<ver>-win-x64.
   Result: empty runtime\node-win-x64\ on networked install path.

2. Mac-Start.command + Windows-Start.bat: legacy-config sync block
   was placed AFTER the default-config block, so the "config.json
   exists but openclaw.json doesn't" branch was unreachable. Existing
   USB users with config.json never got their settings migrated;
   they got the empty default instead.

Reordered so legacy migration runs first, default only as fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hfshfg
2026-05-01 15:36:34 +08:00
parent 88cf2b2dc4
commit b6ba958b79
3 changed files with 20 additions and 18 deletions

View File

@@ -72,8 +72,13 @@ mkdir -p "$STATE_DIR" "$DATA_DIR/memory" "$DATA_DIR/backups" "$DATA_DIR/logs"
# ---- 5. Default config ----
if [ ! -f "$CONFIG_FILE" ]; then
echo -e " ${YELLOW}First run - creating default config...${NC}"
cat > "$CONFIG_FILE" << 'CFGEOF'
if [ -f "$DATA_DIR/config.json" ]; then
echo -e " ${YELLOW}Migrating legacy config...${NC}"
cp "$DATA_DIR/config.json" "$CONFIG_FILE"
echo -e " ${GREEN}Config migrated${NC}"
else
echo -e " ${YELLOW}First run - creating default config...${NC}"
cat > "$CONFIG_FILE" << 'CFGEOF'
{
"gateway": {
"mode": "local",
@@ -81,15 +86,11 @@ if [ ! -f "$CONFIG_FILE" ]; then
}
}
CFGEOF
echo -e " ${GREEN}Config created${NC}"
echo -e " ${GREEN}Config created${NC}"
fi
echo ""
fi
# Sync config from legacy location
if [ -f "$DATA_DIR/config.json" ] && [ ! -f "$CONFIG_FILE" ]; then
cp "$DATA_DIR/config.json" "$CONFIG_FILE"
fi
# ---- 6. Set environment (portable mode) ----
export OPENCLAW_HOME="$DATA_DIR"
export OPENCLAW_STATE_DIR="$STATE_DIR"