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,6 +72,11 @@ mkdir -p "$STATE_DIR" "$DATA_DIR/memory" "$DATA_DIR/backups" "$DATA_DIR/logs"
|
|||||||
|
|
||||||
# ---- 5. Default config ----
|
# ---- 5. Default config ----
|
||||||
if [ ! -f "$CONFIG_FILE" ]; then
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
|
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}"
|
echo -e " ${YELLOW}First run - creating default config...${NC}"
|
||||||
cat > "$CONFIG_FILE" << 'CFGEOF'
|
cat > "$CONFIG_FILE" << 'CFGEOF'
|
||||||
{
|
{
|
||||||
@@ -82,14 +87,10 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
|||||||
}
|
}
|
||||||
CFGEOF
|
CFGEOF
|
||||||
echo -e " ${GREEN}Config created${NC}"
|
echo -e " ${GREEN}Config created${NC}"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
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) ----
|
# ---- 6. Set environment (portable mode) ----
|
||||||
export OPENCLAW_HOME="$DATA_DIR"
|
export OPENCLAW_HOME="$DATA_DIR"
|
||||||
export OPENCLAW_STATE_DIR="$STATE_DIR"
|
export OPENCLAW_STATE_DIR="$STATE_DIR"
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ if "!USE_NODE!"=="usb" (
|
|||||||
echo 解压中...
|
echo 解压中...
|
||||||
mkdir "%INSTALL_TARGET%\runtime\node-win-x64" 2>nul
|
mkdir "%INSTALL_TARGET%\runtime\node-win-x64" 2>nul
|
||||||
powershell -command "Expand-Archive -Path '%TEMP%\!NODE_ZIP!' -DestinationPath '%TEMP%\node-extract' -Force"
|
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
|
rmdir /s /q "%TEMP%\node-extract" 2>nul
|
||||||
del "%TEMP%\!NODE_ZIP!" 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%\backups" mkdir "%DATA_DIR%\backups"
|
||||||
if not exist "%DATA_DIR%\logs" mkdir "%DATA_DIR%\logs"
|
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" (
|
if not exist "%STATE_DIR%\openclaw.json" (
|
||||||
|
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 First run - creating default config...
|
||||||
(echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json"
|
(echo {"gateway":{"mode":"local","auth":{"token":"uclaw"}}})>"%STATE_DIR%\openclaw.json"
|
||||||
echo Config created
|
echo Config created
|
||||||
|
)
|
||||||
echo.
|
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
|
REM Check dependencies
|
||||||
if not exist "%CORE_DIR%\node_modules" (
|
if not exist "%CORE_DIR%\node_modules" (
|
||||||
echo First run - installing dependencies...
|
echo First run - installing dependencies...
|
||||||
|
|||||||
Reference in New Issue
Block a user