diff --git a/Dockerfile b/Dockerfile
index 9f8fbd24..bb55d460 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,34 +32,35 @@ ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG TARGETVARIANT=""
-ARG EASY_ADD_VER=0.5.3
+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
RUN chmod +x /usr/bin/easy-add
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
- --var version=1.2.0 --var app=restify --file restify \
+ --var version=1.2.0 --var app=restify --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
-RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
- --var version=1.4.7 --var app=rcon-cli --file rcon-cli \
+RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
+ --var version=1.4.7 --var app=rcon-cli --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
- --var version=0.1.7 --var app=mc-monitor --file mc-monitor \
+ --var version=0.1.7 --var app=mc-monitor --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
- --var version=1.3.3 --var app=mc-server-runner --file mc-server-runner \
+ --var version=1.3.5 --var app=mc-server-runner --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
-RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
- --var version=0.1.1 --var app=maven-metadata-release --file maven-metadata-release \
+RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
+ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
COPY mcstatus /usr/local/bin
-VOLUME ["/data","/mods","/config"]
+VOLUME ["/data"]
COPY server.properties /tmp/server.properties
+COPY log4j2.xml /tmp/log4j2.xml
WORKDIR /data
ENTRYPOINT [ "/start" ]
diff --git a/README.md b/README.md
index 65cc83b6..5dedf38f 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,8 @@ latest snapshot. See the *Versions* section below for more information.
[](https://github.com/itzg/docker-minecraft-server/blob/master/README.md)
+[Full docs available in Github](https://github.com/itzg/docker-minecraft-server/blob/master/README.md)
+
To simply use the latest stable version, run
docker run -d -p 25565:25565 --name mc itzg/minecraft-server
@@ -118,11 +120,30 @@ or a specific version:
docker run -d -e VERSION=1.7.9 ...
-When using "LATEST" or "SNAPSHOT" an upgrade can be performed by simply restarting the container.
+When using "LATEST" or "SNAPSHOT" an upgrade can be performed by simply restarting the container.
During the next startup, if a newer version is available from the respective release channel, then
the new server jar file is downloaded and used. _NOTE: over time you might see older versions of
the server jar remain in the `/data` directory. It is safe to remove those._
+## Running Minecraft server on different Java version
+
+To use a different version of Java, please use a docker tag to run your Minecraft server.
+
+| Tag name | Description | Linux |
+|---------|-------------|-------|
+| latest | **Default**. Uses Java version 8 update 212 | Alpine Linux |
+| adopt13 | Uses Java version 13 latest update | Alpine Linux |
+| adopt11 | Uses Java version 11 latest update | Alpine Linux |
+| openj9 | Uses Eclipse OpenJ9 JVM | Alpine Linux |
+| openj9-nightly | Uses Eclipse OpenJ9 JVM testing builds | Alpine Linux |
+| multiarch | Uses Java version 8 latest update | Debian Linux |
+
+For example, to use a Java version 13:
+
+ docker run --name mc itzg/minecraft-server:adopt13
+
+Keep in mind that some versions of Minecraft server can't work on the newest versions of Java. Also, FORGE doesn't support openj9 JVM implementation.
+
## Healthcheck
This image contains [Dinnerbone's mcstatus](https://github.com/Dinnerbone/mcstatus) and uses
@@ -151,6 +172,17 @@ description: "{u'text': u'A Minecraft Server Powered by Docker'}"
players: 0/20 No players online
```
+## Deployment Templates and Examples
+
+### Helm Charts
+
+- [stable/minecraft](https://hub.helm.sh/charts/stable/minecraft) ([chart source](https://github.com/helm/charts/tree/master/stable/minecraft))
+- [mcsh/server-deployment](https://github.com/mcserverhosting-net/charts)
+
+### Examples
+
+The [examples directory](https://github.com/itzg/docker-minecraft-server/tree/master/examples) also provides examples of deploying the [itzg/minecraft-server](https://hub.docker.com/r/itzg/minecraft-server/) Docker image.
+
## Running a Forge Server
Enable Forge server mode by adding a `-e TYPE=FORGE` to your command-line.
@@ -229,7 +261,7 @@ For those cases there is the option to replace defined variables inside your con
with environment variables defined at container runtime.
If you set the enviroment variable `REPLACE_ENV_VARIABLES` to `TRUE` the startup script
-will go thru all files inside your `/data` volume and replace variables that match your
+will go thru all files inside your `/data` volume and replace variables that match your
defined environment variables. Variables that you want to replace need to be wrapped
inside `${YOUR_VARIABLE}` curly brackets and prefixed with a dollar sign. This is the regular
syntax for enviromment variables inside strings or config files.
@@ -389,7 +421,7 @@ If you are hosting your own copy of PaperSpigot you can override the download UR
You can install Bukkit plugins in two ways...
-An example compose file is provided at
+An example compose file is provided at
[examples/docker-compose-paper.yml](examples/docker-compose-paper.yml).
### Using the /data volume
@@ -440,49 +472,19 @@ variable. An FTB/CurseForge server modpack is available together with its respec
client modpack on https://www.feed-the-beast.com under "Additional Files." Similar you can
locate the modpacks for CurseForge at https://minecraft.curseforge.com/modpacks .
-There are a couple of options for obtaining an FTB/CurseForge modpack.
-One options is that you can pre-download the **server** modpack and copy the modpack to the `/data`
-directory (see "Attaching data directory to host filesystem”).
-
Now you can add a `-e FTB_SERVER_MOD=name_of_modpack.zip` to your command-line.
docker run -d -v /path/on/host:/data -e TYPE=FTB \
-e FTB_SERVER_MOD=FTBPresentsSkyfactory3Server_3.0.6.zip \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
-Instead of pre-downloading a modpack from the FTB/CurseForge site, you
-can you set `FTB_SERVER_MOD` (or `CF_SERVER_MOD`) to the **server** URL of a modpack, such as
+If you don't want to keep the pre-download modpacks separate from your data directory,
+then you can attach another volume at a path of your choosing and reference that.
+The following example uses `/modpacks` as the container path as the pre-download area:
- docker run ... \
- -e TYPE=FTB \
- -e FTB_SERVER_MOD=https://www.feed-the-beast.com/projects/ftb-infinity-lite-1-10/files/2402889
-
-or for a CurseForce modpack:
-
- docker run ... \
- -e TYPE=CURSEFORGE \
- -e CF_SERVER_MOD=https://minecraft.curseforge.com/projects/enigmatica2expert/files/2663153/download
-
-### Using the /data volume
-
-You must use a persistent `/data` mount for this type of server.
-
-To do this, you will need to attach the container's `/data` directory
-(see "Attaching data directory to host filesystem”).
-
-If the modpack is updated and you want to run the new version on your
-server, you stop and remove the container:
-
- docker stop mc
- docker rm mc
-
-Do not erase anything from your /data directory (unless you know of
-specific mods that have been removed from the modpack). Download the
-updated FTB server modpack and copy it to `/data`. Start a new container
-with `FTB_SERVER_MOD` specifying the updated modpack file.
-
- $ docker run -d -v /path/on/host:/data -e TYPE=FTB \
- -e FTB_SERVER_MOD=FTBPresentsSkyfactory3Server_3.0.7.zip \
+ docker run -d -v /path/on/host:/data -v /path/to/modpacks:/modpacks \
+ -e TYPE=FTB \
+ -e FTB_SERVER_MOD=/modpacks/FTBPresentsSkyfactory3Server_3.0.6.zip \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
### Fixing "unable to launch forgemodloader"
@@ -497,8 +499,8 @@ then you apply a workaround by adding this to the run invocation:
### Using a client-made curseforge modpack
-If you use something like curseforge, you may end up creating/using modpacks that do not
-contain server mod jars. Instead, the curseforge setup has `manifest.json` files, which
+If you use something like CurseForge, you may end up creating/using modpacks that do not
+contain server mod jars. Instead, the CurseForge setup has `manifest.json` files, which
will show up under `/data/FeedTheBeast/manifest.json`.
To use these packs you will need to:
@@ -529,7 +531,7 @@ $ docker run -itd --name derpcraft \
itzg/minecraft-server
```
-Note the `CF_SERVER_MOD` env var should match the url to download the modpack you are targeting.
+Note the `CF_SERVER_MOD` env var should match the server version of the modpack you are targeting.
## Running a SpongeVanilla server
@@ -615,16 +617,16 @@ in either persistent volumes or a downloadable archive.
## Running with a custom server JAR
If you would like to run a custom server JAR, set `-e TYPE=CUSTOM` and pass the custom server
-JAR via `CUSTOM_SERVER`. It can either be a URL or a container path to an existing JAR file.
+JAR via `CUSTOM_SERVER`. It can either be a URL or a container path to an existing JAR file.
If it is a URL, it will only be downloaded into the `/data` directory if it wasn't already. As
such, if you need to upgrade or re-download the JAR, then you will need to stop the container,
-remove the file from the container's `/data` directory, and start again.
+remove the file from the container's `/data` directory, and start again.
## Force re-download of the server file
-For VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types, set
-`$FORCE_REDOWNLOAD` to some value (e.g. 'true) to force a re-download of the server file for
+For VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types, set
+`$FORCE_REDOWNLOAD` to some value (e.g. 'true) to force a re-download of the server file for
the particular server type. by adding a `-e FORCE_REDOWNLOAD=true` to your command-line.
For example, with PaperSpigot, it would look something like this:
@@ -831,7 +833,7 @@ Determines if monsters will be spawned.
Determines if villagers will be spawned.
docker run -d -e SPAWN_NPCS=true
-
+
### Set spawn protection
Sets the area that non-ops can not edit (0 to disable)
@@ -960,7 +962,7 @@ from `/worlds/basic`. Also notice in the example that you can use a
read-only volume attachment to ensure the clone source remains pristine.
```
-docker run ... -v $HOME/worlds:/worlds:ro -e WORLD=/worlds/basic
+docker run ... -v $HOME/worlds:/worlds:ro -e WORLD=/worlds/basic
```
### Downloadable mod/plugin pack for Forge, Bukkit, and Spigot Servers
@@ -978,7 +980,7 @@ particular `TYPE` of server you are running.
You may also download individual mods using the `MODS` environment variable and supplying the URL
to the jar files. Multiple mods/plugins should be comma separated.
- docker run -d -e MODS=https://www.example.com/mods/mod1.jar,https://www.example.com/mods/mod2.jar ...
+ docker run -d -e MODS=https://www.example.com/mods/mod1.jar,https://www.example.com/mods/mod2.jar ...
### Remove old mods/plugins
@@ -990,7 +992,7 @@ To use this option pass the environment variable `REMOVE_OLD_MODS="TRUE"`, such
docker run -d -e REMOVE_OLD_MODS="TRUE" -e MODPACK=http://www.example.com/mods/modpack.zip ...
**WARNING:** All content of the `mods` or `plugins` directory will be deleted
-before unpacking new content from the MODPACK or MODS.
+before unpacking new content from the MODPACK or MODS.
### Online mode
@@ -1039,7 +1041,13 @@ environment variable. Options like `-X` that need to proceed general JVM options
via a `JVM_XX_OPTS` environment variable.
For some cases, if e.g. after removing mods, it could be necessary to startup minecraft with an additional `-D` parameter like `-Dfml.queryResult=confirm`. To address this you can use the environment variable `JVM_DD_OPTS`, which builds the params from a given list of values separated by space, but without the `-D` prefix. To make things running under systems (e.g. Plesk), which doesn't allow `=` inside values, a `:` (colon) could be used instead. The upper example would look like this:
-`JVM_DD_OPTS=fml.queryResult:confirm`, and will be converted to `-Dfml.queryResult=confirm`.
+`JVM_DD_OPTS=fml.queryResult:confirm`, and will be converted to `-Dfml.queryResult=confirm`.
+
+### Enable Remote JMX for Profiling
+
+To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true` and add a port forwarding of TCP port 7091, such as:
+
+ -e ENABLE_JMX=true -p 7091:7091
### HTTP Proxy
@@ -1058,3 +1066,11 @@ pass that at the end of `docker run` after the image name or set `-e CONSOLE=FAL
Some older servers get confused and think that the GUI interface is enabled. You can explicitly
disable that by passing `-e GUI=FALSE`.
+
+## Running on RaspberryPi
+
+To run this image on a RaspberryPi 3 B+, 4, or newer, use the image tag
+
+ itzg/minecraft-server:armv7
+
+> NOTE: you may need to lower the memory allocation, such as `-e MEMORY=750m`
\ No newline at end of file
diff --git a/docker-versions-create.sh b/docker-versions-create.sh
index 3c3ad353..36486ba3 100755
--- a/docker-versions-create.sh
+++ b/docker-versions-create.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#set -x
# Use this variable to indicate a list of branches that docker hub is watching
-branches_list=('openj9' 'openj9-nightly' 'adopt11')
+branches_list=('openj9' 'openj9-nightly' 'adopt11' 'adopt13' 'multiarch' 'armv7')
function TrapExit {
echo "Checking out back in master"
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 00000000..2eab9875
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,3 @@
+# Deployment Examples
+
+This directory contains various deployment examples of the [itzg/minecraft-server](https://hub.docker.com/r/itzg/minecraft-server/) Docker image.
\ No newline at end of file
diff --git a/k8s-examples/using-statefulset.yml b/examples/k8s/using-statefulset.yml
similarity index 100%
rename from k8s-examples/using-statefulset.yml
rename to examples/k8s/using-statefulset.yml
diff --git a/k8s-examples/vanilla-deployment.yml b/examples/k8s/vanilla-deployment.yml
similarity index 100%
rename from k8s-examples/vanilla-deployment.yml
rename to examples/k8s/vanilla-deployment.yml
diff --git a/log4j2.xml b/log4j2.xml
new file mode 100644
index 00000000..ca9f73d2
--- /dev/null
+++ b/log4j2.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/start b/start
index 69ed3d53..3a919292 100644
--- a/start
+++ b/start
@@ -1,5 +1,7 @@
#!/bin/bash
+. /start-utils
+
umask 0002
chmod g+w /data
@@ -10,7 +12,7 @@ if [ $(id -u) = 0 ]; then
if [[ -v UID ]]; then
if [[ $UID != 0 ]]; then
if [[ $UID != $(id -u minecraft) ]]; then
- echo "Changing uid of minecraft to $UID"
+ log "Changing uid of minecraft to $UID"
usermod -u $UID minecraft
fi
else
@@ -21,7 +23,7 @@ if [ $(id -u) = 0 ]; then
if [[ -v GID ]]; then
if [[ $GID != 0 ]]; then
if [[ $GID != $(id -g minecraft) ]]; then
- echo "Changing gid of minecraft to $GID"
+ log "Changing gid of minecraft to $GID"
groupmod -o -g $GID minecraft
fi
else
@@ -30,7 +32,7 @@ if [ $(id -u) = 0 ]; then
fi
if [[ $(stat -c "%u" /data) != $UID ]]; then
- echo "Changing ownership of /data to $UID ..."
+ log "Changing ownership of /data to $UID ..."
chown -R ${runAsUser}:${runAsGroup} /data
fi
diff --git a/start-configuration b/start-configuration
index 8f0555f7..aa014998 100644
--- a/start-configuration
+++ b/start-configuration
@@ -1,5 +1,7 @@
#!/bin/bash
+. /start-utils
+
shopt -s nullglob
#umask 002
@@ -8,28 +10,28 @@ export HOME=/data
if [ ! -e /data/eula.txt ]; then
EULA="${EULA,,}"
if [ "$EULA" != "true" ]; then
- echo ""
- echo "Please accept the Minecraft EULA at"
- echo " https://account.mojang.com/documents/minecraft_eula"
- echo "by adding the following immediately after 'docker run':"
- echo " -e EULA=TRUE"
- echo ""
+ log ""
+ log "Please accept the Minecraft EULA at"
+ log " https://account.mojang.com/documents/minecraft_eula"
+ log "by adding the following immediately after 'docker run':"
+ log " -e EULA=TRUE"
+ log ""
exit 1
fi
echo "# Generated via Docker on $(date)" > eula.txt
echo "eula=$EULA" >> eula.txt
if [ $? != 0 ]; then
- echo "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
+ log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
exit 2
fi
fi
-echo "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
+log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'"
if ! touch /data/.verify_access; then
- echo "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
+ log "ERROR: /data doesn't seem to be writable. Please make sure attached directory is writable by uid=$(id -u)"
exit 2
fi
@@ -38,14 +40,13 @@ rm /data/.verify_access || true
if [[ $PROXY ]]; then
export http_proxy="$PROXY"
export https_proxy="$PROXY"
- echo "INFO: Giving proxy time to startup..."
+ log "INFO: Giving proxy time to startup..."
sleep 5
fi
export SERVER_PROPERTIES=/data/server.properties
export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.json
-echo "Checking version information."
case "X$VERSION" in
X|XLATEST|Xlatest)
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
@@ -60,12 +61,13 @@ case "X$VERSION" in
export VANILLA_VERSION=`curl -fsSL $VERSIONS_JSON | jq -r '.latest.release'`
;;
esac
+log "Resolved version given ${VERSION} into ${VANILLA_VERSION}"
cd /data
export ORIGINAL_TYPE=${TYPE^^}
-echo "Checking type information."
+log "Resolving type given ${TYPE}"
case "${TYPE^^}" in
*BUKKIT|SPIGOT)
exec /start-deployBukkitSpigot $@
@@ -100,8 +102,8 @@ case "${TYPE^^}" in
;;
*)
- echo "Invalid type: '$TYPE'"
- echo "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA"
+ log "Invalid type: '$TYPE'"
+ log "Must be: VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, FTB, CURSEFORGE, SPONGEVANILLA"
exit 1
;;
diff --git a/start-deployBukkitSpigot b/start-deployBukkitSpigot
index b69532db..a6e25f19 100644
--- a/start-deployBukkitSpigot
+++ b/start-deployBukkitSpigot
@@ -1,24 +1,27 @@
#!/bin/bash
+. /start-utils
+
set -e
function buildSpigotFromSource {
- echo "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
+ log "Building Spigot $VANILLA_VERSION from source, might take a while, get some coffee"
rm -rf /data/temp
mkdir /data/temp
cd /data/temp
jvmOpts="-Xms${INIT_MEMORY:-$MEMORY} -Xmx${MAX_MEMORY:-$MEMORY}"
+ logn ''
curl -sSL -o /data/temp/BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar && \
- java $jvmOpts -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; echo "done"
+ java $jvmOpts -jar /data/temp/BuildTools.jar --rev $VANILLA_VERSION 2>&1 |tee /data/spigot_build.log| while read l; do echo -n .; done; log "done"
if ! mv spigot-*.jar /data/spigot_server.jar; then
- echo "ERR failed to build Spigot"
+ log "ERR failed to build Spigot"
cat /data/spigot_build.log
exit 1
fi
mv craftbukkit-*.jar /data/${SERVER}
- echo "Cleaning up"
+ log "Cleaning up"
rm -rf /data/temp
cd /data
}
@@ -42,7 +45,7 @@ function downloadSpigot {
downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar"
fi
- echo "Downloading $match from $downloadUrl ..."
+ log "Downloading $match from $downloadUrl ..."
curl -fsSL -o $SERVER "$downloadUrl"
if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then
cat < $downloaded"
curl -sSL -o $downloaded $srv_modpack
fi
@@ -60,16 +60,16 @@ if [[ $startScriptCount = 0 ]]; then
srv_modpack=/data/${srv_modpack}
fi
if [[ ! -f ${srv_modpack} ]]; then
- echo "FTB server modpack ${srv_modpack} not found."
+ log "FTB server modpack ${srv_modpack} not found."
exit 2
fi
if [[ ! ${srv_modpack: -4} == ".zip" ]]; then
- echo "FTB server modpack ${srv_modpack} is not a zip archive."
- echo "Please set FTB_SERVER_MOD to a file with a .zip extension."
+ 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
- echo "Unpacking FTB server modpack ${srv_modpack} ..."
+ 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
@@ -79,7 +79,7 @@ if [[ $(find ${FTB_BASE_DIR} $entryScriptExpr | wc -l) = 0 ]]; then
forgeJar=$(find ${FTB_BASE_DIR} -name 'forge*.jar' -a -not -name 'forge*installer')
if [[ "$forgeJar" ]]; then
export FTB_BASE_DIR=$(dirname "${forgeJar}")
- echo "No entry script found, so building one for ${forgeJar}"
+ log "No entry script found, so building one for ${forgeJar}"
cat > "${FTB_BASE_DIR}/ServerStart.sh" < 1 ]]; then
- echo "Ambigous startup scripts in FTB modpack!"
- echo "found:"
+ log "Ambigous startup scripts in FTB modpack!"
+ log "found:"
find ${FTB_BASE_DIR} $entryScriptExpr
exit 2
fi
@@ -107,12 +107,13 @@ export FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr)
export FTB_DIR=$(dirname "${FTB_SERVER_START}")
chmod a+x "${FTB_SERVER_START}"
-sed -i 's/-jar/-Dfml.queryResult=confirm -jar/' "${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
- echo "Installing legacy java fixer to ${legacyJavaFixerPath}"
+ log "Installing legacy java fixer to ${legacyJavaFixerPath}"
curl -sSL -o "${legacyJavaFixerPath}" ${legacyJavaFixerUrl}
fi
diff --git a/start-deployFabric b/start-deployFabric
index ad6e1d7b..194594a9 100644
--- a/start-deployFabric
+++ b/start-deployFabric
@@ -9,7 +9,7 @@ FABRIC_INSTALLER=${FABRIC_INSTALLER:-}
FABRIC_INSTALLER_URL=${FABRIC_INSTALLER_URL:-}
FABRICVERSION=${FABRICVERSION:-LATEST}
if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
- echo "Checking Fabric version information."
+ log "Checking Fabric version information."
case $FABRICVERSION in
LATEST)
FABRIC_VERSION=$(maven-metadata-release https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml)
@@ -25,7 +25,7 @@ if [[ -z $FABRIC_INSTALLER && -z $FABRIC_INSTALLER_URL ]]; then
elif [[ -z $FABRIC_INSTALLER ]]; then
FABRIC_INSTALLER="/tmp/fabric-installer.jar"
elif [[ ! -e $FABRIC_INSTALLER ]]; then
- echo "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
+ log "ERROR: the given Fabric installer doesn't exist : $FABRIC_INSTALLER"
exit 2
fi
@@ -35,14 +35,14 @@ debug Checking for installMarker ${installMarker}
if [[ ! -e $installMarker ]]; then
if [[ ! -e $FABRIC_INSTALLER ]]; then
if [[ -z $FABRIC_INSTALLER_URL ]]; then
- echo "Downloading $FABRIC_VERSION"
+ log "Downloading $FABRIC_VERSION"
downloadUrl="https://maven.fabricmc.net/net/fabricmc/fabric-installer/$FABRIC_VERSION/fabric-installer-$FABRIC_VERSION.jar"
- echo "...trying $downloadUrl"
+ log "...trying $downloadUrl"
curl -o $FABRIC_INSTALLER -fsSL $downloadUrl
else
- echo "Downloading $FABRIC_INSTALLER_URL ..."
+ log "Downloading $FABRIC_INSTALLER_URL ..."
if ! curl -o $FABRIC_INSTALLER -fsSL $FABRIC_INSTALLER_URL; then
- echo "Failed to download from given location $FABRIC_INSTALLER_URL"
+ log "Failed to download from given location $FABRIC_INSTALLER_URL"
exit 2
fi
fi
@@ -51,7 +51,7 @@ if [[ ! -e $installMarker ]]; then
if isDebugging; then
debug "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER with mcversion ${VANILLA_VERSION}"
else
- echo "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER"
+ log "Installing Fabric $FABRIC_VERSION using $FABRIC_INSTALLER"
fi
tries=3
set +e
@@ -63,11 +63,11 @@ if [[ ! -e $installMarker ]]; then
done
set -e
if (($tries < 0)); then
- echo "Fabric failed to install after several tries." >&2
+ log "Fabric failed to install after several tries." >&2
exit 10
fi
export SERVER=fabric-server-launch.jar
- echo "Using server $SERVER"
+ log "Using server $SERVER"
echo $SERVER > $installMarker
else
diff --git a/start-deployForge b/start-deployForge
index e0d07022..d280ac5e 100644
--- a/start-deployForge
+++ b/start-deployForge
@@ -1,5 +1,7 @@
#!/bin/bash
+. /start-utils
+
export TYPE=FORGE
if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
@@ -14,7 +16,7 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
#################################################################################
- echo "Checking Forge version information."
+ log "Checking Forge version information."
case $FORGEVERSION in
RECOMMENDED)
curl -fsSL -o /tmp/forge.json http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
@@ -22,8 +24,8 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
if [ $FORGE_VERSION = null ]; then
FORGE_VERSION=$(cat /tmp/forge.json | jq -r ".promos[\"$VANILLA_VERSION-latest\"]")
if [ $FORGE_VERSION = null ]; then
- echo "ERROR: Version $VANILLA_VERSION is not supported by Forge"
- echo " Refer to http://files.minecraftforge.net/ for supported versions"
+ log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
+ log " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2
fi
fi
@@ -41,7 +43,7 @@ if [[ -z $FORGE_INSTALLER && -z $FORGE_INSTALLER_URL ]]; then
elif [[ -z $FORGE_INSTALLER ]]; then
FORGE_INSTALLER="/tmp/forge-installer.jar"
elif [[ ! -e $FORGE_INSTALLER ]]; then
- echo "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
+ log "ERROR: the given Forge installer doesn't exist : $FORGE_INSTALLER"
exit 2
fi
@@ -51,7 +53,7 @@ if [ ! -e $installMarker ]; then
if [ ! -e $FORGE_INSTALLER ]; then
if [[ -z $FORGE_INSTALLER_URL ]]; then
- echo "Downloading $normForgeVersion"
+ log "Downloading $normForgeVersion"
forgeFileNames="
$normForgeVersion/forge-$normForgeVersion-installer.jar
@@ -60,25 +62,25 @@ if [ ! -e $installMarker ]; then
"
for fn in $forgeFileNames; do
if [ $fn == END ]; then
- echo "Unable to compute URL for $normForgeVersion"
+ log "Unable to compute URL for $normForgeVersion"
exit 2
fi
downloadUrl=http://files.minecraftforge.net/maven/net/minecraftforge/forge/$fn
- echo "...trying $downloadUrl"
+ log "...trying $downloadUrl"
if curl -o $FORGE_INSTALLER -fsSL $downloadUrl; then
break
fi
done
else
- echo "Downloading $FORGE_INSTALLER_URL ..."
+ log "Downloading $FORGE_INSTALLER_URL ..."
if ! curl -o $FORGE_INSTALLER -fsSL $FORGE_INSTALLER_URL; then
- echo "Failed to download from given location $FORGE_INSTALLER_URL"
+ log "Failed to download from given location $FORGE_INSTALLER_URL"
exit 2
fi
fi
fi
- echo "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
+ log "Installing Forge $shortForgeVersion using $FORGE_INSTALLER"
mkdir -p mods
tries=3
while ((--tries >= 0)); do
@@ -88,22 +90,22 @@ if [ ! -e $installMarker ]; then
fi
done
if (($tries < 0)); then
- echo "Forge failed to install after several tries." >&2
+ log "Forge failed to install after several tries." >&2
exit 10
fi
# NOTE $shortForgeVersion will be empty if installer location was given to us
- echo "Finding installed server jar..."
+ log "Finding installed server jar..."
unset -v latest
for file in *forge*.jar; do
[[ $file =~ installer ]] || [[ $file -nt $latest ]] && latest=$file
done
if [[ -z $latest ]]; then
- echo "Unable to derive server jar for Forge"
+ log "Unable to derive server jar for Forge"
exit 2
fi
export SERVER=$latest
- echo "Using server $SERVER"
+ log "Using server $SERVER"
echo $SERVER > $installMarker
else
diff --git a/start-deployPaper b/start-deployPaper
index aac76d30..bec4016f 100644
--- a/start-deployPaper
+++ b/start-deployPaper
@@ -1,12 +1,14 @@
#!/bin/bash
+. /start-utils
+
export SERVER=paper_server-${VANILLA_VERSION}.jar
if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/latest/download}
- echo "Downloading Paper $VANILLA_VERSION from $downloadUrl ..."
+ log "Downloading Paper $VANILLA_VERSION from $downloadUrl ..."
curl -fsSL -o "$SERVER" "$downloadUrl"
if [ ! -f "$SERVER" ]; then
- echo "ERROR: failed to download from $downloadUrl (status=$?)"
+ log "ERROR: failed to download from $downloadUrl (status=$?)"
exit 3
fi
fi
diff --git a/start-deploySpongeVanilla b/start-deploySpongeVanilla
index 116e610f..f6ab1934 100644
--- a/start-deploySpongeVanilla
+++ b/start-deploySpongeVanilla
@@ -1,9 +1,11 @@
#!/bin/bash
+. /start-utils
+
export TYPE=spongevanilla
# Parse branch
-echo "Choosing branch for Sponge"
+log "Choosing branch for Sponge"
case "$SPONGEBRANCH" in
EXPERIMENTAL|experimental|BLEEDING|bleeding)
@@ -18,7 +20,7 @@ esac
# If not SPONGEVERSION selected, detect last version on selected branch
if [ -z $SPONGEVERSION ]; then
- echo "Choosing Version for Sponge"
+ log "Choosing Version for Sponge"
if [ "$SPONGEBRANCH" == "stable" ]; then
export SPONGEVERSION=`curl -fsSL https://dl-api.spongepowered.org/v1/org.spongepowered/$TYPE | jq -r '.buildTypes.stable.latest.version'`
else
@@ -29,7 +31,7 @@ fi
export SERVER="spongevanilla-$SPONGEVERSION.jar"
if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
- echo "Downloading $SERVER ..."
+ log "Downloading $SERVER ..."
curl -sSL -o $SERVER https://repo.spongepowered.org/maven/org/spongepowered/$TYPE/$SPONGEVERSION/$SERVER
fi
diff --git a/start-deployVanilla b/start-deployVanilla
index 69cf5d6f..e5dd91c3 100644
--- a/start-deployVanilla
+++ b/start-deployVanilla
@@ -6,16 +6,16 @@ set -o pipefail
export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar"
if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
- echo "Downloading $SERVER ..."
+ log "Downloading $SERVER ..."
debug "Finding version manifest for $VANILLA_VERSION"
versionManifestUrl=$(curl -fsSL 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url')
result=$?
if [ $result != 0 ]; then
- echo "ERROR failed to obtain version manifest URL ($result)"
+ log "ERROR failed to obtain version manifest URL ($result)"
exit 1
fi
if [ $versionManifestUrl = "null" ]; then
- echo "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION"
+ log "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION"
exit 1
fi
debug "Found version manifest at $versionManifestUrl"
@@ -23,7 +23,7 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
serverDownloadUrl=$(curl -fsSL ${versionManifestUrl} | jq --raw-output '.downloads.server.url')
result=$?
if [ $result != 0 ]; then
- echo "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
+ log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
exit 1
fi
@@ -34,7 +34,7 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
curl $verbose -fsSL -o $SERVER $serverDownloadUrl
result=$?
if [ $result != 0 ]; then
- echo "ERROR failed to download server from $serverDownloadUrl ($result)"
+ log "ERROR failed to download server from $serverDownloadUrl ($result)"
exit 1
fi
fi
diff --git a/start-finalSetup01World b/start-finalSetup01World
index 201f6685..0a7b5e2c 100644
--- a/start-finalSetup01World
+++ b/start-finalSetup01World
@@ -1,5 +1,7 @@
#!/bin/bash
+. /start-utils
+
if [ $TYPE = "FEED-THE-BEAST" ]; then
worldDest=$FTB_BASE_DIR/$LEVEL
else
@@ -10,24 +12,24 @@ fi
if [[ "$WORLD" ]] && [ ! -d "$worldDest" ]; then
case "X$WORLD" in
X[Hh][Tt][Tt][Pp]*)
- echo "Downloading world from $WORLD"
+ log "Downloading world from $WORLD"
curl -sSL -o - "$WORLD" > /data/world.zip
- echo "Unzipping world"
+ log "Unzipping world"
unzip -o -q /data/world.zip
rm -f /data/world.zip
if [ ! -d $worldDest ]; then
- echo World directory not found
+ log World directory not found
for i in /data/*/level.dat; do
if [ -f "$i" ]; then
d=`dirname "$i"`
- echo Renaming world directory from $d
+ log Renaming world directory from $d
mv -f "$d" $worldDest
fi
done
fi
if [ "$TYPE" = "SPIGOT" ]; then
# Reorganise if a Spigot server
- echo "Moving End and Nether maps to Spigot location"
+ log "Moving End and Nether maps to Spigot location"
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "/data/${LEVEL}_the_end"
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "/data/${LEVEL}_nether"
fi
@@ -35,13 +37,13 @@ case "X$WORLD" in
*)
if [[ -d $WORLD ]]; then
if [[ ! -d $worldDest ]]; then
- echo "Cloning world directory from $WORLD ..."
+ log "Cloning world directory from $WORLD ..."
cp -r $WORLD $worldDest
else
- echo "Skipping clone from $WORLD since $worldDest exists"
+ log "Skipping clone from $WORLD since $worldDest exists"
fi
else
- echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
+ log "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
fi
;;
esac
diff --git a/start-finalSetup02Modpack b/start-finalSetup02Modpack
index 94b637a0..751f0ce0 100644
--- a/start-finalSetup02Modpack
+++ b/start-finalSetup02Modpack
@@ -21,28 +21,28 @@ if [[ "$MODPACK" ]]; then
EFFECTIVE_MODPACK_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MODPACK)
case "X$EFFECTIVE_MODPACK_URL" in
X[Hh][Tt][Tt][Pp]*.zip)
- echo "Downloading mod/plugin pack via HTTP"
- echo " from $EFFECTIVE_MODPACK_URL ..."
+ log "Downloading mod/plugin pack via HTTP"
+ log " from $EFFECTIVE_MODPACK_URL ..."
if ! curl -sSL -o /tmp/modpack.zip "$EFFECTIVE_MODPACK_URL"; then
- echo "ERROR: failed to download from $EFFECTIVE_MODPACK_URL"
+ log "ERROR: failed to download from $EFFECTIVE_MODPACK_URL"
exit 2
fi
if [ "$TYPE" = "SPIGOT" ]; then
mkdir -p /data/plugins
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
- echo "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
+ log "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
fi
else
mkdir -p /data/mods
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
- echo "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
+ log "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
fi
fi
rm -f /tmp/modpack.zip
;;
*)
- echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
+ log "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
;;
esac
fi
@@ -54,10 +54,10 @@ do
EFFECTIVE_MOD_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i)
case "X$EFFECTIVE_MOD_URL" in
X[Hh][Tt][Tt][Pp]*.jar)
- echo "Downloading mod/plugin via HTTP"
- echo " from $EFFECTIVE_MOD_URL ..."
+ log "Downloading mod/plugin via HTTP"
+ log " from $EFFECTIVE_MOD_URL ..."
if ! curl -sSL -o /tmp/${EFFECTIVE_MOD_URL##*/} $EFFECTIVE_MOD_URL; then
- echo "ERROR: failed to download from $EFFECTIVE_MOD_URL to /tmp/${EFFECTIVE_MOD_URL##*/}"
+ log "ERROR: failed to download from $EFFECTIVE_MOD_URL to /tmp/${EFFECTIVE_MOD_URL##*/}"
exit 2
fi
@@ -71,7 +71,7 @@ do
rm -f /tmp/${EFFECTIVE_MOD_URL##*/}
;;
*)
- echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a JAR file"
+ log "Invalid URL given for modpack: Must be HTTP or HTTPS and a JAR file"
;;
esac
done
@@ -85,7 +85,7 @@ if [[ "$MANIFEST" ]]; then
EFFECTIVE_MANIFEST_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MANIFEST)
curl -Ls -o $EFFECTIVE_MANIFEST_FILE "$EFFECTIVE_MANIFEST_URL"
else
- echo "MANIFEST='$MANIFEST' is not a valid manifest url or location"
+ log "MANIFEST='$MANIFEST' is not a valid manifest url or location"
exit 2
fi
@@ -95,27 +95,27 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
MOD_DIR=${FTB_BASE_DIR:-/data}/mods
if [ ! -d "$MOD_DIR" ]
then
- echo "Creating mods dir $MOD_DIR"
+ log "Creating mods dir $MOD_DIR"
mkdir -p "$MOD_DIR"
fi
- echo "Starting manifest download..."
+ log "Starting manifest download..."
cat "${EFFECTIVE_MANIFEST_FILE}" | jq -r '.files[] | (.projectID|tostring) + " " + (.fileID|tostring)'| while read -r p f
do
if [ ! -f $MOD_DIR/${p}_${f}.jar ]
then
redirect_url="$(curl -Ls -o /dev/null -w %{url_effective} ${CURSE_URL_BASE}/${p})"
url="$redirect_url/download/${f}/file"
- echo Downloading curseforge mod $url
+ log Downloading curseforge mod $url
# Manifest usually doesn't have mod names. Using id should be fine, tho
curl -sSL "${url}" -o $MOD_DIR/${p}_${f}.jar
fi
done
else
- echo "Could not find manifest file, unsufficient privs, or malformed path."
+ log "Could not find manifest file, unsufficient privs, or malformed path."
fi
;;
*)
- echo "Invalid manifest file for modpack. Please make sure it is a .json file."
+ log "Invalid manifest file for modpack. Please make sure it is a .json file."
;;
esac
fi
@@ -124,7 +124,7 @@ if [[ "${GENERIC_PACK}" ]]; then
if isURL "${GENERIC_PACK}"; then
generic_pack_url=${GENERIC_PACK}
GENERIC_PACK=/tmp/$(basename ${generic_pack_url})
- echo "Downloading generic pack from ${generic_pack_url} ..."
+ log "Downloading generic pack from ${generic_pack_url} ..."
curl -fsSL -o ${GENERIC_PACK} ${generic_pack_url}
fi
@@ -134,7 +134,7 @@ if [[ "${GENERIC_PACK}" ]]; then
mkdir -p ${base_dir}
unzip -q -d ${base_dir} ${GENERIC_PACK}
depth=$(( ${GENERIC_PACK_STRIP_DIRS:-1} + 1 ))
- echo "Applying generic pack, stripping $(( depth - 1 )) level ..."
+ log "Applying generic pack, stripping $(( depth - 1 )) level ..."
find ${base_dir} -type d -mindepth $depth -maxdepth $depth -exec cp -r {} /data/ +
rm -rf ${base_dir}
sha256sum ${GENERIC_PACK} > ${sum_file}
diff --git a/start-finalSetup03Modconfig b/start-finalSetup03Modconfig
index 1467f345..f4219a73 100644
--- a/start-finalSetup03Modconfig
+++ b/start-finalSetup03Modconfig
@@ -1,11 +1,13 @@
#!/bin/bash
+. /start-utils
+
# If supplied with a URL for a config (simple zip of configurations), download it and unpack
if [[ "$MODCONFIG" ]]; then
case "X$MODCONFIG" in
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
- echo "Downloading mod/plugin configs via HTTP"
- echo " from $MODCONFIG ..."
+ log "Downloading mod/plugin configs via HTTP"
+ log " from $MODCONFIG ..."
curl -sSL -o /tmp/modconfig.zip "$MODCONFIG"
if [ "$TYPE" = "SPIGOT" ]; then
mkdir -p /data/plugins
@@ -17,7 +19,7 @@ case "X$MODCONFIG" in
rm -f /tmp/modconfig.zip
;;
*)
- echo "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
+ log "Invalid URL given for modconfig: Must be HTTP or HTTPS and a ZIP file"
;;
esac
fi
diff --git a/start-finalSetup04ServerProperties b/start-finalSetup04ServerProperties
index b9df16e8..91919a79 100644
--- a/start-finalSetup04ServerProperties
+++ b/start-finalSetup04ServerProperties
@@ -1,5 +1,7 @@
#!/bin/bash
+. /start-utils
+
# FUNCTIONS
function setServerProp {
local prop=$1
@@ -10,16 +12,16 @@ function setServerProp {
TRUE|FALSE)
var=${var,,} ;;
esac
- echo "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
+ log "Setting ${prop} to '${var}' in ${SERVER_PROPERTIES}"
sed -i "/^${prop}\s*=/ c ${prop}=${var}" "$SERVER_PROPERTIES"
else
- echo "Skip setting ${prop}"
+ log "Skip setting ${prop}"
fi
}
function customizeServerProps {
if [ -n "$WHITELIST" ]; then
- echo "Creating whitelist"
+ log "Creating whitelist"
setServerProp "whitelist" "true"
setServerProp "white-list" "true"
fi
@@ -41,6 +43,7 @@ function customizeServerProps {
fi
setServerProp "server-name" "$SERVER_NAME"
+ setServerProp "server-ip" "$SERVER_IP"
setServerProp "server-port" "$SERVER_PORT"
setServerProp "motd" "$MOTD"
setServerProp "allow-nether" "$ALLOW_NETHER"
@@ -89,7 +92,7 @@ function customizeServerProps {
DIFFICULTY=3
;;
*)
- echo "DIFFICULTY must be peaceful, easy, normal, or hard."
+ log "DIFFICULTY must be peaceful, easy, normal, or hard."
exit 1
;;
esac
@@ -97,7 +100,7 @@ function customizeServerProps {
fi
if [ -n "$MODE" ]; then
- echo "Setting mode"
+ log "Setting mode"
MODE_LC=$( echo $MODE | tr '[:upper:]' '[:lower:]' )
case $MODE_LC in
0|1|2|3)
@@ -115,7 +118,7 @@ function customizeServerProps {
MODE=3
;;
*)
- echo "ERROR: Invalid game mode: $MODE"
+ log "ERROR: Invalid game mode: $MODE"
exit 1
;;
esac
@@ -126,11 +129,11 @@ function customizeServerProps {
# Deploy server.properties file
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
export SERVER_PROPERTIES=${FTB_DIR}/server.properties
- echo "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
+ log "detected FTB, changing properties path to ${SERVER_PROPERTIES}"
fi
if [ ! -e "$SERVER_PROPERTIES" ]; then
- echo "Creating server.properties in ${SERVER_PROPERTIES}"
+ log "Creating server.properties in ${SERVER_PROPERTIES}"
cp /tmp/server.properties "$SERVER_PROPERTIES"
customizeServerProps
elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
@@ -139,11 +142,11 @@ elif [ -n "${OVERRIDE_SERVER_PROPERTIES}" ]; then
customizeServerProps
;;
*)
- echo "server.properties already created, skipping"
+ log "server.properties already created, skipping"
;;
esac
else
- echo "server.properties already created, skipping"
+ log "server.properties already created, skipping"
fi
exec /start-finalSetup05EnvVariables $@
diff --git a/start-finalSetup05EnvVariables b/start-finalSetup05EnvVariables
index 532e28e4..8f08d30a 100644
--- a/start-finalSetup05EnvVariables
+++ b/start-finalSetup05EnvVariables
@@ -1,14 +1,16 @@
#!/bin/bash
+. /start-utils
+
if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
- echo "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
+ log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
while IFS='=' read -r name value ; do
# check if name of env variable matches the prefix
# sanity check environment variables to avoid code injections
if [[ "$name" = $ENV_VARIABLE_PREFIX* ]] \
&& [[ $value =~ ^[0-9a-zA-Z_:/=?.+\-]*$ ]] \
&& [[ $name =~ ^[0-9a-zA-Z_\-]*$ ]]; then
- echo "Replacing $name with $value ..."
+ log "Replacing $name with $value ..."
find /data/ -type f \
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
-or -name "*.conf" -or -name "*.properties" \) \
diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup
index 5ab6fa2a..6f5ab2a6 100644
--- a/start-minecraftFinalSetup
+++ b/start-minecraftFinalSetup
@@ -3,36 +3,46 @@
. /start-utils
if [ -n "$OPS" ]; then
- echo "Setting/adding ops"
+ log "Setting/adding ops"
rm -rf ops.txt.converted
echo $OPS | awk -v RS=, '{print}' > ops.txt
fi
if [ -n "$WHITELIST" ]; then
- echo "Setting whitelist"
+ log "Setting whitelist"
rm -rf white-list.txt.converted
echo $WHITELIST | awk -v RS=, '{print}' > white-list.txt
fi
if [ -n "$ICON" -a ! -e server-icon.png ]; then
- echo "Using server icon from $ICON..."
+ log "Using server icon from $ICON..."
# Not sure what it is yet...call it "img"
curl -sSL -o /tmp/icon.img $ICON
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
if [ "$specs" = "PNG 64x64" ]; then
mv /tmp/icon.img /data/server-icon.png
else
- echo "Converting image to 64x64 PNG..."
+ log "Converting image to 64x64 PNG..."
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
fi
fi
+# Set up log configuration
+LOGFILE="/data/log4j2.xml"
+if [ ! -e "$LOGFILE" ]; then
+ log "Creating log4j2.xml in ${LOGFILE}"
+ cp /tmp/log4j2.xml "$LOGFILE"
+else
+ log "log4j2.xml already created, skipping"
+fi
+JVM_OPTS="-Dlog4j.configurationFile=/data/log4j2.xml ${JVM_OPTS}"
+
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
-echo "Checking for JSON files."
+log "Checking for JSON files."
JSON_FILES=$(find . -maxdepth 1 -name '*.json')
for j in $JSON_FILES; do
if [[ $(cat $j | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') == "" ]]; then
- echo "Fixing JSON $j"
+ log "Fixing JSON $j"
echo '[]' > $j
fi
done
@@ -41,7 +51,7 @@ done
# If any modules have been provided, copy them over
mkdir -p /data/mods
if [ -d /mods ]; then
- echo "Copying any mods over..."
+ log "Copying any mods over..."
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --update /mods /data
fi
@@ -49,7 +59,7 @@ fi
for c in /config/*
do
if [ -f "$c" ]; then
- echo Copying configuration `basename "$c"`
+ log Copying configuration `basename "$c"`
cp -rf "$c" /data/config
fi
done
@@ -57,7 +67,7 @@ done
mkdir -p /data/plugins
if [ "$TYPE" = "SPIGOT" ]; then
if [ -d /plugins ]; then
- echo "Copying any Bukkit plugins over..."
+ log "Copying any Bukkit plugins over..."
# Copy plugins over using rsync to allow deeply nested updates of plugins
# only updates files if the source file is newer and print updated files
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --update /plugins /data
@@ -76,7 +86,7 @@ if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
fi
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
-echo "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
+log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
expandedDOpts=
if [ -n "$JVM_DD_OPTS" ]; then
@@ -86,9 +96,26 @@ if [ -n "$JVM_DD_OPTS" ]; then
done
fi
+if isTrue ${ENABLE_JMX}; then
+ : ${JMX_HOST:=0.0.0.0}
+ : ${JMX_PORT:=7091}
+ JVM_OPTS="${JVM_OPTS}
+ -Dcom.sun.management.jmxremote.local.only=false
+ -Dcom.sun.management.jmxremote.port=${JMX_PORT}
+ -Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT}
+ -Dcom.sun.management.jmxremote.authenticate=false
+ -Dcom.sun.management.jmxremote.ssl=false
+ -Dcom.sun.management.jmxremote.host=${JMX_HOST}
+ -Djava.rmi.server.hostname=${JMX_HOST}"
+
+ log "JMX is enabled. Make sure you have port forwarding for ${JMX_PORT}"
+fi
+
mcServerRunnerArgs="--stop-duration 60s"
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
+ mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
+
if [ ! -e "${FTB_DIR}/ops.json" -a -e /data/ops.txt ]; then
cp -f /data/ops.txt ${FTB_DIR}/
fi
@@ -111,7 +138,7 @@ EOF
fi
cd "${FTB_DIR}"
- echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
+ log "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
if isTrue ${DEBUG_EXEC}; then
set -x
fi
@@ -122,7 +149,7 @@ else
bootstrapArgs="--bootstrap /data/bootstrap.txt"
fi
- echo "Starting the Minecraft server..."
+ log "Starting the Minecraft server..."
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
if isTrue ${DEBUG_EXEC}; then
set -x
diff --git a/start-utils b/start-utils
index a2aaa18d..7ef42751 100644
--- a/start-utils
+++ b/start-utils
@@ -37,6 +37,14 @@ function isDebugging {
function debug {
if isDebugging; then
- echo "DEBUG: $*"
+ log "DEBUG: $*"
fi
}
+
+function logn {
+ echo -n "[init] $*"
+}
+
+function log {
+ echo "[init] $*"
+}