diff --git a/portable/Mac-Start.command b/portable/Mac-Start.command index 0f635be..6c0ce05 100755 --- a/portable/Mac-Start.command +++ b/portable/Mac-Start.command @@ -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" diff --git a/portable/Windows-Install.bat b/portable/Windows-Install.bat index 3734c7b..37d2be7 100644 --- a/portable/Windows-Install.bat +++ b/portable/Windows-Install.bat @@ -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 diff --git a/portable/Windows-Start.bat b/portable/Windows-Start.bat index dd733ad..3dad924 100644 --- a/portable/Windows-Start.bat +++ b/portable/Windows-Start.bat @@ -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...