Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set config=SSConfig.ini
- echo Loading settings...
- :: Here we set up the default values.
- set AdditionalArgs=-server -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -XX:ParallelGCThreads=4 -XX:+UseConcMarkSweepGC -XX:ThreadStackSize=256k
- set ArchiveDir=backups
- set ArchiveName=%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.7z
- set AutoExit=false
- set BackupDefault=N
- set BackupTimeout=5
- set CleanupDays=10
- set CompressionLevel=9
- set JarFile=minecraft_server.jar
- set MaxRam=1024M
- set WorldFolder=world
- :: And load the config.ini file.
- IF EXIST %config% (
- :: For each line in the config file
- for /f "eol=# delims=" %%x in (%config%) do (set "%%x")
- echo Settings loaded!
- ) ELSE (
- echo Settings file ^(%config%^) not found! Creating the default one!
- CALL :CREATE_INI
- IF AutoExit==true exit
- )
- CHOICE /C YN /T %BackupTimeout% /D %BackupDefault% /N /M "Backup running in %BackupTimeout% seconds. Press Y to start now or N to cancel..."
- :: If we chose to run the backup...
- IF NOT ERRORLEVEL 2 (
- call 7z.exe a -mx%CompressionLevel% %ArchiveDir%/%ArchiveName% %WorldFolder%/
- forfiles -p %ArchiveDir% -s -m *.* -d -%CleanupDays% -c "cmd /c del @PATH"
- echo Backup run!
- ) ELSE (
- echo Backup cancelled... continuing.
- )
- echo.
- echo Server starting...
- echo Checking for JAR file...
- IF NOT EXIST %JarFile% (
- echo %JarFile% does not exist... Check settings file!
- IF AutoExit==true exit
- GOTO:EOF
- )
- :: Start the server...
- echo Launch command will be: javaw -Xmx%MaxRam% %AdditionalArgs% -jar %JarFile%
- start "Minecraft Server Launcher" /REALTIME /MIN javaw -Xmx%MaxRam% %AdditionalArgs% -jar %JarFile%
- IF AutoExit==true exit
- GOTO:EOF
- :CREATE_INI
- :: This is the content of the default settings file
- echo # ServerStart.bat settings file.>%config%
- echo # Delete and run ServerStart.bat to recreate with defaults.>>%config%
- echo # Deleting a kay=value forces it to default.>>%config%
- echo.>>%config%
- echo # How long to wait, in seconds, before choosing the default backup mode.>>%config%
- echo BackupTimeout=5 >>%config%
- echo.>>%config%
- echo # Default backup option. ^(Y for yes, N for no^)>>%config%
- echo BackupDefault=Y>>%config%
- echo.>>%config%
- echo # Minecraft Jar file. ^(Does not currently support .exe server^)>>%config%
- echo JarFile=minecraft_server.jar>>%config%
- echo.>>%config%
- echo # Maximum RAM to allot the server. Postfix is either K ^(Kilobytes^), M ^(Megabytes^), or G ^(Gigabytes^)>>%config%
- echo MaxRam=1024M>>%config%
- echo.>>%config%
- echo # Any additional Java arguments. Here are some useful defaults...>>%config%
- echo AdditionalArgs=-server -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+AggressiveOpts -XX:ParallelGCThreads=4 -XX:+UseConcMarkSweepGC -XX:ThreadStackSize=256k>>%config%
- echo.>>%config%
- echo # 7-zip compression level ^(for backups^). Values range from 0 ^(no compression^) to 1 through 9 ^(Low through Ultra compression^)>>%config%
- echo CompressionLevel=9 >>%config%
- echo.>>%config%
- echo # 7-zip archive file name. Defaults to YEAR-MONTH-DAY.7z. ^(E.g. 2014-09-29.7z^)>>%config%
- echo ArchiveName=%%DATE:~-4%%-%%DATE:~4,2%%-%%DATE:~7,2%%.7z>>%config%
- echo.>>%config%
- echo # The folder to store backups in. Prefers relative paths.>>%config%
- echo ArchiveDir=backups>>%config%
- echo.>>%config%
- echo # The name of the world save folder.>>%config%
- echo WorldFolder=world>>%config%
- echo.>>%config%
- echo # The number of days to keep backups for. ^(E.g., with a default value of 10, backups older than 10 days are deleted.^)>>%config%
- echo CleanupDays=10 >>%config%
- echo.>>%config%
- echo # Whether or not the script automatically closes the command window after launching the server. (true/false)>>%config%
- echo AutoExit=true>>%config%
- echo Settings file written!
- IF AutoExit==true exit
- EXIT /B
Advertisement
Add Comment
Please, Sign In to add comment