76 lines
3.1 KiB
Batchfile
76 lines
3.1 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
:: --------- Define Paths ---------
|
|
set "LOG_FILE=%~dp0update.log"
|
|
set "GIT_PORTABLE=%~dp0gitportable\bin\git.exe"
|
|
set "MAIN_REPO_DIR=%~dp0" :: The current folder is the main repo
|
|
set "SCRIPTS_REPO_URL=http://nathantech.net:3000/CosmicRage/VIPMudCosmicRageScripts.git" :: The main repo URL for scripts
|
|
set "SCRIPTS_TEMP_DIR=%MAIN_REPO_DIR%\temp_scripts" :: Temporary directory for cloning scripts
|
|
set "SOUNDS_DIR=%MAIN_REPO_DIR%sounds"
|
|
set "SOUNDS_REPO_URL=https://nathantech.net:3000/CosmicRage/CosmicRageSounds.git"
|
|
set "REPO_SUBFOLDER=wav"
|
|
|
|
:: --------- Setup Log ---------
|
|
echo [%DATE% %TIME%] Starting update process... > "%LOG_FILE%"
|
|
echo [%DATE% %TIME%] GitPortable: %GIT_PORTABLE% >> "%LOG_FILE%"
|
|
echo [%DATE% %TIME%] Main repository directory: %MAIN_REPO_DIR% >> "%LOG_FILE%"
|
|
echo [%DATE% %TIME%] Sounds directory: %SOUNDS_DIR% >> "%LOG_FILE%"
|
|
echo [%DATE% %TIME%] Temporary scripts directory: %SCRIPTS_TEMP_DIR% >> "%LOG_FILE%"
|
|
|
|
:: --------- Check GitPortable Exists ---------
|
|
if not exist "%GIT_PORTABLE%" (
|
|
echo [%DATE% %TIME%] ERROR: GitPortable not found at %GIT_PORTABLE% >> "%LOG_FILE%"
|
|
echo ERROR: GitPortable not found.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
:: --------- Clone the Main Repo into Temporary Directory ---------
|
|
if exist "%SCRIPTS_TEMP_DIR%" (
|
|
echo [%DATE% %TIME%] Deleting existing temporary scripts directory... >> "%LOG_FILE%"
|
|
rd /s /q "%SCRIPTS_TEMP_DIR%" >nul 2>&1
|
|
)
|
|
|
|
echo [%DATE% %TIME%] Cloning main repo into temporary directory... >> "%LOG_FILE%"
|
|
"%GIT_PORTABLE%" clone "%SCRIPTS_REPO_URL%" "%SCRIPTS_TEMP_DIR%" >> "%LOG_FILE%" 2>&1
|
|
if errorlevel 1 (
|
|
echo [%DATE% %TIME%] ERROR: Git clone failed for main scripts repo. >> "%LOG_FILE%"
|
|
echo ERROR: Failed to clone the main scripts repo. Check network or GitPortable version.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
:: --------- Replace Files in the Main Directory ---------
|
|
echo [%DATE% %TIME%] Replacing files in the main directory... >> "%LOG_FILE%"
|
|
|
|
:: Use robocopy to copy all files and subdirectories from temp to main repo directory
|
|
robocopy "%SCRIPTS_TEMP_DIR%" "%MAIN_REPO_DIR%" /E /PURGE >> "%LOG_FILE%" 2>&1
|
|
if errorlevel 1 (
|
|
echo [%DATE% %TIME%] ERROR: Robocopy failed to copy files. >> "%LOG_FILE%"
|
|
echo ERROR: Robocopy failed to copy files. Check the log for details.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
:: --------- Clean Up Temporary Directory ---------
|
|
rd /s /q "%SCRIPTS_TEMP_DIR%" >nul 2>&1
|
|
|
|
:: --------- Pull Updates for Sounds Repo ---------
|
|
if exist "%SOUNDS_DIR%" (
|
|
echo [%DATE% %TIME%] Pulling updates for the sounds repository... >> "%LOG_FILE%"
|
|
"%GIT_PORTABLE%" -C "%SOUNDS_DIR%" pull >> "%LOG_FILE%" 2>&1
|
|
if errorlevel 1 (
|
|
echo [%DATE% %TIME%] ERROR: Failed to pull updates for the sounds repository. >> "%LOG_FILE%"
|
|
echo ERROR: Failed to pull updates for the sounds repository. Check the log for details.
|
|
)
|
|
) else (
|
|
echo [%DATE% %TIME%] ERROR: Sounds directory not found at %SOUNDS_DIR% >> "%LOG_FILE%"
|
|
echo ERROR: Sounds directory not found at %SOUNDS_DIR%.
|
|
)
|
|
|
|
:: --------- Final Logging ---------
|
|
echo [%DATE% %TIME%] Update process completed. >> "%LOG_FILE%"
|
|
pause
|
|
exit /b
|