Add server template
This commit is contained in:
parent
71b19acd8b
commit
56c9676891
3 changed files with 126 additions and 0 deletions
52
server/startserver.bat
Normal file
52
server/startserver.bat
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
@echo off
|
||||
set MAX_RAM=5G
|
||||
set MIN_RAM=5G
|
||||
set FORGE_VERSION=40.1.79
|
||||
:: To use a specific Java runtime, set an environment variable named ATM7_JAVA to the full path of java.exe.
|
||||
|
||||
set INSTALLER="%~dp0forge-1.18.2-%FORGE_VERSION%-installer.jar"
|
||||
set FORGE_URL="http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.18.2-%FORGE_VERSION%/forge-1.18.2-%FORGE_VERSION%-installer.jar"
|
||||
|
||||
:JAVA
|
||||
if not defined ATM7_JAVA (
|
||||
set ATM7_JAVA=java
|
||||
)
|
||||
|
||||
"%ATM7_JAVA%" -version 1>nul 2>nul || (
|
||||
echo Minecraft 1.18 requires Java 17 - Java not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for /f tokens^=2-5^ delims^=.-_^" %%j in ('"%ATM7_JAVA%" -fullversion 2^>^&1') do set "jver=%%j"
|
||||
if not %jver% == 17 (
|
||||
echo Minecraft 1.18 requires Java 17 - found Java %jver%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:FORGE
|
||||
setlocal
|
||||
cd /D "%~dp0"
|
||||
if not exist "libraries" (
|
||||
echo Forge not installed, installing now.
|
||||
if not exist %INSTALLER% (
|
||||
echo No Forge installer found, downloading from %FORGE_URL%
|
||||
bitsadmin.exe /rawreturn /nowrap /transfer forgeinstaller /download /priority FOREGROUND %FORGE_URL% %INSTALLER%
|
||||
)
|
||||
|
||||
echo Running Forge installer.
|
||||
"%ATM7_JAVA%" -jar %INSTALLER% -installServer
|
||||
)
|
||||
|
||||
if not exist "server.properties" (
|
||||
echo level-type=skyblockbuilder\:skyblock> "server.properties"
|
||||
)
|
||||
|
||||
:START
|
||||
"%ATM7_JAVA%" -Xmx%MAX_RAM% -Xms%MIN_RAM% -XX:+UseZGC @libraries/net/minecraftforge/forge/1.18.2-%FORGE_VERSION%/win_args.txt nogui
|
||||
|
||||
echo Restarting automatically in 10 seconds (press Ctrl + C to cancel)
|
||||
timeout /t 10 /nobreak > NUL
|
||||
goto:START
|
||||
pause
|
||||
64
server/startserver.sh
Normal file
64
server/startserver.sh
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
MAX_RAM=5G
|
||||
MIN_RAM=5G
|
||||
FORGE_VERSION=40.1.79
|
||||
# To use a specific Java runtime, set an environment variable named ATM7_JAVA to the full path of java.exe.
|
||||
|
||||
INSTALLER="forge-1.18.2-$FORGE_VERSION-installer.jar"
|
||||
FORGE_URL="http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.18.2-$FORGE_VERSION/forge-1.18.2-$FORGE_VERSION-installer.jar"
|
||||
|
||||
pause() {
|
||||
printf "%s\n" "Press enter to continue..."
|
||||
read ans
|
||||
}
|
||||
|
||||
if ! command -v "${ATM7_JAVA:-java}" >/dev/null 2>&1; then
|
||||
echo "Minecraft 1.18 requires Java 17 - Java not found"
|
||||
pause
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAVA_VERSION=$("${ATM7_JAVA:-java}" -fullversion 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1)
|
||||
if [ ! $JAVA_VERSION = "17" ]; then
|
||||
echo "Minecraft 1.18 requires Java 17 - found Java $JAVA_VERSION"
|
||||
pause
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
if [ ! -d libraries ]; then
|
||||
echo "Forge not installed, installing now."
|
||||
if [ ! -f "$INSTALLER" ]; then
|
||||
echo "No Forge installer found, downloading now."
|
||||
which wget >> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "DEBUG: (wget) Downloading $FORGE_URL"
|
||||
wget -O "$INSTALLER" "$FORGE_URL"
|
||||
else
|
||||
which curl >> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "DEBUG: (curl) Downloading $FORGE_URL"
|
||||
curl -o "$INSTALLER" -L "$FORGE_URL"
|
||||
else
|
||||
echo "Neither wget or curl were found on your system. Please install one and try again"
|
||||
pause
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Running Forge installer."
|
||||
"${ATM7_JAVA:-java}" -jar "$INSTALLER" -installServer
|
||||
fi
|
||||
|
||||
if [ ! -e server.properties ]; then
|
||||
echo "level-type=skyblockbuilder\\:skyblock" > server.properties
|
||||
fi
|
||||
|
||||
while true
|
||||
do
|
||||
"${ATM7_JAVA:-java}" -Xmx$MAX_RAM -Xms$MIN_RAM -XX:+UseZGC @libraries/net/minecraftforge/forge/1.18.2-$FORGE_VERSION/unix_args.txt nogui
|
||||
echo "Restarting automatically in 10 seconds (press Ctrl + C to cancel)"
|
||||
sleep 10
|
||||
done
|
||||
10
server/user_jvm_args.txt
Normal file
10
server/user_jvm_args.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Xmx and Xms set the maximum and minimum RAM usage, respectively.
|
||||
# They can take any number, followed by an M or a G.
|
||||
# M means Megabyte, G means Gigabyte.
|
||||
# For example, to set the maximum to 3GB: -Xmx3G
|
||||
# To set the minimum to 2.5GB: -Xms2500M
|
||||
|
||||
# A good default for a modded server is 4GB.
|
||||
# Uncomment the next line to set it.
|
||||
# -Xmx4G
|
||||
-Xms6G -Xmx6G -XX:+UseZGC
|
||||
Loading…
Reference in a new issue