Feat: batch file added to automate synchronisation of a user's minecraft instance with the server mods, resources, scripts, etc.
This commit is contained in:
58
sync_instance_with_server.bat
Normal file
58
sync_instance_with_server.bat
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user