mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-02-20 16:26:23 +00:00
Compare commits
33 Commits
2021.6.0-j
...
1.7.0-mult
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eba1ef6ab9 | ||
|
|
6462e1580c | ||
|
|
8b5552bb62 | ||
|
|
3ca514f2b2 | ||
|
|
c07f899870 | ||
|
|
e527fd9551 | ||
|
|
047a477f7b | ||
|
|
78cb05adda | ||
|
|
8493252645 | ||
|
|
aa42633ab2 | ||
|
|
9ec336283f | ||
|
|
bbdb2c9b36 | ||
|
|
48e09f42fc | ||
|
|
ec7d182d38 | ||
|
|
9c7c95cf4f | ||
|
|
e32ffd1819 | ||
|
|
095c6ad099 | ||
|
|
14342c9632 | ||
|
|
f6df4d6694 | ||
|
|
0406e89c2a | ||
|
|
5ef21e1ddf | ||
|
|
414d5bd8ac | ||
|
|
15ccf03b28 | ||
|
|
828a48998f | ||
|
|
4b590e03ff | ||
|
|
0db8780ad9 | ||
|
|
5b744176df | ||
|
|
20b15e0330 | ||
|
|
818539e3de | ||
|
|
f48741f65c | ||
|
|
e9e5af849f | ||
|
|
22d68f5c7c | ||
|
|
690598da60 |
25
.github/workflows/build-multiarch.yml
vendored
Normal file
25
.github/workflows/build-multiarch.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Build and publish multiarch
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- multiarch
|
||||||
|
tags:
|
||||||
|
- "[0-9]+.[0-9]+.[0-9]+-multiarch"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-buildx:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2.2.0
|
||||||
|
- name: Get branch name
|
||||||
|
uses: nelonoel/branch-name@v1
|
||||||
|
- name: Docker Buildx
|
||||||
|
uses: ilteoood/docker_buildx@1.0.4
|
||||||
|
with:
|
||||||
|
publish: true
|
||||||
|
imageName: itzg/minecraft-server
|
||||||
|
tag: ${{ env.BRANCH_NAME }}
|
||||||
|
dockerHubUser: ${{ secrets.DOCKER_USER }}
|
||||||
|
dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
5
BUILDING.md
Normal file
5
BUILDING.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Ensure buildx/BuildKit support is enabled and run:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx build --platform=linux/arm64 --platform=linux/arm/v7 --platform=linux/amd64 --tag itzg/minecraft-server:multiarch --push .
|
||||||
|
```
|
||||||
53
Dockerfile
53
Dockerfile
@@ -1,32 +1,27 @@
|
|||||||
FROM openjdk:8u212-jre-alpine
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
|
LABEL org.opencontainers.image.authors="Geoff Bourne <itzgeoff@gmail.com>"
|
||||||
|
|
||||||
# upgrade all packages since alpine jre8 base image tops out at 8u212
|
RUN apt-get update \
|
||||||
RUN apk -U --no-cache upgrade
|
&& DEBIAN_FRONTEND=noninteractive \
|
||||||
|
apt-get install -y \
|
||||||
|
openjdk-8-jre-headless \
|
||||||
|
imagemagick \
|
||||||
|
gosu \
|
||||||
|
curl wget \
|
||||||
|
jq \
|
||||||
|
dos2unix \
|
||||||
|
mysql-client \
|
||||||
|
tzdata \
|
||||||
|
rsync \
|
||||||
|
nano \
|
||||||
|
unzip \
|
||||||
|
knockd \
|
||||||
|
ttf-dejavu \
|
||||||
|
&& apt-get clean
|
||||||
|
|
||||||
RUN apk add --no-cache -U \
|
RUN addgroup --gid 1000 minecraft \
|
||||||
openssl \
|
&& adduser --system --shell /bin/false --uid 1000 --ingroup minecraft --home /data minecraft
|
||||||
imagemagick \
|
|
||||||
lsof \
|
|
||||||
su-exec \
|
|
||||||
shadow \
|
|
||||||
bash \
|
|
||||||
curl iputils wget \
|
|
||||||
git \
|
|
||||||
jq \
|
|
||||||
mysql-client \
|
|
||||||
tzdata \
|
|
||||||
rsync \
|
|
||||||
nano \
|
|
||||||
sudo \
|
|
||||||
knock \
|
|
||||||
ttf-dejavu
|
|
||||||
|
|
||||||
RUN addgroup -g 1000 minecraft \
|
|
||||||
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
|
|
||||||
&& mkdir -m 777 /data \
|
|
||||||
&& chown minecraft:minecraft /data /home/minecraft
|
|
||||||
|
|
||||||
COPY files/sudoers* /etc/sudoers.d
|
COPY files/sudoers* /etc/sudoers.d
|
||||||
|
|
||||||
@@ -34,9 +29,9 @@ EXPOSE 25565 25575
|
|||||||
|
|
||||||
# hook into docker BuildKit --platform support
|
# hook into docker BuildKit --platform support
|
||||||
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
# see https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
||||||
ARG TARGETOS=linux
|
ARG TARGETOS
|
||||||
ARG TARGETARCH=amd64
|
ARG TARGETARCH
|
||||||
ARG TARGETVARIANT=""
|
ARG TARGETVARIANT
|
||||||
|
|
||||||
ARG EASY_ADD_VER=0.7.1
|
ARG EASY_ADD_VER=0.7.1
|
||||||
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
|
ADD https://github.com/itzg/easy-add/releases/download/${EASY_ADD_VER}/easy-add_${TARGETOS}_${TARGETARCH}${TARGETVARIANT} /usr/bin/easy-add
|
||||||
@@ -70,7 +65,7 @@ COPY log4j2.xml /tmp/log4j2.xml
|
|||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
ENV UID=1000 GID=1000 \
|
ENV UID=1000 GID=1000 \
|
||||||
JVM_XX_OPTS="-XX:+UseG1GC" MEMORY="1G" \
|
MEMORY="1G" \
|
||||||
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
|
TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED SPONGEBRANCH=STABLE SPONGEVERSION= FABRICVERSION=LATEST LEVEL=world \
|
||||||
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
PVP=true DIFFICULTY=easy ENABLE_RCON=true RCON_PORT=25575 RCON_PASSWORD=minecraft \
|
||||||
LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
|
LEVEL_TYPE=DEFAULT SERVER_PORT=25565 ONLINE_MODE=TRUE SERVER_NAME="Dedicated Server" \
|
||||||
|
|||||||
0
docs/.gitkeep
Normal file
0
docs/.gitkeep
Normal file
2
start
2
start
@@ -45,7 +45,7 @@ if [ $(id -u) = 0 ]; then
|
|||||||
echo 'hosts: files dns' > /etc/nsswitch.conf
|
echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec su-exec ${runAsUser}:${runAsGroup} ${SCRIPTS:-/}start-configuration $@
|
exec gosu ${runAsUser}:${runAsGroup} ${SCRIPTS:-/}start-configuration $@
|
||||||
else
|
else
|
||||||
exec ${SCRIPTS:-/}start-configuration $@
|
exec ${SCRIPTS:-/}start-configuration $@
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ shopt -s nullglob
|
|||||||
#umask 002
|
#umask 002
|
||||||
export HOME=/data
|
export HOME=/data
|
||||||
|
|
||||||
|
log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
||||||
|
|
||||||
if [ ! -e /data/eula.txt ]; then
|
if [ ! -e /data/eula.txt ]; then
|
||||||
EULA="${EULA,,}"
|
EULA="${EULA,,}"
|
||||||
if [ "$EULA" != "true" ]; then
|
if [ "$EULA" != "true" ]; then
|
||||||
@@ -28,15 +30,6 @@ if [ ! -e /data/eula.txt ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
|
|
||||||
|
|
||||||
if ! touch /data/.verify_access; then
|
|
||||||
log "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm /data/.verify_access || true
|
|
||||||
|
|
||||||
if [[ $PROXY ]]; then
|
if [[ $PROXY ]]; then
|
||||||
export http_proxy="$PROXY"
|
export http_proxy="$PROXY"
|
||||||
export https_proxy="$PROXY"
|
export https_proxy="$PROXY"
|
||||||
@@ -108,10 +101,14 @@ case "${TYPE^^}" in
|
|||||||
exec ${SCRIPTS:-/}start-deployFabric "$@"
|
exec ${SCRIPTS:-/}start-deployFabric "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
FTB|CURSEFORGE)
|
FTBA)
|
||||||
exec ${SCRIPTS:-/}start-deployFTB "$@"
|
exec ${SCRIPTS:-/}start-deployFTB "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
CURSEFORGE|FTB)
|
||||||
|
exec ${SCRIPTS:-/}start-deployCF "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
VANILLA)
|
VANILLA)
|
||||||
exec ${SCRIPTS:-/}start-deployVanilla "$@"
|
exec ${SCRIPTS:-/}start-deployVanilla "$@"
|
||||||
;;
|
;;
|
||||||
|
|||||||
189
start-deployCF
Normal file
189
start-deployCF
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
. ${SCRIPTS:-/}start-utils
|
||||||
|
|
||||||
|
export FTB_BASE_DIR=/data/FeedTheBeast
|
||||||
|
legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
|
||||||
|
export TYPE=CURSEFORGE
|
||||||
|
|
||||||
|
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
||||||
|
|
||||||
|
log "Looking for Feed-The-Beast / CurseForge server modpack."
|
||||||
|
requireVar FTB_SERVER_MOD
|
||||||
|
|
||||||
|
if ! isTrue ${USE_MODPACK_START_SCRIPT:-true}; then
|
||||||
|
if ! [ -f ${FTB_SERVER_MOD} ]; then
|
||||||
|
log "ERROR unable to find requested modpack file ${FTB_SERVER_MOD}"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
needsInstall=true
|
||||||
|
installMarker=/data/.curseforge-installed
|
||||||
|
if [ -f $installMarker ]; then
|
||||||
|
if [ "$(cat $installMarker)" != "${FTB_SERVER_MOD}" ]; then
|
||||||
|
log "Upgrading modpack"
|
||||||
|
|
||||||
|
serverJar=$(find ${FTB_BASE_DIR} -not -name "forge*installer.jar" -name "forge*.jar")
|
||||||
|
if [[ "${serverJar}" ]]; then
|
||||||
|
rm -rf $(dirname "${serverJar}")/{mods,*.jar,libraries,resources,scripts}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
needsInstall=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $needsInstall; then
|
||||||
|
log "Unpacking FTB server modpack ${FTB_SERVER_MOD} ..."
|
||||||
|
mkdir -p ${FTB_BASE_DIR}
|
||||||
|
unzip -o ${FTB_SERVER_MOD} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
||||||
|
|
||||||
|
forgeInstallerJar=$(find ${FTB_BASE_DIR} -name "forge*installer.jar")
|
||||||
|
if [[ -z "${forgeInstallerJar}" ]]; then
|
||||||
|
log "ERROR Unable to find forge installer in modpack."
|
||||||
|
log " Make sure you downloaded the server files."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Installing forge server"
|
||||||
|
(cd $(dirname "${forgeInstallerJar}"); java -jar $(basename ${forgeInstallerJar}) --installServer) | awk '{printf "."} END {print ""}'
|
||||||
|
|
||||||
|
echo "${FTB_SERVER_MOD}" > $installMarker
|
||||||
|
fi
|
||||||
|
|
||||||
|
export SERVER=$(find ${FTB_BASE_DIR} -not -name "forge*installer.jar" -name "forge*.jar")
|
||||||
|
if [[ -z "${SERVER}" || ! -f "${SERVER}" ]]; then
|
||||||
|
log "ERROR unable to locate installed forge server jar"
|
||||||
|
isDebugging && find ${FTB_BASE_DIR} -name "forge*.jar"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
export FTB_DIR=$(dirname "${SERVER}")
|
||||||
|
|
||||||
|
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||||
|
fi
|
||||||
|
|
||||||
|
entryScriptExpr="
|
||||||
|
-name ServerStart.sh
|
||||||
|
-o -name serverstart.sh
|
||||||
|
-o -name ServerStartLinux.sh
|
||||||
|
-o -name LaunchServer.sh
|
||||||
|
-o -name server-start.sh
|
||||||
|
-o -name startserver.sh
|
||||||
|
-o -name StartServer.sh
|
||||||
|
"
|
||||||
|
|
||||||
|
if [[ -d ${FTB_BASE_DIR} ]]; then
|
||||||
|
startScriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr |wc -l)
|
||||||
|
if [[ $startScriptCount > 1 ]]; then
|
||||||
|
log "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
startScriptCount=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# only download and install if a mod pack isn't already installed
|
||||||
|
# also check for the start script rather than just the folder
|
||||||
|
# this allows saving just the world separate from the rest of the data directory
|
||||||
|
if [[ $startScriptCount = 0 ]]; then
|
||||||
|
srv_modpack=${FTB_SERVER_MOD}
|
||||||
|
if isURL ${srv_modpack}; then
|
||||||
|
case $srv_modpack in
|
||||||
|
https://www.feed-the-beast.com/*/download|https://www.curseforge.com/minecraft/modpacks/*/download/*/file)
|
||||||
|
;;
|
||||||
|
https://www.curseforge.com/minecraft/modpacks/*/download/*)
|
||||||
|
srv_modpack=${srv_modpack}/file;;
|
||||||
|
https://www.feed-the-beast.com/*)
|
||||||
|
srv_modpack=${srv_modpack}/download;;
|
||||||
|
esac
|
||||||
|
file=$(basename $(dirname $srv_modpack))
|
||||||
|
downloaded=/data/${file}.zip
|
||||||
|
if [ ! -e $downloaded ]; then
|
||||||
|
log "Downloading FTB modpack...
|
||||||
|
$srv_modpack -> $downloaded"
|
||||||
|
curl -sSL -o $downloaded $srv_modpack
|
||||||
|
fi
|
||||||
|
srv_modpack=$downloaded
|
||||||
|
fi
|
||||||
|
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
||||||
|
# Prepend with "/"
|
||||||
|
srv_modpack=/${srv_modpack}
|
||||||
|
fi
|
||||||
|
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
||||||
|
# If not an absolute path, assume file is in "/data"
|
||||||
|
srv_modpack=/data/${srv_modpack}
|
||||||
|
fi
|
||||||
|
if [[ ! -f ${srv_modpack} ]]; then
|
||||||
|
log "FTB server modpack ${srv_modpack} not found."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
||||||
|
log "FTB server modpack ${srv_modpack} is not a zip archive."
|
||||||
|
log "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Unpacking FTB server modpack ${srv_modpack} ..."
|
||||||
|
mkdir -p ${FTB_BASE_DIR}
|
||||||
|
unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l) = 0 ]]; then
|
||||||
|
|
||||||
|
# Allow up to 2 levels since some modpacks have a top-level directory named
|
||||||
|
# for the modpack
|
||||||
|
forgeJar=$(find ${FTB_BASE_DIR} -maxdepth 2 -name 'forge*.jar' -a -not -name 'forge*installer')
|
||||||
|
if [[ "$forgeJar" ]]; then
|
||||||
|
export FTB_BASE_DIR=$(dirname "${forgeJar}")
|
||||||
|
log "No entry script found, so building one for ${forgeJar}"
|
||||||
|
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
. ./settings-local.sh
|
||||||
|
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
|
||||||
|
EOF
|
||||||
|
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
|
||||||
|
else
|
||||||
|
log "Please make sure you are using the server version of the FTB modpack!"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
|
||||||
|
if [[ $scriptCount = 0 ]]; then
|
||||||
|
log "Please make sure you are using the server version of the FTB modpack!"
|
||||||
|
exit 2
|
||||||
|
elif [[ $scriptCount > 1 ]]; then
|
||||||
|
log "Ambigous startup scripts in FTB modpack!"
|
||||||
|
log "found:"
|
||||||
|
find ${FTB_BASE_DIR} $entryScriptExpr
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
|
||||||
|
|
||||||
|
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
|
||||||
|
chmod a+x "${FTB_SERVER_START}"
|
||||||
|
grep fml.queryResult=confirm ${FTB_SERVER_START} > /dev/null || \
|
||||||
|
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${FTB_SERVER_START}"
|
||||||
|
sed -i 's/.*read.*Restart now/#\0/' "${FTB_SERVER_START}"
|
||||||
|
legacyJavaFixerPath="${FTB_DIR}/mods/legacyjavafixer.jar"
|
||||||
|
|
||||||
|
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e "${legacyJavaFixerPath}" ]; then
|
||||||
|
log "Installing legacy java fixer to ${legacyJavaFixerPath}"
|
||||||
|
curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then
|
||||||
|
pushd "${FTB_DIR}"
|
||||||
|
sh FTBInstall.sh
|
||||||
|
popd
|
||||||
|
elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
||||||
|
pushd "${FTB_DIR}"
|
||||||
|
sh Install.sh
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Continue to Final Setup
|
||||||
|
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||||
225
start-deployFTB
225
start-deployFTB
@@ -1,188 +1,69 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
ftbInstallMarker=".ftb-installed"
|
||||||
|
|
||||||
. ${SCRIPTS:-/}start-utils
|
. ${SCRIPTS:-/}start-utils
|
||||||
|
isDebugging && set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
export FTB_BASE_DIR=/data/FeedTheBeast
|
if ! [[ -v FTB_MODPACK_ID ]]; then
|
||||||
legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
|
log "ERROR FTB_MODPACK_ID is required with TYPE=FTB"
|
||||||
export TYPE=FEED-THE-BEAST
|
exit 1
|
||||||
|
|
||||||
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
|
||||||
|
|
||||||
log "Looking for Feed-The-Beast / CurseForge server modpack."
|
|
||||||
requireVar FTB_SERVER_MOD
|
|
||||||
|
|
||||||
if ! isTrue ${USE_MODPACK_START_SCRIPT:-true}; then
|
|
||||||
if ! [ -f ${FTB_SERVER_MOD} ]; then
|
|
||||||
log "ERROR unable to find requested modpack file ${FTB_SERVER_MOD}"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
needsInstall=true
|
|
||||||
installMarker=/data/.curseforge-installed
|
|
||||||
if [ -f $installMarker ]; then
|
|
||||||
if [ "$(cat $installMarker)" != "${FTB_SERVER_MOD}" ]; then
|
|
||||||
log "Upgrading modpack"
|
|
||||||
|
|
||||||
serverJar=$(find ${FTB_BASE_DIR} -not -name "forge*installer.jar" -name "forge*.jar")
|
|
||||||
if [[ "${serverJar}" ]]; then
|
|
||||||
rm -rf $(dirname "${serverJar}")/{mods,*.jar,libraries,resources,scripts}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
needsInstall=false
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $needsInstall; then
|
|
||||||
log "Unpacking FTB server modpack ${FTB_SERVER_MOD} ..."
|
|
||||||
mkdir -p ${FTB_BASE_DIR}
|
|
||||||
unzip -o ${FTB_SERVER_MOD} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
|
||||||
|
|
||||||
forgeInstallerJar=$(find ${FTB_BASE_DIR} -name "forge*installer.jar")
|
|
||||||
if [[ -z "${forgeInstallerJar}" ]]; then
|
|
||||||
log "ERROR Unable to find forge installer in modpack."
|
|
||||||
log " Make sure you downloaded the server files."
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Installing forge server"
|
|
||||||
(cd $(dirname "${forgeInstallerJar}"); java -jar $(basename ${forgeInstallerJar}) --installServer) | awk '{printf "."} END {print ""}'
|
|
||||||
|
|
||||||
echo "${FTB_SERVER_MOD}" > $installMarker
|
|
||||||
fi
|
|
||||||
|
|
||||||
export SERVER=$(find ${FTB_BASE_DIR} -not -name "forge*installer.jar" -name "forge*.jar")
|
|
||||||
if [[ -z "${SERVER}" || ! -f "${SERVER}" ]]; then
|
|
||||||
log "ERROR unable to locate installed forge server jar"
|
|
||||||
isDebugging && find ${FTB_BASE_DIR} -name "forge*.jar"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
export FTB_DIR=$(dirname "${SERVER}")
|
|
||||||
|
|
||||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
entryScriptExpr="
|
if ! [[ ${FTB_MODPACK_ID} =~ [0-9]+ ]]; then
|
||||||
-name ServerStart.sh
|
log "ERROR FTB_MODPACK_ID needs to be numeric"
|
||||||
-o -name serverstart.sh
|
exit 1
|
||||||
-o -name ServerStartLinux.sh
|
fi
|
||||||
-o -name LaunchServer.sh
|
|
||||||
-o -name server-start.sh
|
|
||||||
-o -name startserver.sh
|
|
||||||
-o -name StartServer.sh
|
|
||||||
"
|
|
||||||
|
|
||||||
if [[ -d ${FTB_BASE_DIR} ]]; then
|
if ! [[ -v FTB_MODPACK_VERSION_ID ]]; then
|
||||||
startScriptCount=$(find ${FTB_BASE_DIR} $entryScriptExpr |wc -l)
|
if ! FTB_MODPACK_VERSION_ID=$(curl -fsSL https://api.modpacks.ch/public/modpack/${FTB_MODPACK_ID} | jq -r '.versions | sort_by(.updated)[-1].id'); then
|
||||||
if [[ $startScriptCount > 1 ]]; then
|
log "ERROR unable to resolve latest modpack version ID for modpack ${FTB_MODPACK_ID}"
|
||||||
log "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}"
|
exit 1
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
|
elif ! [[ ${FTB_MODPACK_VERSION_ID} =~ [0-9]+ ]]; then
|
||||||
|
log "ERROR FTB_MODPACK_VERSION_ID needs to be numeric"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -f "${ftbInstallMarker}" ] || [ $(cat "${ftbInstallMarker}") != "${FTB_MODPACK_ID}=${FTB_MODPACK_VERSION_ID}" ]; then
|
||||||
|
ftbInstaller=/data/ftb-installer
|
||||||
|
if ! [[ -f "${ftbInstaller}" ]]; then
|
||||||
|
log "Downloading FTB installer"
|
||||||
|
curl -fsSL https://api.modpacks.ch/public/modpack/1/1/server/linux -o "${ftbInstaller}"
|
||||||
|
chmod +x "${ftbInstaller}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf forge*jar mods config libraries defaultconfigs changelogs
|
||||||
|
|
||||||
|
log "Installing modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID}"
|
||||||
|
${ftbInstaller} ${FTB_MODPACK_ID} ${FTB_MODPACK_VERSION_ID} --noscript --auto
|
||||||
|
rm -f forge*installer.jar
|
||||||
|
|
||||||
|
echo "${FTB_MODPACK_ID}=${FTB_MODPACK_VERSION_ID}" > ${ftbInstallMarker}
|
||||||
else
|
else
|
||||||
startScriptCount=0
|
log "FTB modpack ID ${FTB_MODPACK_ID}, version ID ${FTB_MODPACK_VERSION_ID} is ready to go"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# only download and install if a mod pack isn't already installed
|
isDebugging && cat version.json
|
||||||
# also check for the start script rather than just the folder
|
forgeVersion=$(jq -r '.targets[] | select(.name == "forge") | .version' version.json)
|
||||||
# this allows saving just the world separate from the rest of the data directory
|
mcVersion=$(jq -r '.targets[] | select(.name == "minecraft") | .version' version.json)
|
||||||
if [[ $startScriptCount = 0 ]]; then
|
|
||||||
srv_modpack=${FTB_SERVER_MOD}
|
variants=(
|
||||||
if isURL ${srv_modpack}; then
|
forge-${mcVersion}-${forgeVersion}.jar
|
||||||
case $srv_modpack in
|
forge-${mcVersion}-${forgeVersion}-universal.jar
|
||||||
https://www.feed-the-beast.com/*/download|https://www.curseforge.com/minecraft/modpacks/*/download/*/file)
|
forge-${mcVersion}-${forgeVersion}-${mcVersion}-universal.jar
|
||||||
;;
|
)
|
||||||
https://www.curseforge.com/minecraft/modpacks/*/download/*)
|
for f in ${variants[@]}; do
|
||||||
srv_modpack=${srv_modpack}/file;;
|
if [ -f $f ]; then
|
||||||
https://www.feed-the-beast.com/*)
|
export SERVER=$f
|
||||||
srv_modpack=${srv_modpack}/download;;
|
break
|
||||||
esac
|
|
||||||
file=$(basename $(dirname $srv_modpack))
|
|
||||||
downloaded=/data/${file}.zip
|
|
||||||
if [ ! -e $downloaded ]; then
|
|
||||||
log "Downloading FTB modpack...
|
|
||||||
$srv_modpack -> $downloaded"
|
|
||||||
curl -sSL -o $downloaded $srv_modpack
|
|
||||||
fi
|
|
||||||
srv_modpack=$downloaded
|
|
||||||
fi
|
fi
|
||||||
if [[ ${srv_modpack:0:5} == "data/" ]]; then
|
done
|
||||||
# Prepend with "/"
|
if ! [ -v SERVER ]; then
|
||||||
srv_modpack=/${srv_modpack}
|
log "ERROR unable to locate the installed forge server jar"
|
||||||
fi
|
ls *.jar
|
||||||
if [[ ! ${srv_modpack:0:1} == "/" ]]; then
|
exit 2
|
||||||
# If not an absolute path, assume file is in "/data"
|
|
||||||
srv_modpack=/data/${srv_modpack}
|
|
||||||
fi
|
|
||||||
if [[ ! -f ${srv_modpack} ]]; then
|
|
||||||
log "FTB server modpack ${srv_modpack} not found."
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
|
|
||||||
log "FTB server modpack ${srv_modpack} is not a zip archive."
|
|
||||||
log "Please set FTB_SERVER_MOD to a file with a .zip extension."
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Unpacking FTB server modpack ${srv_modpack} ..."
|
|
||||||
mkdir -p ${FTB_BASE_DIR}
|
|
||||||
unzip -o ${srv_modpack} -d ${FTB_BASE_DIR} | awk '{printf "."} END {print ""}'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l) = 0 ]]; then
|
|
||||||
|
|
||||||
# Allow up to 2 levels since some modpacks have a top-level directory named
|
|
||||||
# for the modpack
|
|
||||||
forgeJar=$(find ${FTB_BASE_DIR} -maxdepth 2 -name 'forge*.jar' -a -not -name 'forge*installer')
|
|
||||||
if [[ "$forgeJar" ]]; then
|
|
||||||
export FTB_BASE_DIR=$(dirname "${forgeJar}")
|
|
||||||
log "No entry script found, so building one for ${forgeJar}"
|
|
||||||
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
|
|
||||||
#!/bin/sh
|
|
||||||
. ./settings-local.sh
|
|
||||||
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
|
|
||||||
EOF
|
|
||||||
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
|
|
||||||
else
|
|
||||||
log "Please make sure you are using the server version of the FTB modpack!"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
|
|
||||||
if [[ $scriptCount = 0 ]]; then
|
|
||||||
log "Please make sure you are using the server version of the FTB modpack!"
|
|
||||||
exit 2
|
|
||||||
elif [[ $scriptCount > 1 ]]; then
|
|
||||||
log "Ambigous startup scripts in FTB modpack!"
|
|
||||||
log "found:"
|
|
||||||
find ${FTB_BASE_DIR} $entryScriptExpr
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
|
|
||||||
|
|
||||||
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
|
|
||||||
chmod a+x "${FTB_SERVER_START}"
|
|
||||||
grep fml.queryResult=confirm ${FTB_SERVER_START} > /dev/null || \
|
|
||||||
sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${FTB_SERVER_START}"
|
|
||||||
sed -i 's/.*read.*Restart now/#\0/' "${FTB_SERVER_START}"
|
|
||||||
legacyJavaFixerPath="${FTB_DIR}/mods/legacyjavafixer.jar"
|
|
||||||
|
|
||||||
if isTrue ${FTB_LEGACYJAVAFIXER} && [ ! -e "${legacyJavaFixerPath}" ]; then
|
|
||||||
log "Installing legacy java fixer to ${legacyJavaFixerPath}"
|
|
||||||
curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then
|
|
||||||
pushd "${FTB_DIR}"
|
|
||||||
sh FTBInstall.sh
|
|
||||||
popd
|
|
||||||
elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
|
||||||
pushd "${FTB_DIR}"
|
|
||||||
sh Install.sh
|
|
||||||
popd
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Continue to Final Setup
|
# Continue to Final Setup
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then
|
|||||||
exec mc-server-runner ${mcServerRunnerArgs} \
|
exec mc-server-runner ${mcServerRunnerArgs} \
|
||||||
--cf-instance-file "${CURSE_INSTANCE_JSON}" \
|
--cf-instance-file "${CURSE_INSTANCE_JSON}" \
|
||||||
java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar _SERVERJAR_ "$@" $EXTRA_ARGS
|
java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar _SERVERJAR_ "$@" $EXTRA_ARGS
|
||||||
elif [[ ${TYPE} == "FEED-THE-BEAST" && "${SERVER}" ]]; then
|
elif [[ ${TYPE} == "CURSEFORGE" && "${SERVER}" ]]; then
|
||||||
copyFilesForCurseForge
|
copyFilesForCurseForge
|
||||||
|
|
||||||
cd "${FTB_DIR}"
|
cd "${FTB_DIR}"
|
||||||
@@ -190,7 +190,7 @@ elif [[ ${TYPE} == "FEED-THE-BEAST" && "${SERVER}" ]]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $(basename "${SERVER}") "$@" $EXTRA_ARGS
|
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $(basename "${SERVER}") "$@" $EXTRA_ARGS
|
||||||
elif [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
elif [[ ${TYPE} == "CURSEFORGE" ]]; then
|
||||||
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
||||||
|
|
||||||
copyFilesForCurseForge
|
copyFilesForCurseForge
|
||||||
|
|||||||
Reference in New Issue
Block a user