Improved and documented GENERIC_PACK feature

#1077
This commit is contained in:
Geoff Bourne 2021-10-20 15:36:02 -05:00
parent 97a6a4ba85
commit 5777a248d4
7 changed files with 66 additions and 28 deletions

View file

@ -714,6 +714,10 @@ You may also download or copy over individual mods using the `MODS` environment
docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ...
### Generic pack file
To install all of the server content (jars, mods, plugins, configs, etc) from a zip file, such as a CurseForge modpack that is missing a server start script, then set `GENERIC_PACK` to the container path of the zip file. That, combined with `TYPE`, allows for custom content along with container managed server download and install.
### Mod/Plugin URL Listing File
As an alternative to `MODS`, the variable `MODS_FILE` can be set with the path to a text file listing a mod/plugin URL on each line. For example, the following

View file

@ -2,12 +2,12 @@ version: '3.8'
services:
mc:
image: itzg/minecraft-server:java8
image: itzg/minecraft-server:${IMAGE_TAG:-java8}
volumes:
- ./modpacks:/modpacks:ro
environment:
EULA: "true"
TYPE: CURSEFORGE
CF_SERVER_MOD: /modpacks/SkyFactory_4_Server_4.1.0.zip
CF_SERVER_MOD: /modpacks/${MODPACK:-SkyFactory_4_Server_4.1.0.zip}
ports:
- 25565:25565
- "25565:25565"

View file

@ -0,0 +1,20 @@
version: '3.8'
services:
mc:
image: itzg/minecraft-server:${IMAGE_TAG:-latest}
volumes:
- data:/data
- ./modpacks:/modpacks:ro
environment:
EULA: "true"
TYPE: FORGE
DEBUG: "${DEBUG:-false}"
VERSION: ${VERSION:-1.17.1}
FORGEVERSION: ${FORGEVERSION:-37.0.90}
GENERIC_PACK: /modpacks/${MODPACK:-Server-Files-0.0.21.zip}
ports:
- "25565:25565"
volumes:
data: {}

View file

@ -124,10 +124,8 @@ case "${TYPE^^}" in
FTB|CURSEFORGE)
log "**********************************************************************"
log "WARNING: The image tag itzg/minecraft-server:java8 is recommended"
log " since some mods require Java 8"
log " Exception traces reporting ClassCastException: class jdk.internal.loader.ClassLoaders\$AppClassLoader"
log " can be fixed with java8"
log "NOTE: Some mods and modpacks may require Java 8."
log " If so, use itzg/minecraft-server:java8"
log "**********************************************************************"
exec ${SCRIPTS:-/}start-deployCF "$@"
;;

View file

@ -92,7 +92,7 @@ if ! isTrue ${USE_MODPACK_START_SCRIPT:-true}; then
echo "${FTB_SERVER_MOD}" > $installMarker
fi
export SERVER=$(find ${FTB_BASE_DIR} -type f \( -path "/libraries/*" -o -path "/mods/*" \) -prune -o -name "forge*.jar" -not -name "forge*installer.jar" -maxdepth 2 -print)
export SERVER=$(find "${FTB_BASE_DIR}" -maxdepth 2 -type f \( -path "/libraries/*" -o -path "/mods/*" \) -prune -o -name "forge*.jar" -not -name "forge*installer.jar" -print)
if [[ -z "${SERVER}" || ! -f "${SERVER}" ]]; then
log "ERROR unable to locate installed forge server jar"
isDebugging && find ${FTB_BASE_DIR} -name "forge*.jar"
@ -185,7 +185,7 @@ 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} -type f \( -path "/libraries/*" -o -path "/mods/*" \) -prune -o -name "forge*.jar" -not -name "forge*installer.jar" -maxdepth 2 -print)
forgeJar=$(find "${FTB_BASE_DIR}" -maxdepth 2 -type f \( -path "/libraries/*" -o -path "/mods/*" \) -prune -o -name "forge*.jar" -not -name "forge*installer.jar" -print)
if [[ "$forgeJar" ]]; then
export FTB_BASE_DIR=$(dirname "${forgeJar}")
log "No entry script found, so building one for ${forgeJar}"

