Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem Description: This script makes sure the mod files on the server are identical to the corresponding files in the games mod dir (which are automatically updated and therefor always the current version).
- rem Version: 1.3
- rem Date: 2020-04-12
- cls
- chcp 65001 >nul 2>&1
- setlocal
- rem Path to where the servers mods are installed. Don't put a backslash at the end.
- set serverModsPath=D:\Spel\steamapps\common\DayZServer
- rem Path to where the servers keys are installed. Don't put a backslash at the end.
- set serverKeysPath=D:\Spel\steamapps\common\DayZServer\keys
- rem Path to where the games mods are installed. Don't put a backslash at the end.
- set gameModsPath=D:\Spel\steamapps\common\DayZ\!Workshop
- echo.
- echo Detta skript kontrollerar så alla moddar installerade på servern är identiska med motsvarande moddar som är installerad i spelet.
- echo.
- echo Serverns modkatalog: %serverModsPath%
- echo Serverns nyckelkatalog: %serverKeysPath%
- echo Spelets modkatalog: %gameModsPath%
- echo.
- rem Check to make sure the last character in the paths isn't "\".
- if %serverModsPath:~-1% ==\ (
- echo Ett fel uppstod: Det sista tecknet i sökvägen till serverns modkatalog får inte vara "\". Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- if %serverKeysPath:~-1% ==\ (
- echo Ett fel uppstod: Det sista tecknet i sökvägen till serverns nyckelkatalog får inte vara "\". Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- if %gameModsPath:~-1% ==\ (
- echo Ett fel uppstod: Det sista tecknet i sökvägen till spelets modkatalog får inte vara "\". Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- rem Check to make sure the paths exist.
- if not exist "%serverModsPath%" (
- echo Ett fel uppstod: Serverns modkatalog "%serverModsPath%" kunde inte hittas. Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- if not exist "%serverKeysPath%" (
- echo Ett fel uppstod: Serverns nyckelkatalog "%serverKeysPath%" kunde inte hittas. Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- if not exist "%gameModsPath%" (
- echo Ett fel uppstod: Spelets modkatalog "%gameModsPath%" kunde inte hittas. Skriptet har avbrutits.
- echo Tryck ENTER för att avsluta skriptet och kontrollera inställningarna.
- pause >nul
- exit /b 0
- )
- echo Tryck ENTER för att påbörja kontrollen.
- pause >nul
- echo.
- echo.
- set /a modsMirroredNumber=0
- set /a keyFilesCopied=0
- rem Loop through all the folders starting with an @ found in the servers mod path and mirror them if needed as well as copy their keys to the servers key folder.
- for /D %%G in ("%serverModsPath%\@*") do (
- set modName=%%~nxG
- echo Modnamn: %%~nxG
- call :MirrorMod
- call :CopyKey
- echo.
- )
- rem Present a summery over what was done.
- echo Summering
- echo ---------------------------------------
- echo Antal moddar som uppdaterades: %modsMirroredNumber%
- echo.
- if not %modsMirroredNumber%==0 (
- echo Följande moddar uppdaterades:
- for /F "tokens=2 delims==" %%s in ('set modsMirroredNames[') do echo %%s
- echo.
- )
- echo Antal nycklar som kopierades in till serverns keys-katalog: %keyFilesCopied%
- echo Obs: Nycklarna kopieras in varje gång skriptet körs vare sig det behövs eller ej.
- echo.
- echo Skriptet är färdigt.
- echo Tryck ENTER för att stänga ned fönstret.
- pause >nul
- endlocal
- exit /b %errorlevel%
- :MirrorMod
- rem Make sure the first character of the mod directory is "@". This is just a precaution in case anything else slips through the name mask in the directory listing function above, for whatever reason.
- set modNameFirstCharacter=%modName:~0,1%
- if not %modNameFirstCharacter%==@ (
- echo Status: Moddkatalogens namn börjar inte med ett "@". Kontroll av denna mod avbryts.
- exit /b 0
- )
- rem Make sure the mod on the server actually exists in the games mod directory as well.
- if not exist "%gameModsPath%\%modName%" (
- echo Status: Kunde inte hitta moddens motsvarande katalog "%gameModsPath%\%modName%" i spelkatalogen. Kontroll av denna mod avbryts.
- exit /b 0
- )
- rem Mirror the games mod to the servers mod.
- robocopy "%gameModsPath%\%modName%" "%serverModsPath%\%modName%" /mir /nfl /ndl /njh /njs /nc /ns /np >nul
- if %errorlevel%==1 (
- set /a modsMirroredNumber=%modsMirroredNumber%+1
- call :AddModToMirroredList %modsMirroredNumber%
- echo Status: Ej identisk. Serverns mod uppdaterades.
- exit /b 0
- )
- echo Status: Identisk
- exit /b 0
- :AddModToMirroredList
- set /a currentIndex=%1
- set modsMirroredNames[%currentIndex%]=%modName%
- exit /b 0
- :CopyKey
- rem The quotation marks on the destination path needs to be escaped using \ in order for forfiles to work, since they are quotes within a quote.
- forfiles /p "%serverModsPath%\%modName%" /s /m *.bikey /c "cmd /c xcopy /y @path \"%serverKeysPath%\"" >nul 2>&1
- if %errorlevel%==0 (
- set /a keyFilesCopied=%keyFilesCopied%+1
- echo Nyckelfil: Kopierades
- exit /b 0
- )
- if %errorlevel%==1 (
- echo Nyckelfil: Ingen nyckel hittades till denna mod.
- exit /b 0
- )
- exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement