From 48f1663b39b118802658acc88b6add7aa8b02006 Mon Sep 17 00:00:00 2001 From: yuejiajun <1530620364@qq.com> Date: Tue, 19 Aug 2025 23:48:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/Resources/quick.bat | 134 ++++++++++++++++++++++++++++++--------- 1 file changed, 104 insertions(+), 30 deletions(-) diff --git a/base/Resources/quick.bat b/base/Resources/quick.bat index 18a8421..05eed38 100644 --- a/base/Resources/quick.bat +++ b/base/Resources/quick.bat @@ -4,39 +4,113 @@ chcp 65001 >nul title Quick Start set "SCRIPT_DIR=%~dp0" +call :log_info SCRIPT_DIR=%SCRIPT_DIR% + cd /d "%SCRIPT_DIR%" -if exist "%SCRIPT_DIR%\io\minio-server.bat" ( - echo. - echo [INFO] Starting MinIO... - cd "%SCRIPT_DIR%\io\" - start "MinIO Startup" /B cmd /c "minio-server.bat" - if errorlevel 1 ( - echo [ERROR] MinIO start Failed. - pause && exit /b 1 - ) -) +call :Start "Redis" "%SCRIPT_DIR%redis" "redis-server.exe" "redis.conf" -if exist "%SCRIPT_DIR%\redis\redis-server.exe" ( - echo. - echo [INFO] Starting Redis... - cd "%SCRIPT_DIR%\redis" - start "Redis Startup" /B cmd /c "redis-server.exe redis.conf" - if errorlevel 1 ( - echo [ERROR] Redis start Failed. - pause && exit /b 1 - ) -) +call :Start "MinIO" "%SCRIPT_DIR%io" "minio-server.bat" -if exist "%SCRIPT_DIR%\rocketmq\sbin\rocketmq.bat" ( - echo. - echo [INFO] Starting RocketMQ... - cd "%SCRIPT_DIR%\rocketmq\sbin\" - start "RocketMQ Startup" /B cmd /c "rocketmq.bat" - if errorlevel 1 ( - echo [ERROR] RocketMQ start Failed. - pause && exit /b 1 - ) -) +call :Start "RocketMQ" "%SCRIPT_DIR%rocketmq\sbin" "rocketmq.bat" pause && exit /b 0 + +:log_info +call :GetFormattedTime +echo [%FormattedTime%] - [INFO] - %* +exit /b 0 + +:log_warn +call :GetFormattedTime +echo [%FormattedTime%] - [WARN] - %* +exit /b 0 + +:log_error +call :GetFormattedTime +echo [%FormattedTime%] - [ERROR] - %* +exit /b 0 + +:rar +call :RandomStr 16 RAND_NAME +set TARGET_DIR=%temp%\!CURRENT_DATE! +if not exist "!TARGET_DIR!" mkdir "!TARGET_DIR!" + +call :log_info Creating encrypted archive... +rar a -ep1 -hp"Password#!CURRENT_DATE!" "!TARGET_DIR!\!RAND_NAME!.rar" "!TEMP_SQL_DIR!\*" >nul + +if %errorLevel% neq 0 ( + call :log_error Error: Failed to create encrypted archive + pause && exit /b 1 +) + +if not exist "%SCRIPT_PATH%/patch/!CURRENT_DATE!" mkdir "%SCRIPT_PATH%/patch/!CURRENT_DATE!" +call :log_info TEMP_SQL_DIR: %TEMP_SQL_DIR% + +mv !TEMP_SQL_DIR!/*.rar "%SCRIPT_PATH%/patch/!CURRENT_DATE!" +rd /s /q "!TEMP_SQL_DIR!" 2>nul + +call :log_info Encryption completed successfully! +call :log_info Archive: !TARGET_DIR!\!RAND_NAME!.rar +call :log_info Password: Password#!CURRENT_DATE! + +exit /b 0 + +:RandomStr +setlocal +set "len=%~1" +set "varname=%~2" +if "!varname!"=="" set "varname=RAND_STR" + +set "chars=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" +set "random_str=" + +for /l %%i in (1,1,!len!) do ( + set /a rand_index=!random! %% 62 + call set "char=%%chars:~!rand_index!,1%%" + set "random_str=!random_str!!char!" +) + +endlocal & set "%varname%=%random_str%" +exit /b 0 + +:Start +setlocal +set DESCRIPTION=%1 +set SCRIPT_PATH=%2 +set SCRIPT_FILE=%3 + +set PARAMS= +shift /3 +:params_loop +if not "%~1"=="" ( + set "PARAMS=%PARAMS% %~3" + shift + goto params_loop +) + +if exist "%SCRIPT_PATH%\%SCRIPT_FILE%" ( + echo. + call :log_info Starting %DESCRIPTION%... + cd /d "%SCRIPT_PATH%" + start "%DESCRIPTION% Startup" /B cmd /c "%SCRIPT_FILE% %PARAMS%" + if errorlevel 1 ( + call :log_error %DESCRIPTION% start Failed. + pause && exit /b 1 + ) +) else ( + call :log_error Script file not found: %SCRIPT_PATH%\%SCRIPT_FILE% + pause && exit /b 1 +) +endlocal +exit /b 0 + +:GetFormattedTime +for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "datetime=%%a" +set "FormattedTime=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2% %datetime:~8,2%:%datetime:~10,2%:%datetime:~12,2%" +exit /b 0 + +:GetDate +for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "datetime=%%a" +set "FormattedDate=%datetime:~0,4%%datetime:~4,2%%datetime:~6,2%" +exit /b 0 \ No newline at end of file