mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-11-10 14:24:28 +00:00
Auto-merging via docker-versions-create
# Conflicts: # start-deployFTB # start-minecraftFinalSetup
This commit is contained in:
commit
eba1ef6ab9
7 changed files with 123 additions and 43 deletions
|
@ -329,7 +329,7 @@ Specific files can be excluded by listing their name (without path) in the varia
|
|||
Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path
|
||||
excludes are recursive. Here is an example:
|
||||
```
|
||||
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata/ /data/plugins/MyPlugin/"
|
||||
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata /data/plugins/MyPlugin"
|
||||
```
|
||||
|
||||
Here is a full example where we want to replace values inside a `database.yml`.
|
||||
|
@ -513,6 +513,10 @@ The following example uses `/modpacks` as the container path as the pre-download
|
|||
-e CF_SERVER_MOD=/modpacks/SkyFactory_4_Server_4.1.0.zip \
|
||||
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
|
||||
|
||||
#### Buggy start scripts
|
||||
|
||||
Some modpacks have buggy or overly complex start scripts. You can avoid using the bundled start script and use this image's standard server-starting logic by adding `-e USE_MODPACK_START_SCRIPT=false`.
|
||||
|
||||
### Fixing "unable to launch forgemodloader"
|
||||
|
||||
If your server's modpack fails to load with an error [like this](https://support.feed-the-beast.com/t/cant-start-crashlanding-server-unable-to-launch-forgemodloader/6028/2):
|
||||
|
|
|
@ -64,11 +64,8 @@ case "X$VERSION" in
|
|||
XSNAPSHOT|Xsnapshot)
|
||||
VANILLA_VERSION=$(curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot')
|
||||
;;
|
||||
X[1-9]*)
|
||||
VANILLA_VERSION=$VERSION
|
||||
;;
|
||||
*)
|
||||
VANILLA_VERSION=$(curl -fsSL $VERSIONS_JSON | jq -r '.latest.release')
|
||||
VANILLA_VERSION=$VERSION
|
||||
;;
|
||||
esac
|
||||
export VANILLA_VERSION
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
. /start-utils
|
||||
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
|
||||
|
@ -8,15 +10,69 @@ export TYPE=CURSEFORGE
|
|||
|
||||
FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD}
|
||||
|
||||
log "Looking for CurseForge server modpack."
|
||||
if [[ -z $FTB_SERVER_MOD ]]; then
|
||||
log "Environment variable FTB_SERVER_MOD not set."
|
||||
log "Set FTB_SERVER_MOD to the file name of the FTB server modpack."
|
||||
log "(And place the modpack in the /data directory.)"
|
||||
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 ServerStartLinux.sh -o -name LaunchServer.sh"
|
||||
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)
|
||||
|
@ -130,4 +186,4 @@ elif [ -e "${FTB_DIR}/Install.sh" ]; then
|
|||
fi
|
||||
|
||||
# Continue to Final Setup
|
||||
exec /start-finalSetup01World $@
|
||||
exec ${SCRIPTS:-/}start-finalSetupWorld $@
|
||||
|
|
|
@ -26,6 +26,9 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
|
|||
if [ $result != 0 ]; then
|
||||
log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
|
||||
exit 1
|
||||
elif [ $serverDownloadUrl = null ]; then
|
||||
log "ERROR version $VANILLA_VERSION does not provide a server download"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
debug "Downloading server from $serverDownloadUrl"
|
||||
|
|
|
@ -6,20 +6,21 @@
|
|||
|
||||
if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
||||
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
|
||||
findExcludes=
|
||||
|
||||
# File excludes
|
||||
fileExcludes=
|
||||
for f in ${REPLACE_ENV_VARIABLES_EXCLUDES}; do
|
||||
findExcludes="${findExcludes} -not -name $f"
|
||||
fileExcludes="${fileExcludes} -not -name $f"
|
||||
done
|
||||
|
||||
# Directory excludes (recursive)
|
||||
dirExcludes=$(join_by " -o -path " ${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS})
|
||||
if [[ $dirExcludes ]]; then
|
||||
findExcludes+=" -type d ( -path ${dirExcludes} ) -prune"
|
||||
dirExcludes=" -type d ( -path ${dirExcludes} ) -prune -o"
|
||||
fi
|
||||
|
||||
isDebugging && echo "Using find exclusions: $findExcludes"
|
||||
isDebugging && echo "Using find file exclusions: $fileExcludes"
|
||||
isDebugging && echo "Using find directory exclusions: $dirExcludes"
|
||||
|
||||
while IFS='=' read -r name value ; do
|
||||
# check if name of env variable matches the prefix
|
||||
|
@ -34,10 +35,12 @@ if isTrue "${REPLACE_ENV_VARIABLES}"; then
|
|||
fi
|
||||
|
||||
log "Replacing $name with $value ..."
|
||||
find /data/ -type f \
|
||||
find /data/ \
|
||||
$dirExcludes \
|
||||
-type f \
|
||||
\( -name "*.yml" -or -name "*.yaml" -or -name "*.txt" -or -name "*.cfg" \
|
||||
-or -name "*.conf" -or -name "*.properties" \) \
|
||||
$findExcludes \
|
||||
$fileExcludes \
|
||||
-exec sed -i 's#${'"$name"'}#'"$value"'#g' {} \;
|
||||
fi
|
||||
done < <(env)
|
||||
|
|
|
@ -158,46 +158,60 @@ if isTrue "${DEBUG_MEMORY}"; then
|
|||
free -m
|
||||
fi
|
||||
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
|
||||
function copyFilesForCurseForge() {
|
||||
# copy player modification files unconditionally since their
|
||||
# processing into json is additive anyway
|
||||
[ -f /data/ops.txt ] && cp -f /data/ops.txt ${FTB_DIR}/
|
||||
[ -f /data/white-list.txt ] && cp -f /data/white-list.txt ${FTB_DIR}/
|
||||
|
||||
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
|
||||
cp -f /data/server-icon.png ${FTB_DIR}/
|
||||
fi
|
||||
|
||||
cp -f /data/eula.txt "${FTB_DIR}/"
|
||||
}
|
||||
|
||||
mcServerRunnerArgs="--stop-duration 60s"
|
||||
if [[ ${TYPE} == "CURSE_INSTANCE" ]]; then
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${mcServerRunnerArgs} \
|
||||
--cf-instance-file "${CURSE_INSTANCE_JSON}" \
|
||||
java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar _SERVERJAR_ "$@" $EXTRA_ARGS
|
||||
elif [[ ${TYPE} == "CURSEFORGE" && "${SERVER}" ]]; then
|
||||
copyFilesForCurseForge
|
||||
|
||||
cd "${FTB_DIR}"
|
||||
log "Starting CurseForge server in ${FTB_DIR}..."
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $(basename "${SERVER}") "$@" $EXTRA_ARGS
|
||||
elif [[ ${TYPE} == "CURSEFORGE" ]]; then
|
||||
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
||||
mcServerRunnerArgs="${mcServerRunnerArgs} --shell bash"
|
||||
|
||||
# copy player modification files unconditionally since their
|
||||
# processing into json is additive anyway
|
||||
[ -f /data/ops.txt ] && cp -f /data/ops.txt ${FTB_DIR}/
|
||||
[ -f /data/white-list.txt ] && cp -f /data/white-list.txt ${FTB_DIR}/
|
||||
copyFilesForCurseForge
|
||||
|
||||
if [ ! -e "${FTB_DIR}/server-icon.png" -a -e /data/server-icon.png ]; then
|
||||
cp -f /data/server-icon.png ${FTB_DIR}/
|
||||
fi
|
||||
|
||||
cp -f /data/eula.txt "${FTB_DIR}/"
|
||||
|
||||
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
||||
cat > "${FTB_DIR}/settings-local.sh" <<EOF
|
||||
export MIN_RAM="${INIT_MEMORY}"
|
||||
export MAX_RAM="${MAX_MEMORY}"
|
||||
export JAVA_PARAMETERS="${JVM_XX_OPTS} -Xms${INIT_MEMORY} ${JVM_OPTS} $expandedDOpts"
|
||||
EOF
|
||||
|
||||
# patch CurseForge cfg file, if present
|
||||
if [ -f "${FTB_DIR}/settings.cfg" ]; then
|
||||
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
||||
fi
|
||||
# patch CurseForge cfg file, if present
|
||||
if [ -f "${FTB_DIR}/settings.cfg" ]; then
|
||||
sed -i "s/MAX_RAM=[^;]*/MAX_RAM=${MAX_MEMORY}/" "${FTB_DIR}/settings.cfg"
|
||||
fi
|
||||
|
||||
cd "${FTB_DIR}"
|
||||
log "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${mcServerRunnerArgs} "${FTB_SERVER_START}"
|
||||
cd "${FTB_DIR}"
|
||||
log "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
exec mc-server-runner ${mcServerRunnerArgs} "${FTB_SERVER_START}"
|
||||
else
|
||||
# If we have a bootstrap.txt file... feed that in to the server stdin
|
||||
if [ -f /data/bootstrap.txt ]; then
|
||||
|
@ -205,7 +219,6 @@ else
|
|||
fi
|
||||
|
||||
log "Starting the Minecraft server..."
|
||||
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
||||
if isTrue ${DEBUG_EXEC}; then
|
||||
set -x
|
||||
fi
|
||||
|
|
|
@ -108,4 +108,8 @@ requireVar() {
|
|||
log "ERROR: $1 is required to be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${!1}" ]; then
|
||||
log "ERROR: $1 is required to be set"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue