From 77edb46b62a59b3fb2d956c7384466d53e872092 Mon Sep 17 00:00:00 2001 From: David Katz Date: Tue, 18 Apr 2023 22:46:44 -0700 Subject: [PATCH] Add support for Modrinth modpacks --- game_eggs/minecraft/java/modrinth/README.md | 18 ++++++ .../java/modrinth/egg-modrinth-generic.json | 59 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 game_eggs/minecraft/java/modrinth/README.md create mode 100644 game_eggs/minecraft/java/modrinth/egg-modrinth-generic.json diff --git a/game_eggs/minecraft/java/modrinth/README.md b/game_eggs/minecraft/java/modrinth/README.md new file mode 100644 index 00000000..04580ecc --- /dev/null +++ b/game_eggs/minecraft/java/modrinth/README.md @@ -0,0 +1,18 @@ +# Modrinth Generic + +## This is a generic egg for Modrinth modpacks + +You will need to give it a modpack project ID. The project ID for [Extreme Optimization!](https://modrinth.com/modpack/extreme-optimization!) is `1oIpaoJo` for example. +This can be found on the modpack page in the `Technical information` section in the left sidebar. + +You can also optionally specify a version ID. If you do not specify a version ID, the latest version will be used. The version ID for [Extreme Optimization!](https://modrinth.com/modpack/extreme-optimization!) version 1.12.2For2.0 is `SyMW2FDv` for example. This can be found on the modpack page by clicking the version number in the `Versions` section. + +The script will automatically setup of Forge, Fabric, or Quilt depending on the modpack. + +## Server Ports + +The minecraft server requires a single port for access (default 25565) but plugins may require extra ports to enabled for the server. + +| Port | default | +|-------|---------| +| Game | 25565 | diff --git a/game_eggs/minecraft/java/modrinth/egg-modrinth-generic.json b/game_eggs/minecraft/java/modrinth/egg-modrinth-generic.json new file mode 100644 index 00000000..fc3f5bc7 --- /dev/null +++ b/game_eggs/minecraft/java/modrinth/egg-modrinth-generic.json @@ -0,0 +1,59 @@ +{ + "_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO", + "meta": { + "version": "PTDL_v2", + "update_url": null + }, + "exported_at": "2023-04-18T22:37:55-07:00", + "name": "Modrinth Generic", + "author": "contact@chromozone.dev", + "description": "A generic egg for a Modrinth modpack.", + "features": [ + "eula", + "java_version", + "pid_limit" + ], + "docker_images": { + "Java 8": "ghcr.io\/pterodactyl\/yolks:java_8", + "Java 11": "ghcr.io\/pterodactyl\/yolks:java_11", + "Java 16": "ghcr.io\/pterodactyl\/yolks:java_16", + "Java 17": "ghcr.io\/pterodactyl\/yolks:java_17" + }, + "file_denylist": [], + "startup": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -Dterminal.jline=false -Dterminal.ansi=true $([[ ! -f unix_args.txt ]] && printf %s \"-jar `cat .serverjar`\" || printf %s \"@unix_args.txt\")", + "config": { + "files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"0.0.0.0\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\"\r\n }\r\n }\r\n}", + "startup": "{\r\n \"done\": \")! For help, type \"\r\n}", + "logs": "{}", + "stop": "stop" + }, + "scripts": { + "installation": { + "script": "#!\/bin\/bash\r\n# Modrinth Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\n\r\n: ${SERVER_DIR:=\/mnt\/server}\r\n\r\nif [[ ! -d $SERVER_DIR ]]; then\r\n mkdir -p $SERVER_DIR\r\nfi\r\n\r\ncd $SERVER_DIR\r\n\r\nfunction install_required {\r\n echo -e \"Installing required packages...\"\r\n echo -e \"\\tRunning apt update\"\r\n apt update > \/dev\/null 2>&1 || { echo \"apt update failed!\"; exit 1; }\r\n echo -e \"\\tRunning apt install\"\r\n apt install -y wget jq unzip dos2unix > \/dev\/null 2>&1 || { echo \"apt install failed!\"; exit 1; }\r\n}\r\n\r\nMODRINTH_API_URL=\"https:\/\/api.modrinth.com\/v2\"\r\n\r\nfunction get_download {\r\n echo -e \"Retrieving Modrinth project information...\"\r\n PROJECT_DATA=$(wget -q \"${MODRINTH_API_URL}\/project\/${PROJECT_ID}\" -O -)\r\n PROJECT_TITLE=$(echo $PROJECT_DATA | jq -r '.title')\r\n PROJECT_SUPPORTED=$(echo $PROJECT_DATA | jq -r '.\"server_side\"')\r\n\r\n if [[ \"${PROJECT_SUPPORTED}\" == \"unsupported\" ]]; then\r\n echo -e \"\\tWARNING: The project '${PROJECT_TITLE}' is listed as unsupported for server use. Continuing anyway...\"\r\n fi\r\n\r\n if [[ -z ${VERSION_ID} || \"${VERSION_ID}\" == \"latest\" ]]; then\r\n echo -e \"\\tNo version ID specified, using latest version\"\r\n VERSION_ID=$(echo $PROJECT_DATA | jq -r '.versions[-1]')\r\n else\r\n echo -e \"\\tChecking if provided version id '${VERSION_ID}' exists\"\r\n if [[ $(echo $PROJECT_DATA | jq -r --arg VERSION_ID \"$VERSION_ID\" '.versions[] | select(. == $VERSION_ID)') != \"${VERSION_ID}\" ]]; then\r\n echo -e \"\\tERROR: Version id '${VERSION_ID}' not found for project '${PROJECT_TITLE}'\"\r\n exit 1\r\n fi\r\n fi\r\n\r\n # get json data to work with\r\n echo -e \"\\tRetrieving version information for '${VERSION_ID}'\"\r\n JSON_DATA=$(wget -q \"${MODRINTH_API_URL}\/version\/${VERSION_ID}\" -O -)\r\n\r\n echo -e \"\\tParsing Modrinth pack download url\"\r\n\r\n DOWNLOAD_URL=$(echo -e $JSON_DATA | jq -r '.files[] | select(.primary == true) | .url')\r\n\r\n if [[ -z ${DOWNLOAD_URL} ]]; then\r\n echo -e \"\\tERROR: No download url found for version ${VERSION_ID}\"\r\n exit 1\r\n fi\r\n\r\n ## download modpack files\r\n echo -e \"\\tDownloading ${DOWNLOAD_URL}\"\r\n wget -q ${DOWNLOAD_URL} -O server.zip\r\n}\r\n\r\nfunction unpack_zip {\r\n unzip -o server.zip\r\n rm -rf server.zip\r\n}\r\n\r\nfunction json_download_mods {\r\n echo \"Downloading mods...\"\r\n\r\n MANIFEST=\"${SERVER_DIR}\/modrinth.index.json\"\r\n jq -c '.files[] | select(.env.server == \"required\") | {name: .path, url: .downloads[0]}' ${MANIFEST} | while read -r mod; do\r\n fileUrl=$(echo ${mod} | jq -r '.url')\r\n\r\n echo -e \"\\tDownloading ${fileUrl}\"\r\n wget -q \"${fileUrl}\" -P \"${SERVER_DIR}\/mods\"\r\n\r\n if [[ $? != 0 ]]; then\r\n echo -e \"Download failed!\"\r\n exit 1\r\n fi\r\n done\r\n}\r\n\r\nfunction json_download_overrides {\r\n echo \"Copying overrides...\"\r\n if [[ -d \"${SERVER_DIR}\/overrides\" ]]; then\r\n echo -e \"\\tCopying overrides\"\r\n cp -r \"${SERVER_DIR}\/overrides\/\"* \"${SERVER_DIR}\"\r\n rm -r \"${SERVER_DIR}\/overrides\"\r\n fi\r\n\r\n if [[ -d \"${SERVER_DIR}\/server-overrides\" ]]; then\r\n echo -e \"\\tCopying server overrides\"\r\n cp -r \"${SERVER_DIR}\/server-overrides\/\"* \"${SERVER_DIR}\"\r\n rm -r \"${SERVER_DIR}\/server-overrides\"\r\n fi\r\n}\r\n\r\nFORGE_INSTALLER_URL=\"https:\/\/maven.minecraftforge.net\/net\/minecraftforge\/forge\/\"\r\n\r\nfunction json_download_forge {\r\n echo \"Downloading Forge...\"\r\n\r\n MANIFEST=\"${SERVER_DIR}\/modrinth.index.json\"\r\n\r\n MC_VERSION=$(jq -r '.dependencies.minecraft' ${MANIFEST})\r\n FORGE_VERSION=$(jq -r '.dependencies.forge' ${MANIFEST})\r\n\r\n FORGE_VERSION=\"${MC_VERSION}-${FORGE_VERSION}\"\r\n if [[ \"${MC_VERSION}\" == \"1.7.10\" || \"${MC_VERSION}\" == \"1.8.9\" ]]; then\r\n FORGE_VERSION=\"${FORGE_VERSION}-${MC_VERSION}\"\r\n fi\r\n\r\n FORGE_JAR=\"forge-${FORGE_VERSION}.jar\"\r\n if [[ \"${MC_VERSION}\" == \"1.7.10\" ]]; then\r\n FORGE_JAR=\"forge-${FORGE_VERSION}-universal.jar\"\r\n fi\r\n\r\n FORGE_URL=\"${FORGE_INSTALLER_URL}${FORGE_VERSION}\/forge-${FORGE_VERSION}\"\r\n\r\n echo -e \"\\tUsing Forge ${FORGE_VERSION} from ${FORGE_URL}\"\r\n\r\n FORGE_INSTALLER=\"${FORGE_URL}-installer.jar\"\r\n echo -e \"\\tDownloading Forge Installer ${FORGE_VERSION} from ${FORGE_INSTALLER}\"\r\n wget -q -O forge-installer.jar ${FORGE_INSTALLER}\r\n\r\n if [[ $? != 0 ]]; then\r\n echo -e \"Download failed!\"\r\n exit 1\r\n fi\r\n\r\n rm -rf libraries\/net\/minecraftforge\/forge\/\r\n rm -f unix_args.txt\r\n\r\n echo -e \"\\tInstalling Forge Server ${FORGE_VERSION}\"\r\n java -jar forge-installer.jar --installServer > \/dev\/null 2>&1 || { echo \"Forge installer failed!\"; exit 1; }\r\n\r\n if [[ $MC_VERSION =~ ^1\\.(17|18|19|20|21|22|23) || $FORGE_VERSION =~ ^1\\.(17|18|19|20|21|22|23) ]]; then\r\n echo -e \"\\tDetected Forge 1.17 or newer version. Setting up Forge Unix arguments\"\r\n ln -sf libraries\/net\/minecraftforge\/forge\/*\/unix_args.txt unix_args.txt\r\n else\r\n mv $FORGE_JAR forge-server-launch.jar\r\n echo \"forge-server-launch.jar\" > \".serverjar\"\r\n fi\r\n\r\n rm -f forge-installer.jar\r\n}\r\n\r\nFABRIC_INSTALLER_URL=\"https:\/\/meta.fabricmc.net\/v2\/versions\/installer\"\r\n\r\nfunction json_download_fabric {\r\n echo \"Downloading Fabric...\"\r\n\r\n MANIFEST=\"${SERVER_DIR}\/modrinth.index.json\"\r\n\r\n MC_VERSION=$(jq -r '.dependencies.minecraft' ${MANIFEST})\r\n FABRIC_VERSION=$(jq -r '.dependencies.\"fabric-loader\"' ${MANIFEST})\r\n\r\n INSTALLER_JSON=$(wget -q -O - ${FABRIC_INSTALLER_URL} )\r\n INSTALLER_VERSION=$(echo $INSTALLER_JSON | jq -r '.[0].version')\r\n INSTALLER_URL=$(echo $INSTALLER_JSON | jq -r '.[0].url')\r\n\r\n echo -e \"\\tDownloading Fabric Installer ${MC_VERSION}-${FABRIC_VERSION} (${INSTALLER_VERSION}) from ${INSTALLER_URL}\"\r\n wget -q -O fabric-installer.jar ${INSTALLER_URL}\r\n\r\n if [[ $? != 0 ]]; then\r\n echo -e \"Download failed!\"\r\n exit 1\r\n fi\r\n\r\n echo -e \"\\tInstalling Fabric Server ${MC_VERSION}-${FABRIC_VERSION} (${INSTALLER_VERSION})\"\r\n java -jar fabric-installer.jar server -mcversion ${MC_VERSION} -loader ${FABRIC_VERSION} -downloadMinecraft || { echo \"Fabric installer failed!\"; exit 4; }\r\n\r\n echo \"fabric-server-launch.jar\" > \".serverjar\"\r\n\r\n rm -f fabric-installer.jar\r\n}\r\n\r\nQUILT_INSTALLER_URL=\"https:\/\/meta.quiltmc.org\/v3\/versions\/installer\"\r\n\r\nfunction json_download_quilt {\r\n echo \"Downloading Quilt...\"\r\n\r\n MANIFEST=\"${SERVER_DIR}\/modrinth.index.json\"\r\n\r\n MC_VERSION=$(jq -r '.dependencies.minecraft' ${MANIFEST})\r\n QUILT_VERSION=$(jq -r '.dependencies.\"quilt-loader\"' ${MANIFEST})\r\n\r\n INSTALLER_JSON=$(wget -q -O - ${QUILT_INSTALLER_URL} )\r\n INSTALLER_VERSION=$(echo $INSTALLER_JSON | jq -r '.[0].version')\r\n INSTALLER_URL=$(echo $INSTALLER_JSON | jq -r '.[0].url')\r\n\r\n echo -e \"\\tDownloading Quilt Installer ${MC_VERSION}-${QUILT_VERSION} (${INSTALLER_VERSION}) from ${INSTALLER_URL}\"\r\n wget -q -O quilt-installer.jar ${INSTALLER_URL}\r\n\r\n if [[ $? != 0 ]]; then\r\n echo -e \"Download failed!\"\r\n exit 1\r\n fi\r\n\r\n echo -e \"\\tInstalling Quilt Server ${MC_VERSION}-${QUILT_VERSION} (${INSTALLER_VERSION})\"\r\n java -jar quilt-installer.jar install server ${MC_VERSION} ${QUILT_VERSION} --download-server --install-dir=.\/ || { echo \"Quilt installer failed!\"; exit 4; }\r\n\r\n echo \"quilt-server-launch.jar\" > \".serverjar\"\r\n\r\n rm quilt-installer.jar\r\n}\r\n\r\ninstall_required\r\n\r\nif [[ ! -z \"${VERSION_ID}\" && ! \"${VERSION_ID}\" = \"zip\" ]]; then\r\n\tget_download\r\n\tunpack_zip\r\nelse\r\n\tunpack_zip\r\nfi\r\n\r\nif [[ -f \"${SERVER_DIR}\/modrinth.index.json\" ]]; then\r\n echo \"Found modrinth.index.json, installing mods\"\r\n json_download_mods\r\n json_download_overrides\r\nfi\r\n\r\nif [[ -f \"${SERVER_DIR}\/modrinth.index.json\" ]]; then\r\n MANIFEST=\"${SERVER_DIR}\/modrinth.index.json\"\r\n\r\n if [[ $(jq -r '.dependencies.forge' ${MANIFEST}) != \"null\" ]]; then\r\n json_download_forge\r\n fi\r\n\r\n if [[ $(jq -r '.dependencies.\"fabric-loader\"' ${MANIFEST}) != \"null\" ]]; then\r\n json_download_fabric\r\n fi\r\n\r\n if [[ $(jq -r '.dependencies.\"quilt-loader\"' ${MANIFEST}) != \"null\" ]]; then\r\n json_download_quilt\r\n fi\r\nfi\r\n\r\necho -e \"\\nInstall completed succesfully, enjoy!\"", + "container": "openjdk:8-jdk-slim", + "entrypoint": "bash" + } + }, + "variables": [ + { + "name": "Modpack Project ID", + "description": "This is the modpack project ID from the Modrinth site.\r\n\r\nFor example, the project ID of 'https:\/\/modrinth.com\/modpack\/fabulously-optimized\/' is 1KVo5zza", + "env_variable": "PROJECT_ID", + "default_value": "", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:8", + "field_type": "text" + }, + { + "name": "Modpack Version ID", + "description": "This is the modpack version ID from the Modrinth site.\r\n\r\nFor example, the version ID of 'https:\/\/modrinth.com\/modpack\/fabulously-optimized\/version\/4.7.4' is P9wA6exe", + "env_variable": "VERSION_ID", + "default_value": "latest", + "user_viewable": true, + "user_editable": true, + "rules": "required|string|max:8", + "field_type": "text" + } + ] +}