Fika-Tarkov/Download Modpack.bat

140 lines
4.0 KiB
Batchfile
Raw Normal View History

2025-01-03 13:24:33 -05:00
@echo off
:: Setting initial paths
set "mo2_install=%cd%"
echo %mo2_install%
set "repository=%mo2_install%\Fika-Tarkov"
echo %repository%
:: Set path to the portable Git executable (change this if needed)
set "portable_git=%mo2_install%\PortableGit\bin\git.exe"
:: Check if curl is installed
where curl >nul 2>nul
if %errorlevel% neq 0 (
echo ERROR: curl is not installed or not in your PATH.
echo Please install curl or ensure it is in your PATH and try again.
pause
exit /b
)
:: Checking if Git Portable exists
if not exist "%mo2_install%\PortableGit\bin\git.exe" (
echo ----
echo Installing Portable Git...
:: Download Git Portable
curl -L -o PortableGit-2.47.1-64-bit.7z.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/PortableGit-2.47.1-64-bit.7z.exe
if %errorlevel% neq 0 (
echo ERROR: Failed to download Git Portable. Check your internet connection and try again.
pause
exit /b
)
:: Run the portable executable to setup
start PortableGit-2.47.1-64-bit.7z.exe
echo ----
set /p userInput=Press Enter once the Portable Git installation has finished.
)
:: Check if 7z is installed
where 7z >nul 2>nul
if %errorlevel% neq 0 (
echo ERROR: 7z is not installed or not in your PATH.
echo Please install 7-Zip or NanaZip and add it to your PATH.
pause
exit /b
)
IF EXIST "%mo2_install%\ModOrganizer.exe" (
call :UpdateModpack
exit /B 0
) ELSE (
call :InstallModpack
exit /B 0
)
:UpdateModpack
echo ----
echo Existing installation detected! Updating modpack, please wait.
timeout 5
:: Clone or update the Git repository
if not exist "Fika-Tarkov\.git" (
echo ----
echo Cloning repository...
"%portable_git%" clone https://files.moddinglounge.com/Rage/Fika-Tarkov.git
) else (
echo ----
echo Repository already exists. Pulling latest changes...
cd %repository%
git fetch --all
git reset --hard origin/main
)
echo ----
echo Moving files to root folder...
robocopy "%repository%/mods" "%mo2_install%/mods" /E
robocopy "%repository%/profiles" "%mo2_install%/profiles" /E
robocopy "%repository%/stylesheets" "%mo2_install%/stylesheets" /E
robocopy "%repository%/plugins" "%mo2_install%/plugins" /E
echo ----
echo Update complete. You may now launch the game.
pause
exit /B 0
:InstallModpack
setlocal enableextensions disabledelayedexpansion
echo ----
echo No existing installation detected. Downloading modpack.
timeout 5
:: Requiring user input for game path
:: Download MO2
curl -L -o MO2.7z https://github.com/ModOrganizer2/modorganizer/releases/download/v2.5.2/Mod.Organizer-2.5.2.7z
if %errorlevel% neq 0 (
echo ERROR: Failed to download the archive. Check your internet connection and try again.
pause
exit /b
)
:: Confirm the file exists
if not exist "MO2.7z" (
echo ERROR: Download completed, but the file MO2.7z was not found.
echo Please check your internet connection or the download URL.
pause
exit /b
)
:: Extracting MO2 and installing
7z x MO2.7z
if %errorlevel% neq 0 (
echo ERROR: Failed to extract the archive. Ensure the archive is valid and try again.
pause
exit /b
)
:: Deleting the archive
del MO2.7z
echo ----
echo Cloning repository...
"%portable_git%" clone https://files.moddinglounge.com/Rage/Fika-Tarkov.git
echo ----
echo Moving files to root folder...
robocopy "%repository%/mods" "%mo2_install%/mods" /E
robocopy "%repository%/profiles" "%mo2_install%/profiles" /E
robocopy "%repository%/stylesheets" "%mo2_install%/stylesheets" /E
robocopy "%repository%/plugins" "%mo2_install%/plugins" /E
echo ----
echo Installation complete. Launch ModOrganizer.exe and follow the remaining instructions.
pause
exit /B 0