mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-03-19 13:05:58 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fe55b5a28 | ||
|
|
bd503f224d | ||
|
|
b5c91647ca | ||
|
|
c359a0f2ac | ||
|
|
49d9f4a89d | ||
|
|
aebe35c9d4 | ||
|
|
a26361c79f |
@@ -1,4 +1,5 @@
|
|||||||
data
|
data
|
||||||
|
testdata
|
||||||
examples
|
examples
|
||||||
k8s-examples
|
k8s-examples
|
||||||
.idea
|
.idea
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -11,7 +11,7 @@ latest snapshot. See the _Versions_ section below for more information.
|
|||||||
|
|
||||||
To simply use the latest stable version, run
|
To simply use the latest stable version, run
|
||||||
|
|
||||||
docker run -d -p 25565:25565 --name mc itzg/minecraft-server
|
docker run -d -p 25565:25565 --name mc -e EULA=TRUE itzg/minecraft-server
|
||||||
|
|
||||||
where the standard server port, 25565, will be exposed on your host machine.
|
where the standard server port, 25565, will be exposed on your host machine.
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ With that you can easily view the logs, stop, or re-start the container:
|
|||||||
docker stop mc
|
docker stop mc
|
||||||
|
|
||||||
docker start mc
|
docker start mc
|
||||||
|
*Be sure to always include `-e EULA=TRUE` in your commands, as Mojang/Microsoft requires EULA acceptance.*
|
||||||
|
|
||||||
## Looking for a Bedrock Dedicated Server
|
## Looking for a Bedrock Dedicated Server
|
||||||
|
|
||||||
@@ -269,10 +270,20 @@ the `/path/on/host` folder contents look like:
|
|||||||
├── ops.json
|
├── ops.json
|
||||||
├── server.properties
|
├── server.properties
|
||||||
├── whitelist.json
|
├── whitelist.json
|
||||||
|
├── worlds
|
||||||
|
│ └── ... PLACE MAPS IN THEIR OWN FOLDERS HERE ...
|
||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
|
|
||||||
If you add mods while the container is running, you'll need to restart it to pick those
|
Providing a presistent `/data` mount is a good idea, both to persist the game world and to allow for the manual configuration which is sometimes needed.
|
||||||
|
|
||||||
|
For instance, imagine a scenario when the initial launch has completed, but you now want to change the worldmap for your server.
|
||||||
|
|
||||||
|
Assuming you have a shared directory to your container, you can then (after first launch) drag and drop your premade maps or worlds into the `\worlds\` directory. **Note:** each world should be placed in its own folder under the `\worlds\` directory.
|
||||||
|
|
||||||
|
Once your maps are in the proper path, you can then specify which map the server uses by changing the `level-name` value in `server.properties` to match the name of your map.
|
||||||
|
|
||||||
|
If you add mods or make changes to `server.properties` while the container is running, you'll need to restart it to pick those
|
||||||
up:
|
up:
|
||||||
|
|
||||||
docker stop mc
|
docker stop mc
|
||||||
@@ -291,6 +302,8 @@ This works well if you want to have a common set of modules in a separate
|
|||||||
location, but still have multiple worlds with different server requirements
|
location, but still have multiple worlds with different server requirements
|
||||||
in either persistent volumes or a downloadable archive.
|
in either persistent volumes or a downloadable archive.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Replacing variables inside configs
|
### Replacing variables inside configs
|
||||||
|
|
||||||
Sometimes you have mods or plugins that require configuration information that is only available at runtime.
|
Sometimes you have mods or plugins that require configuration information that is only available at runtime.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
. /start-utils
|
. /start-utils
|
||||||
|
|
||||||
sudo /usr/sbin/knockd -c /autopause/knockd-config.cfg -d
|
sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
|
|||||||
5
start
5
start
@@ -36,11 +36,6 @@ if [ $(id -u) = 0 ]; then
|
|||||||
chown -R ${runAsUser}:${runAsGroup} /data
|
chown -R ${runAsUser}:${runAsGroup} /data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(stat -c "%u" /autopause) != $UID ]]; then
|
|
||||||
log "Changing ownership of /autopause to $UID ..."
|
|
||||||
chown -R ${runAsUser}:${runAsGroup} /autopause
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then
|
if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then
|
||||||
echo 'hosts: files dns' > /etc/nsswitch.conf
|
echo 'hosts: files dns' > /etc/nsswitch.conf
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -4,18 +4,20 @@
|
|||||||
|
|
||||||
log "Autopause functionality enabled"
|
log "Autopause functionality enabled"
|
||||||
|
|
||||||
|
cp /autopause/knockd-config.cfg /tmp/knockd-config.cfg
|
||||||
|
|
||||||
# update server port to listen to
|
# update server port to listen to
|
||||||
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$"
|
||||||
linenum=$(grep -nm1 sequence /autopause/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
linenum=$(grep -nm1 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
||||||
if ! [[ $(awk "NR==$linenum" /autopause/knockd-config.cfg) =~ $regseq ]]; then
|
if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then
|
||||||
sed -i "${linenum}s/sequence.*/sequence = $SERVER_PORT/" /autopause/knockd-config.cfg
|
sed -i "${linenum}s/sequence.*/sequence = $SERVER_PORT/" /tmp/knockd-config.cfg
|
||||||
log "Updated server port in knockd config"
|
log "Updated server port in knockd config"
|
||||||
fi
|
fi
|
||||||
# update rcon port to listen to
|
# update rcon port to listen to
|
||||||
regseq="^\s*sequence\s*=\s*$RCON_PORT\s*$"
|
regseq="^\s*sequence\s*=\s*$RCON_PORT\s*$"
|
||||||
linenum=$(grep -nm2 sequence /autopause/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
linenum=$(grep -nm2 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1)
|
||||||
if ! [[ $(awk "NR==$linenum" /autopause/knockd-config.cfg) =~ $regseq ]]; then
|
if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then
|
||||||
sed -i "${linenum}s/sequence.*/sequence = $RCON_PORT/" /autopause/knockd-config.cfg
|
sed -i "${linenum}s/sequence.*/sequence = $RCON_PORT/" /tmp/knockd-config.cfg
|
||||||
log "Updated rcon port in knockd config"
|
log "Updated rcon port in knockd config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ shopt -s nullglob
|
|||||||
export HOME=/data
|
export HOME=/data
|
||||||
|
|
||||||
if [ ! -e /data/eula.txt ]; then
|
if [ ! -e /data/eula.txt ]; then
|
||||||
EULA="${EULA,,}"
|
if ! isTrue "$EULA"; then
|
||||||
if [ "$EULA" != "true" ]; then
|
|
||||||
log ""
|
log ""
|
||||||
log "Please accept the Minecraft EULA at"
|
log "Please accept the Minecraft EULA at"
|
||||||
log " https://account.mojang.com/documents/minecraft_eula"
|
log " https://account.mojang.com/documents/minecraft_eula"
|
||||||
@@ -19,12 +18,7 @@ if [ ! -e /data/eula.txt ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "# Generated via Docker on $(date)" > /data/eula.txt
|
writeEula
|
||||||
|
|
||||||
if ! echo "eula=$EULA" >> /data/eula.txt; then
|
|
||||||
log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@@ -109,7 +103,7 @@ case "${TYPE^^}" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
FTB|CURSEFORGE)
|
FTB|CURSEFORGE)
|
||||||
exec ${SCRIPTS:-/}start-deployFTB "$@"
|
exec ${SCRIPTS:-/}start-deployCF "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
VANILLA)
|
VANILLA)
|
||||||
|
|||||||
@@ -18,42 +18,60 @@ fi
|
|||||||
|
|
||||||
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
|
||||||
if [[ "$MODPACK" ]]; then
|
if [[ "$MODPACK" ]]; then
|
||||||
EFFECTIVE_MODPACK_URL=$(curl -Ls -o /dev/null -w %{url_effective} $MODPACK)
|
if isURL "${MODPACK}"; then
|
||||||
case "X$EFFECTIVE_MODPACK_URL" in
|
if [[ "${MODPACK}" == *.zip ]]; then
|
||||||
X[Hh][Tt][Tt][Pp]*.zip)
|
downloadUrl="${MODPACK}"
|
||||||
|
else
|
||||||
|
downloadUrl=$(curl -Ls -o /dev/null -w %{url_effective} $MODPACK)
|
||||||
|
if ! [[ $downloadUrl == *.zip ]]; then
|
||||||
|
log "ERROR Invalid URL given for MODPACK: $downloadUrl resolved from $MODPACK"
|
||||||
|
log " Must be HTTP or HTTPS and a ZIP file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "Downloading mod/plugin pack via HTTP"
|
log "Downloading mod/plugin pack via HTTP"
|
||||||
log " from $EFFECTIVE_MODPACK_URL ..."
|
log " from $downloadUrl ..."
|
||||||
if ! curl -sSL -o /tmp/modpack.zip "$EFFECTIVE_MODPACK_URL"; then
|
if ! curl -sSL -o /tmp/modpack.zip "$downloadUrl"; then
|
||||||
log "ERROR: failed to download from $EFFECTIVE_MODPACK_URL"
|
log "ERROR: failed to download from $downloadUrl"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$TYPE" = "SPIGOT" ]; then
|
if [ "$TYPE" = "SPIGOT" ]; then
|
||||||
mkdir -p /data/plugins
|
mkdir -p /data/plugins
|
||||||
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
if ! unzip -o -d /data/plugins /tmp/modpack.zip; then
|
||||||
log "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
|
log "ERROR: failed to unzip the modpack from $downloadUrl"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
mkdir -p /data/mods
|
mkdir -p /data/mods
|
||||||
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
if ! unzip -o -d /data/mods /tmp/modpack.zip; then
|
||||||
log "ERROR: failed to unzip the modpack from $EFFECTIVE_MODPACK_URL"
|
log "ERROR: failed to unzip the modpack from $downloadUrl"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
rm -f /tmp/modpack.zip
|
rm -f /tmp/modpack.zip
|
||||||
;;
|
|
||||||
*)
|
else
|
||||||
log "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
|
log "ERROR Invalid URL given for MODPACK: $MODPACK"
|
||||||
;;
|
exit 1
|
||||||
esac
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If supplied with a URL for a plugin download it.
|
# If supplied with a URL for a plugin download it.
|
||||||
if [[ "$MODS" ]]; then
|
if [[ "$MODS" ]]; then
|
||||||
for i in ${MODS//,/ }
|
for i in ${MODS//,/ }
|
||||||
do
|
do
|
||||||
EFFECTIVE_MOD_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i)
|
if isURL $i; then
|
||||||
case "X$EFFECTIVE_MOD_URL" in
|
if [[ $i == *.jar ]]; then
|
||||||
X[Hh][Tt][Tt][Pp]*.jar)
|
EFFECTIVE_MOD_URL=$i
|
||||||
|
else
|
||||||
|
EFFECTIVE_MOD_URL=$(curl -Ls -o /dev/null -w %{url_effective} $i)
|
||||||
|
if ! [[ $EFFECTIVE_MOD_URL == *.jar ]]; then
|
||||||
|
log "ERROR Invalid URL given in MODS: $EFFECTIVE_MOD_URL resolved from $i"
|
||||||
|
log " Must be HTTP or HTTPS and a JAR file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "Downloading mod/plugin via HTTP"
|
log "Downloading mod/plugin via HTTP"
|
||||||
log " from $EFFECTIVE_MOD_URL ..."
|
log " from $EFFECTIVE_MOD_URL ..."
|
||||||
if ! curl -sSL -o /tmp/${EFFECTIVE_MOD_URL##*/} $EFFECTIVE_MOD_URL; then
|
if ! curl -sSL -o /tmp/${EFFECTIVE_MOD_URL##*/} $EFFECTIVE_MOD_URL; then
|
||||||
@@ -69,12 +87,12 @@ do
|
|||||||
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/mods/${EFFECTIVE_MOD_URL##*/}
|
mv /tmp/${EFFECTIVE_MOD_URL##*/} /data/mods/${EFFECTIVE_MOD_URL##*/}
|
||||||
fi
|
fi
|
||||||
rm -f /tmp/${EFFECTIVE_MOD_URL##*/}
|
rm -f /tmp/${EFFECTIVE_MOD_URL##*/}
|
||||||
;;
|
|
||||||
*)
|
else
|
||||||
log "Invalid URL given for modpack: Must be HTTP or HTTPS and a JAR file"
|
log "ERROR Invalid URL given in MODS: $i"
|
||||||
;;
|
exit 1
|
||||||
esac
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$MANIFEST" ]]; then
|
if [[ "$MANIFEST" ]]; then
|
||||||
|
|||||||
@@ -113,3 +113,12 @@ requireVar() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function writeEula() {
|
||||||
|
if ! echo "# Generated via Docker on $(date)
|
||||||
|
eula=${EULA,,}
|
||||||
|
" > /data/eula.txt; then
|
||||||
|
log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user