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:
@@ -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"
|
||||
|
||||
@@ -115,7 +115,7 @@ if "!USE_NODE!"=="usb" (
|
||||
echo 解压中...
|
||||
mkdir "%INSTALL_TARGET%\runtime\node-win-x64" 2>nul
|
||||
powershell -command "Expand-Archive -Path '%TEMP%\!NODE_ZIP!' -DestinationPath '%TEMP%\node-extract' -Force"
|
||||
xcopy /s /e /q /y "%TEMP%\node-%NODE_VER%-win-x64\*" "%INSTALL_TARGET%\runtime\node-win-x64\" >nul
|
||||
xcopy /s /e /q /y "%TEMP%\node-extract\node-%NODE_VER%-win-x64\*" "%INSTALL_TARGET%\runtime\node-win-x64\" >nul
|
||||
rmdir /s /q "%TEMP%\node-extract" 2>nul
|
||||
del "%TEMP%\!NODE_ZIP!" 2>nul
|
||||
|
||||
|
||||
@@ -46,19 +46,20 @@ if not exist "%DATA_DIR%\memory" mkdir "%DATA_DIR%\memory"
|
||||
if not exist "%DATA_DIR%\backups" mkdir "%DATA_DIR%\backups"
|
||||
if not exist "%DATA_DIR%\logs" mkdir "%DATA_DIR%\logs"
|
||||
|
||||
REM Default config
|
||||
REM Default config (migrate legacy if present, otherwise create)
|
||||
if not exist "%STATE_DIR%\openclaw.json" (
|
||||
echo First run - creating default config...
|
||||
(echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json"
|
||||
echo Config created
|
||||
if exist "%DATA_DIR%\config.json" (
|
||||
echo Migrating legacy config...
|
||||
copy "%DATA_DIR%\config.json" "%STATE_DIR%\openclaw.json" >nul
|
||||
echo Config migrated
|
||||
) else (
|
||||
echo First run - creating default config...
|
||||
(echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json"
|
||||
echo Config created
|
||||
)
|
||||
echo.
|
||||
)
|
||||
|
||||
REM Sync config from legacy location
|
||||
if exist "%DATA_DIR%\config.json" if not exist "%STATE_DIR%\openclaw.json" (
|
||||
copy "%DATA_DIR%\config.json" "%STATE_DIR%\openclaw.json" >nul
|
||||
)
|
||||
|
||||
REM Check dependencies
|
||||
if not exist "%CORE_DIR%\node_modules" (
|
||||
echo First run - installing dependencies...
|
||||
|
||||
Reference in New Issue
Block a user