-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: dynamically install loaders based on environment
- Loading branch information
1 parent
1679ba9
commit b6ad815
Showing
9 changed files
with
214 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
JAR_NAME="fabric-server-mc.${MINECRAFT_VERSION}-loader.${FABRIC_LOADER_VERSION}-launcher.${FABRIC_INSTALLER_VERSION}.jar" | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
# echo "Downloading Fabric"; | ||
|
||
manifest=$(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json') | ||
version=$(jq -c ".versions[] | select( .id == \"$MINECRAFT_VERSION\" )" <<< "$manifest") | ||
version_manifest=$(curl -s "$(jq -r ".url" <<< "$version")") | ||
|
||
server_url=$(jq -r '.downloads.server.url' <<< "$version_manifest") | ||
|
||
curl -Lso "$JAR_NAME" -J "$server_url" | ||
fi | ||
|
||
echo "$JAR_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
JAR_NAME="forge-${MINECRAFT_VERSION}-${FORGE_VERSION}-installer.jar" | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
echo "Downloading Forge"; | ||
curl -LsOJ "https://maven.minecraftforge.net/net/minecraftforge/forge/${MINECRAFT_VERSION}-${FORGE_VERSION}/${JAR_NAME}" | ||
java -jar "${JAR_NAME}" --installServer | ||
fi | ||
|
||
echo "$JAR_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
BASE_URL="https://maven.neoforged.net/releases/net/neoforged" | ||
JAR_NAME="neoforge-${NEO_VERSION}-installer.jar" | ||
|
||
if [ "$MINECRAFT_VERSION" = "1.20.1" ]; then | ||
BASE_URL="$BASE_URL/forge/1.20.1-${NEO_VERSION}" | ||
JAR_NAME="forge-1.20.1-${NEO_VERSION}-installer.jar" | ||
else | ||
BASE_URL="$BASE_URL/neoforge/${NEO_VERSION}" | ||
fi | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
echo "Downloading NeoForge"; | ||
|
||
server_url="${BASE_URL}/${JAR_NAME}" | ||
|
||
curl -Lso "$JAR_NAME" -J "$server_url" | ||
|
||
java -jar "$JAR_NAME" --installServer | ||
|
||
echo "" >> user_jvm_args.txt | ||
echo "$JAVA_OPTS" >> user_jvm_args.txt | ||
fi | ||
|
||
echo "$JAR_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
JAR_NAME="paper-${MINECRAFT_VERSION}-${PAPER_BUILD}.jar" | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
echo "Downloading Paper"; | ||
|
||
server_url=https://api.papermc.io/v2/projects/paper/versions/${MINECRAFT_VERSION}/builds/${PAPER_BUILD}/downloads/${JAR_NAME} | ||
|
||
curl -Lso "$JAR_NAME" -J "$server_url" | ||
fi | ||
|
||
echo "$JAR_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
JAR_NAME="server-${MINECRAFT_VERSION}.jar" | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
# echo "Downloading Minecraft"; | ||
|
||
manifest=$(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json') | ||
version=$(jq -c ".versions[] | select( .id == \"$MINECRAFT_VERSION\" )" <<< "$manifest") | ||
version_manifest=$(curl -s "$(jq -r ".url" <<< "$version")") | ||
|
||
server_url=$(jq -r '.downloads.server.url' <<< "$version_manifest") | ||
|
||
curl -Lso "$JAR_NAME" -J "$server_url" | ||
fi | ||
|
||
echo "$JAR_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
#! /usr/bin/env bash | ||
set -e | ||
set -ex | ||
|
||
JAR_NAME="server-${MINECRAFT_VERSION}.jar" | ||
env | ||
|
||
PUID=${PUID:-1000} | ||
PGID=${PGID:-1000} | ||
USER=${USER:-"minecraft"} | ||
|
||
set-up-user.sh "$USER" "$PUID" "$PGID" | ||
|
||
if [ ! -f "$JAR_NAME" ]; then | ||
echo "Downloading Minecraft"; | ||
|
||
manifest=$(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json') | ||
version=$(jq -c ".versions[] | select( .id == \"$MINECRAFT_VERSION\" )" <<< "$manifest") | ||
version_manifest=$(curl -s "$(jq -r ".url" <<< "$version")") | ||
|
||
server_url=$(jq -r '.downloads.server.url' <<< "$version_manifest") | ||
if [ -n "$FABRIC_LOADER_VERSION" ] && [ -n "$FABRIC_INSTALLER_VERSION" ]; then | ||
echo "Installing Fabric" | ||
JAR_NAME="$(download-fabric.sh)" | ||
elif [ -n "$NEO_VERSION" ]; then | ||
echo "Installing NeoForge" | ||
|
||
JAR_NAME="$(download-neoforge.sh)" | ||
# Neoforge uses a custom script to run minecraft | ||
COMMAND="${*:-"cd /minecraft; PATH=$(which java):$PATH ./run.sh nogui"}" | ||
elif [ -n "$FORGE_VERSION" ]; then | ||
echo "Installing Forge" | ||
|
||
JAR_NAME="$(download-forge.sh)" | ||
# Modern versions of forge use a custom script | ||
if [ -f "run.sh" ]; then | ||
COMMAND="${*:-"cd /minecraft; PATH=$(which java):$PATH ./run.sh nogui"}" | ||
fi | ||
elif [ -n "$PAPER_BUILD" ]; then | ||
echo "Installing Paper" | ||
|
||
JAR_NAME="$(download-paper.sh)" | ||
else | ||
echo "Installing Vanilla" | ||
|
||
JAR_NAME="$(download-vanilla.sh)" | ||
fi | ||
|
||
curl -o "$JAR_NAME" -J "$server_url" | ||
if [ -z "$COMMAND" ]; then | ||
# Default command | ||
COMMAND="${*:-"cd /minecraft; $(which java) ${JAVA_OPTS} -jar $JAR_NAME nogui"}" | ||
fi | ||
|
||
echo "Accepting EULA" | ||
echo "eula=true" > eula.txt | ||
if [ "$EULA" == "true" ]; then | ||
echo "Accepting EULA" | ||
echo "eula=true" > eula.txt | ||
fi | ||
|
||
configure-server-properties.sh | ||
|
||
chown -R "${USER}":"${USER}" /minecraft | ||
|
||
|
||
COMMAND="${*:-"cd /minecraft; $(which java) ${JAVA_OPTS} -jar $JAR_NAME nogui"}" | ||
|
||
su -l "${USER}" -c "$COMMAND" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!compose.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
services: | ||
vanilla: | ||
image: minecraft-server | ||
build: .. | ||
|
||
environment: | ||
MINECRAFT_VERSION: 1.21 | ||
|
||
EULA: true | ||
|
||
volumes: | ||
- ./vanilla:/minecraft | ||
|
||
fabric: | ||
image: minecraft-server | ||
build: .. | ||
|
||
environment: | ||
MINECRAFT_VERSION: 1.21 | ||
|
||
FABRIC_LOADER_VERSION: 0.15.11 | ||
FABRIC_INSTALLER_VERSION: 1.0.1 | ||
|
||
EULA: true | ||
|
||
volumes: | ||
- ./fabric:/minecraft | ||
|
||
neoforge: | ||
image: minecraft-server | ||
build: .. | ||
|
||
environment: | ||
MINECRAFT_VERSION: 1.21 | ||
|
||
NEO_VERSION: 21.0.4-beta | ||
|
||
EULA: true | ||
|
||
volumes: | ||
- ./neoforge:/minecraft | ||
|
||
forge: | ||
image: minecraft-server | ||
build: .. | ||
|
||
environment: | ||
MINECRAFT_VERSION: 1.20.6 | ||
|
||
FORGE_VERSION: 50.1.7 | ||
|
||
EULA: true | ||
|
||
volumes: | ||
- ./forge:/minecraft | ||
|
||
paper: | ||
image: minecraft-server | ||
build: .. | ||
|
||
environment: | ||
MINECRAFT_VERSION: 1.20.6 | ||
|
||
PAPER_BUILD: 147 | ||
|
||
EULA: true | ||
|
||
volumes: | ||
- ./paper:/minecraft |