View file

@ -53,13 +53,19 @@ install() {
# NOTE $shortForgeVersion will be empty if installer location was given to us
log "Finding installed server jar..."
unset -v latest
for file in *forge*.jar; do
if ! [[ $file =~ installer ]]; then
if [[ -z $latest ]] || [[ $file -nt $latest ]]; then
latest=$file
# 1.17+ ?
if [ -f /data/run.sh ]; then
latest=/data/run.sh
# else pre 1.17
else
for file in *forge*.jar; do
if ! [[ $file =~ installer ]]; then
if [[ -z $latest ]] || [[ $file -nt $latest ]]; then
latest=$file
fi
fi
fi
done
done
fi
if [[ -z $latest ]]; then
log "Unable to derive server jar for Forge"
exit 2
@ -67,6 +73,7 @@ install() {
export SERVER=$latest
log "Using server $SERVER"
debug "Writing install marker at $installMarker"
echo "$SERVER" > "$installMarker"
}
@ -134,10 +141,10 @@ if [ ! -e "$installMarker" ]; then
else
SERVER=$(cat "$installMarker")
export SERVER
if [ ! -e "$SERVER" ] && versionLessThan 1.17; then
if [ ! -e "$SERVER" ]; then
rm "$installMarker"
install
fi
fi
exec "${SCRIPTS:-$(dirname "$0")}/start-setupWorld" "$@"
exec "${SCRIPTS:-/}start-setupWorld" "$@"

View file

@ -169,29 +169,38 @@ if [[ "${GENERIC_PACK}" ]]; then
fi
sum_file=/data/.generic_pack.sum
if ! sha256sum -c ${sum_file} -s 2> /dev/null; then
isDebugging && [ -f "$sum_file}" ] && cat "$sum_file"
if ! sha256sum -c "${sum_file}" --status 2> /dev/null; then
base_dir=/tmp/generic_pack_base
mkdir -p ${base_dir}
isDebugging && ls -l "${GENERIC_PACK}"
unzip -q -d ${base_dir} "${GENERIC_PACK}"
# recalculate the actual base directory of content
base_dir=$(find "$base_dir" -type d \( -name mods -o -name plugins -o -name config \) -printf '%h' -quit)
if [[ ! $base_dir ]]; then
log "Unable to find content base of generic pack ${GENERIC_PACK}"
exit 1
fi
if [ -f /data/manifest.txt ]; then
log "Manifest exists from older generic pack, cleaning up ..."
while read f; do
while read -r f; do
rm -rf "/data/${f}"
done < /data/manifest.txt
find /data/* -type d -exec rmdir --ignore-fail-on-non-empty {} +
# prune empty dirs
find /data -mindepth 1 -depth -type d -empty -delete
rm -f /data/manifest.txt
fi
log "Writing generic pack manifest ... "
find ${base_dir} -type f -print0 | xargs -0 -I {} echo "{}" | sed "s#${base_dir}/##" > /data/manifest.txt
find "${base_dir}" -type f -printf "%P\n" > /data/manifest.txt
log "Applying generic pack ..."
IFS='
'
set -f
for d in $(find ${base_dir} -type d); do mkdir -p "$(sed "s#${base_dir}#/data#" <<< $d)"; done
for f in $(find ${base_dir} -type f); do cp -f "$f" "$(sed "s#${base_dir}#/data#" <<< $f)"; done
rm -rf ${base_dir}
sha256sum "${GENERIC_PACK}" > ${sum_file}
cp -R -f "${base_dir}"/* /data
rm -rf /tmp/generic_pack_base
sha256sum "${GENERIC_PACK}" > "${sum_file}"
isDebugging && cat "$sum_file"
fi
fi