From 90404ab44ff7cced1747757e193235a3e877cd86 Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 5 Dec 2024 12:40:33 +0000 Subject: [PATCH] Feat: batch file added to automate synchronisation of a user's minecraft instance with the server mods, resources, scripts, etc. --- sync_instance_with_server.bat | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sync_instance_with_server.bat diff --git a/sync_instance_with_server.bat b/sync_instance_with_server.bat new file mode 100644 index 0000000..69a812b --- /dev/null +++ b/sync_instance_with_server.bat @@ -0,0 +1,58 @@ +@echo off +setlocal EnableDelayedExpansion + +:: Configuration +set "REPO_URL=https://github.com/Teddy-1024/minecraft_server_zombie.git" +set "SYNC_FOLDERS=mods config kubejs defaultconfigs scripts resources patchouli_books pfm modernfix" + +:: Clear screen and show header +cls +echo Minecraft Server Sync Tool +echo ======================== +echo. + +:: Check if git is installed +where git >nul 2>&1 +if %ERRORLEVEL% NEQ 0 ( + echo Git is not installed or not in PATH. + echo Please install Git from https://git-scm.com/downloads + pause + exit /b 1 +) + +:: Process each folder +for %%F in (%SYNC_FOLDERS%) do ( + echo Processing %%F... + + :: Create directory if it doesn't exist + if not exist "%~dp0%%F" mkdir "%~dp0%%F" + + :: Initialize git in the directory if not already done + if not exist "%~dp0%%F\.git" ( + cd "%~dp0%%F" + git init + git remote add origin "%REPO_URL%" + :: Configure sparse checkout + git config core.sparseCheckout true + :: Set up sparse checkout to only get this directory + echo %%F> .git/info/sparse-checkout + :: Initial fetch of just this directory + git fetch --depth 1 origin main + git checkout main + ) else ( + :: Just pull updates if git is already initialized + cd "%~dp0%%F" + git fetch origin main + git reset --hard origin/main + ) +) + +echo. +echo Sync completed successfully! +echo. +echo This sync has: +echo - Updated all tracked files from the repository +echo - Kept your local untracked files intact +echo. + +pause \ No newline at end of file