From 78a175ddf25f110706537befba7ecd170e481d33 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 14 May 2022 23:44:31 -0500 Subject: [PATCH] init commit --- Dockerfile | 20 ++++++++++++++++++++ cleanup.sh | 22 ++++++++++++++++++++++ docker-compose.yml | 19 +++++++++++++++++++ downloadpack.sh | 21 +++++++++++++++++++++ setup.sh | 28 ++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 Dockerfile create mode 100644 cleanup.sh create mode 100644 docker-compose.yml create mode 100644 downloadpack.sh create mode 100644 setup.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14476b6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:jammy +RUN apt-get update +RUN apt-get upgrade -y +RUN apt-get install jq -y +RUN apt-get install webp -y +RUN apt-get install openjdk-17-jre -y +RUN apt-get install curl -y +RUN apt-get install wget -y +RUN mkdir -p /opt/ftbmc +RUN mkdir -p /tmp/modpackch +WORKDIR /tmp/modpackch +COPY downloadpack.sh . +COPY cleanup.sh . +COPY setup.sh . +RUN chmod +x *sh + +ENV MAXMEMORY="20g" +ENV MINMEMORY="10g" + +ENTRYPOINT [ "bash", "./setup.sh" ] diff --git a/cleanup.sh b/cleanup.sh new file mode 100644 index 0000000..2fdbf60 --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e # Error out immediately on failed line +set +x # Don't print commands as they are run + +echo "Cleaning up old installation (if any, exluding world and property files)..." +# The aim is to delete anything that doesn't need to be persistent between upgrades +echo "Deleting mods..." # Mods may change between versions +rm -rf ./mods +echo "Deleting forge jars..." # The version of Forge may change +rm -f forge-* +echo "Deleting Minecraft jars..." # The version of Minecraft may change +rm -f minecraft_server* +echo "Deleting libraries..." # Unsure if libraries might change +rm -rf ./libraries +echo "Deleting kubejs..." # Not sure what this folder is, but I don't think anything persistent is stored in it +rm -rf ./kubejs +echo "Deleting packmenu..." # Not sure what this folder is, but I don't think anything persistent is stored in it +rm -rf ./packmenu +echo "Deleting old installers..." # These shouldn't conflict, but I'm deleting them in-case they ever have a hotfix release with the same name +rm -f serverinstall* +echo "Cleanup Complete " +echo "==========================" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3c7c920 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3.3' + +services: + ftbmc: + container_name: ftbmc118 + image: ftbdw20118 + restart: unless-stopped + volumes: + - ./ftbmc:/opt/ftbmc + ports: + - "25566:25565" + environment: + MODPACKID: '95' + VERSION: 'LATEST' + networks: + - minecraft2 + +networks: + minecraft2: diff --git a/downloadpack.sh b/downloadpack.sh new file mode 100644 index 0000000..f4b71d4 --- /dev/null +++ b/downloadpack.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e # Error out immediately on failed line +set +x # Don't print commands as they are run + +if [[ -z "${MODPACKID}" ]] || [[ -z "${VERSION}" ]]; +then +echo "Invalid MODPACKID or VERSION" +exit 1 +fi + +# If we're using the latest version (it's not manually specified) +if [ "$VERSION" == "LATEST" ] +# Lookup the latest version available from the API and save it to the version variable +then VERSION=$(curl https://api.modpacks.ch/public/modpack/$MODPACKID/ | jq '.versions[-1].id'); fi; + +echo "Downloading installer..." +wget https://api.modpacks.ch/public/modpack/$MODPACKID/$VERSION/server/linux --content-disposition +#echo "Renaming..." +#mv ./serverinstall_"$MODPACKID"_"$VERSION" ./serverinstall +echo "Making it executable..." +chmod +x ./serverinstall_"$MODPACKID"_"$VERSION" diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..ecbc932 --- /dev/null +++ b/setup.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e +set +x + +if [[ -z ${MODPACKID} ]];then MODPACKID='95';fi +if [[ -z ${VERSION} ]];then VERSION='LATEST';fi +cp cleanup.sh /opt/ftbmc +cd /opt/ftbmc + +if [ -f "/opt/ftbmc/.updatelock" ]; then + echo "Operating in manual mode!" + echo "Updating disabled. Not overwriting files." +else + echo "Cleaning old files.." + /opt/ftbmc/cleanup.sh + echo "Downloading new files..." + cd /tmp/modpackch + /tmp/modpackch/downloadpack.sh + echo "Installing new files..." + /tmp/modpackch/serverinstall* --path /opt/ftbmc --latest --auto + cd /opt/ftbmc + touch /opt/ftbmc/.updatelock +fi + +# echo "Creating Minecraft EULA file" +echo "Now starting server..." +echo "eula=true" > eula.txt +./run.sh