Compare commits

...

9 Commits

Author SHA1 Message Date
Chip Wolf ‮
a9140fb84a chore(docs): note add mod var for auto_curseforge use (#3111) 2024-10-16 12:07:15 -05:00
Geoff Bourne
07708209a6 cf: gracefully handle corrupted API cache index (#3110) 2024-10-15 18:39:43 -05:00
Geoff Bourne
fd20fc9654 cf: default API cache TTL to 2 days and allow config (#3107) 2024-10-15 07:54:30 -05:00
ギリ猫
4085d28773 Fix mc-send-to-console running with uid=0(root) (#3106) 2024-10-15 07:08:17 -05:00
dependabot[bot]
7dbeac99d3 build(deps): bump actions/checkout from 4.2.0 to 4.2.1 in the updates group (#3105)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-14 21:50:48 -05:00
dependabot[bot]
e4773e47cb build(deps): bump the patches group in /docs with 2 updates (#3104) 2024-10-14 15:42:15 -05:00
Tristan
da4f7d0dd8 refactoring a little bit some test script files (#3100)
Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>
2024-10-13 18:04:11 -05:00
Geoff Bourne
afbdfea0bb Add SKIP_CHOWN_DATA to skip the "Changing ownership of /data" (#3103) 2024-10-13 15:05:49 -05:00
Geoff Bourne
f5da624789 curseforge: cache get mod info and file API calls to disk (#3102) 2024-10-13 14:15:09 -05:00
12 changed files with 181 additions and 214 deletions

View File

@@ -93,7 +93,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.2.0
uses: actions/checkout@v4.2.1
with:
# for build-files step
fetch-depth: 0

View File

@@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.2.0
uses: actions/checkout@v4.2.1
with:
# for build-files step
fetch-depth: 0

View File

@@ -50,7 +50,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=${MC_SERVER_RUNNER_VERSION} --var app=mc-server-runner --file {{.app}} \
--from ${GITHUB_BASEURL}/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.39.13
ARG MC_HELPER_VERSION=1.40.2
ARG MC_HELPER_BASE_URL=${GITHUB_BASEURL}/itzg/mc-image-helper/releases/download/${MC_HELPER_VERSION}
# used for cache busting local copy of mc-image-helper
ARG MC_HELPER_REV=1
@@ -77,4 +77,4 @@ RUN curl -fsSL -o /image/Log4jPatcher.jar https://github.com/CreeperHost/Log4jPa
RUN dos2unix /start* /auto/*
ENTRYPOINT [ "/start" ]
HEALTHCHECK --start-period=30s --retries=24 --interval=60s CMD mc-health
HEALTHCHECK --start-period=2m --retries=2 --interval=30s CMD mc-health

View File

@@ -17,7 +17,7 @@ if [ ! -p "${CONSOLE_IN_NAMED_PIPE}" ]; then
exit 1
fi
if [ "$(id -u)" = 0 ]; then
if [ "$(id -u)" = 0 -a $UID != 0 ]; then
if [[ $(getDistro) == alpine ]]; then
exec su-exec minecraft bash -c "echo '$*' > '${CONSOLE_IN_NAMED_PIPE:-/tmp/minecraft-console-in}'"
else

View File

@@ -3,3 +3,5 @@ To troubleshoot the container initialization, such as when server files are pre-
To troubleshoot just the command-line used to start the Minecraft server, set the environment variable `DEBUG_EXEC` to `true`.
To troubleshoot any issues with memory allocation reported by the JVM, set the environment variable `DEBUG_MEMORY` to `true`.
If you are experiencing any issues with the "Changing ownership of /data" step, that can be disabled by setting `SKIP_CHOWN_DATA` to `true`.

View File

@@ -9,7 +9,7 @@
|
+-- project slug
```
Also, a specific version (or release type) can be declared adding a colon and then the version id, version name, or release type after the project slug. The version ID can be found in the 'Metadata' section. Valid release types are `release`, `beta`, `alpha`.
Also, a specific version (or release type) can be declared adding a colon and then the version id, version number/name, or release type after the project slug. The version ID or number can be found in the 'Metadata' section. Valid release types are `release`, `beta`, `alpha`.
To select a datapack from a Modrinth project, prefix the entry with "datapack:". When running a vanilla server, this is optional since only datapacks will be available for vanilla servers to select.

View File

@@ -1,6 +1,6 @@
mkdocs-material == 9.5.39
mkdocs-material == 9.5.40
mkdocs-autorefs == 1.2.0
mkdocstrings == 0.26.1
mkdocstrings == 0.26.2
mkdocs-literate-nav == 0.6.1
mdx-gh-links == 0.4
mkdocs-click == 0.8.1

View File

@@ -164,6 +164,11 @@ Quite often there are mods that need to be excluded, such as ones that did not p
Mods can be excluded by passing a comma or space delimited list of **project** slugs or IDs via `CF_EXCLUDE_MODS`. Similarly, there are some mods that are incorrectly tagged as client only. For those, pass the **project** slugs or IDs via `CF_FORCE_INCLUDE_MODS`. These lists will be combined with the content of the exclude/include file, if given.
!!! note
`CF_FORCE_INCLUDE_MODS` will not download additional mods.
For additional mods, refer to [the `CURSEFORGE_FILES` variable](../../mods-and-plugins/curseforge-files.md).
A mod's project ID can be obtained from the right hand side of the project page:
![cf-project-id](../../img/cf-project-id.png)

View File

@@ -6,6 +6,7 @@
# The Dockerfile ENVs take precedence here, but defaulting for testing consistency
: "${UID:=1000}"
: "${GID:=1000}"
: "${SKIP_CHOWN_DATA:=false}"
umask "${UMASK:=0002}"
@@ -38,7 +39,7 @@ if ! isTrue "${SKIP_SUDO:-false}" && [ "$(id -u)" = 0 ]; then
fi
fi
if [[ $(stat -c "%u" /data) != "$UID" ]]; then
if isTrue "${SKIP_CHOWN_DATA}" || [[ $(stat -c "%u" /data) != "$UID" ]]; then
log "Changing ownership of /data to $UID ..."
chown -R ${runAsUser}:${runAsGroup} /data
fi

View File

@@ -20,6 +20,7 @@ set -eu
: "${CF_OVERRIDES_EXCLUSIONS:=}" # --overrides-exclusions
: "${CF_DOWNLOADS_REPO=$([ -d /downloads ] && echo '/downloads' || echo '')}"
: "${CF_MODPACK_MANIFEST:=}"
: "${CF_API_CACHE_DEFAULT_TTL:=}" # as ISO-8601 duration, such as P2D or PT12H
resultsFile=/data/.install-curseforge.env
@@ -29,49 +30,31 @@ ensureRemoveAllModsOff "MOD_PLATFORM=AUTO_CURSEFORGE"
args=(
--results-file="$resultsFile"
)
if [[ $CF_PAGE_URL ]]; then
args+=(--modpack-page-url="$CF_PAGE_URL")
fi
if [[ $CF_FILE_ID ]]; then
args+=(--file-id="$CF_FILE_ID")
fi
if [[ $CF_SLUG ]]; then
args+=(--slug="$CF_SLUG")
fi
if [[ $CF_MODPACK_MANIFEST ]]; then
args+=(--modpack-manifest="$CF_MODPACK_MANIFEST")
fi
if [[ $CF_FILENAME_MATCHER ]]; then
args+=(--filename-matcher="$CF_FILENAME_MATCHER")
fi
if [[ ${CF_SET_LEVEL_FROM} ]]; then
args+=(--set-level-from="$CF_SET_LEVEL_FROM")
fi
if [[ ${CF_OVERRIDES_EXCLUSIONS} ]]; then
args+=(--overrides-exclusions="$CF_OVERRIDES_EXCLUSIONS")
fi
if [[ ${CF_IGNORE_MISSING_FILES} ]]; then
args+=(--ignore-missing-files="$CF_IGNORE_MISSING_FILES")
fi
args+=(
--force-synchronize="$CF_FORCE_SYNCHRONIZE"
--force-reinstall-modloader="$CF_FORCE_REINSTALL_MODLOADER"
--overrides-skip-existing="$CF_OVERRIDES_SKIP_EXISTING"
)
setArg() {
arg="${1?}"
var="${2?}"
if [[ $CF_EXCLUDE_MODS ]]; then
args+=( --exclude-mods="$CF_EXCLUDE_MODS" )
fi
if [[ $CF_FORCE_INCLUDE_MODS ]]; then
args+=( --force-include-mods="$CF_FORCE_INCLUDE_MODS" )
fi
if [[ $CF_EXCLUDE_INCLUDE_FILE ]]; then
args+=( --exclude-include-file="$CF_EXCLUDE_INCLUDE_FILE" )
fi
if [[ $CF_DOWNLOADS_REPO ]]; then
args+=( --downloads-repo="$CF_DOWNLOADS_REPO" )
fi
if [[ ${!var} ]]; then
args+=("${arg}=${!var}")
fi
}
setArg --modpack-page-url CF_PAGE_URL
setArg --file-id CF_FILE_ID
setArg --slug CF_SLUG
setArg --modpack-manifest CF_MODPACK_MANIFEST
setArg --filename-matcher CF_FILENAME_MATCHER
setArg --set-level-from CF_SET_LEVEL_FROM
setArg --overrides-exclusions CF_OVERRIDES_EXCLUSIONS
setArg --ignore-missing-files CF_IGNORE_MISSING_FILES
setArg --api-cache-default-ttl CF_API_CACHE_DEFAULT_TTL
setArg --exclude-mods CF_EXCLUDE_MODS
setArg --force-include-mods CF_FORCE_INCLUDE_MODS
setArg --exclude-include-file CF_EXCLUDE_INCLUDE_FILE
setArg --downloads-repo CF_DOWNLOADS_REPO
if ! mc-image-helper install-curseforge "${args[@]}"; then
log "ERROR failed to auto-install CurseForge modpack"

View File

@@ -34,18 +34,14 @@ function get_major_version() {
function isURL() {
local value=$1
if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" || ${value:0:6} == "ftp://" ]]; then
return 0
else
return 1
fi
[[ $value =~ ^(https?|ftp):// ]]
}
function isValidFileURL() {
suffix=${1:?Missing required suffix arg}
url=${2:?Missing required url arg}
[[ "$url" == http*://*.${suffix} || "$url" == http*://*.${suffix}\?* ]]
[[ "$url" =~ ^http.*://.*\.${suffix}(\?.*)?$ ]]
}
function resolveEffectiveUrl() {
@@ -85,11 +81,7 @@ function isFalse() {
}
function isDebugging() {
if isTrue "${DEBUG:-false}"; then
return 0
else
return 1
fi
isTrue "${DEBUG:-false}"
}
function handleDebugMode() {
@@ -113,11 +105,9 @@ function log() {
# The return status when listing options is zero if all optnames are enabled, non- zero otherwise.
oldState=$(shopt -po xtrace || true)
shopt -u -o xtrace
ts=
if isDebugging || isTrue "${LOG_TIMESTAMP:-false}"; then
ts=" $(date --rfc-3339=seconds)"
else
ts=
fi
echo "[init]${ts} $*"
eval "$oldState"
@@ -162,106 +152,95 @@ function normalizeMemSize() {
}
function compare_version() {
local left_version=$1
local comparison=$2
local right_version=$3
local left_version=$1
local comparison=$2
local right_version=$3
if [[ -z "$left_version" ]]; then
echo "Left version is required"
return 1
fi
if [[ -z "$left_version" ]]; then
echo "Left version is required"
return 1
fi
if [[ -z "$right_version" ]]; then
echo "Right version is required"
return 1
fi
if [[ -z "$right_version" ]]; then
echo "Right version is required"
return 1
fi
# Handle version channels ('a', 'b', or numeric)
if [[ $left_version == a* || $left_version == b* ]]; then
left_version=${left_version:1}
fi
if [[ $right_version == a* || $right_version == b* ]]; then
right_version=${right_version:1}
fi
# Handle version channels ('a', 'b', or numeric)
if [[ $left_version == a* || $left_version == b* ]]; then
left_version=${left_version:1}
fi
if [[ $right_version == a* || $right_version == b* ]]; then
right_version=${right_version:1}
fi
local left_version_channel=${left_version:0:1}
if [[ $left_version_channel =~ [0-9] ]]; then
left_version_channel='r'
fi
local left_version_channel=${left_version:0:1}
if [[ $left_version_channel =~ [0-9] ]]; then
left_version_channel='r'
fi
local right_version_channel=${right_version:0:1}
if [[ $right_version_channel =~ [0-9] ]]; then
right_version_channel='r'
fi
local right_version_channel=${right_version:0:1}
if [[ $right_version_channel =~ [0-9] ]]; then
right_version_channel='r'
fi
if [[ $comparison == "lt" && $left_version_channel < $right_version_channel ]]; then
return 0
elif [[ $comparison == "lt" && $left_version_channel > $right_version_channel ]]; then
return 1
elif [[ $comparison == "gt" && $left_version_channel > $right_version_channel ]]; then
return 0
elif [[ $comparison == "gt" && $left_version_channel < $right_version_channel ]]; then
return 1
elif [[ $comparison == "le" && $left_version_channel < $right_version_channel ]]; then
return 0
elif [[ $comparison == "le" && $left_version_channel == $right_version_channel ]]; then
return 0
elif [[ $comparison == "ge" && $left_version_channel > $right_version_channel ]]; then
return 0
elif [[ $comparison == "ge" && $left_version_channel == $right_version_channel ]]; then
return 0
elif [[ $comparison == "eq" && $left_version_channel == $right_version_channel ]]; then
return 0
fi
if [[ $comparison == "lt" && $left_version_channel < $right_version_channel ]]; then
return 0
elif [[ $comparison == "lt" && $left_version_channel > $right_version_channel ]]; then
return 1
elif [[ $comparison == "gt" && $left_version_channel > $right_version_channel ]]; then
return 0
elif [[ $comparison == "gt" && $left_version_channel < $right_version_channel ]]; then
return 1
elif [[ $comparison == "le" && $left_version_channel < $right_version_channel ]]; then
return 0
elif [[ $comparison == "le" && $left_version_channel == $right_version_channel ]]; then
return 0
elif [[ $comparison == "ge" && $left_version_channel > $right_version_channel ]]; then
return 0
elif [[ $comparison == "ge" && $left_version_channel == $right_version_channel ]]; then
return 0
elif [[ $comparison == "eq" && $left_version_channel == $right_version_channel ]]; then
return 0
fi
# Compare the versions using sort -V
local result
# Compare the versions using sort -V
local result=1
case $comparison in
"lt")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | head -n1) == "$left_version" && "$left_version" != "$right_version" ]]; then
result=0
else
result=1
fi
;;
"le")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | head -n1) == "$left_version" ]]; then
result=0
else
result=1
fi
;;
"eq")
if [[ "$left_version" == "$right_version" ]]; then
result=0
else
result=1
fi
;;
"ge")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | tail -n1) == "$left_version" ]]; then
result=0
else
result=1
fi
;;
"gt")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | tail -n1) == "$left_version" && "$left_version" != "$right_version" ]]; then
result=0
else
result=1
fi
;;
*)
echo "Unsupported comparison operator: $comparison"
return 1
;;
esac
case $comparison in
"lt")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | head -n1) == "$left_version" && "$left_version" != "$right_version" ]]; then
result=0
fi
;;
"le")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | head -n1) == "$left_version" ]]; then
result=0
fi
;;
"eq")
if [[ "$left_version" == "$right_version" ]]; then
result=0
fi
;;
"ge")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | tail -n1) == "$left_version" ]]; then
result=0
fi
;;
"gt")
if [[ $(echo -e "$left_version\n$right_version" | sort -V | tail -n1) == "$left_version" && "$left_version" != "$right_version" ]]; then
result=0
fi
;;
*)
echo "Unsupported comparison operator: $comparison"
return 1
;;
esac
return $result
return $result
}
function versionLessThan() {
@@ -270,14 +249,10 @@ function versionLessThan() {
oldState=$(shopt -po xtrace || true)
shopt -u -o xtrace
# Use if-else since strict mode might be enabled
if compare_version "${VERSION}" "lt" "${1?}"; then
eval "$oldState"
return 0
else
eval "$oldState"
return 1
fi
eval "$oldState"
# Verify strict mode because it might be enabled
compare_version "${VERSION}" "lt" "${1?}"
}
requireVar() {
@@ -302,7 +277,7 @@ requireEnum() {
done
log "ERROR: $var must be set to one of $*"
# exit 1
# exit 1
}
function writeEula() {
@@ -369,19 +344,19 @@ function extract() {
type=$(file -b --mime-type "${src}")
case "${type}" in
application/zip)
unzip -o -q -d "${destDir}" "${src}"
;;
application/x-tar|application/gzip|application/x-gzip|application/x-bzip2)
tar -C "${destDir}" -xf "${src}"
;;
application/zstd|application/x-zstd)
tar -C "${destDir}" --use-compress-program=unzstd -xf "${src}"
;;
*)
log "ERROR: unsupported archive type: $type"
return 1
;;
application/zip)
unzip -o -q -d "${destDir}" "${src}"
;;
application/x-tar | application/gzip | application/x-gzip | application/x-bzip2)
tar -C "${destDir}" -xf "${src}"
;;
application/zstd | application/x-zstd)
tar -C "${destDir}" --use-compress-program=unzstd -xf "${src}"
;;
*)
log "ERROR: unsupported archive type: $type"
return 1
;;
esac
}
@@ -395,31 +370,33 @@ function checkSum() {
# Get distro
distro=$(getDistro)
if [ "${distro}" == "debian" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
return 0
elif [ "${distro}" == "ubuntu" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
return 0
elif [ "${distro}" == "alpine" ] && sha1sum -c "${sum_file}" -s 2> /dev/null; then
return 0
elif [ "${distro}" == "ol" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
return 0
else
case "${distro}" in
debian | ubuntu | ol)
sha1sum -c "${sum_file}" --status 2>/dev/null && return 0
;;
alpine)
sha1sum -c "${sum_file}" -s 2>/dev/null && return 0
;;
*)
return 1
fi
;;
esac
}
function usesMods() {
case "$FAMILY" in
FORGE|FABRIC|HYBRID|SPONGE)
return 0
FORGE | FABRIC | HYBRID | SPONGE)
return 0
;;
esac
return 1
}
function usesPlugins() {
case "$FAMILY" in
SPIGOT|HYBRID)
return 0
SPIGOT | HYBRID)
return 0
;;
esac
return 1
}
@@ -435,15 +412,15 @@ function resolveVersion() {
function resolveFamily() {
case "$TYPE" in
PAPER|SPIGOT|BUKKIT|CANYON|PUFFERFISH|PURPUR)
FAMILY=SPIGOT
;;
FORGE)
FAMILY=FORGE
;;
FABRIC|QUILT)
FAMILY=FABRIC
;;
PAPER | SPIGOT | BUKKIT | CANYON | PUFFERFISH | PURPUR)
FAMILY=SPIGOT
;;
FORGE)
FAMILY=FORGE
;;
FABRIC | QUILT)
FAMILY=FABRIC
;;
esac
export FAMILY
}

View File

@@ -44,22 +44,20 @@ setupOnlyMinecraftTest(){
# false positive since it's used in delta calculations below
# shellcheck disable=SC2034
start=$(date +%s)
status=PASSED
verify=
if ! logs=$(docker compose run --rm -e SETUP_ONLY=true -e DEBUG="${DEBUG:-false}" mc 2>&1); then
outputContainerLog "$logs"
result=1
elif [ -f verify.sh ]; then
verify=" verify"
if ! docker run --rm --entrypoint bash -v "${PWD}/data":/data -v "${PWD}/verify.sh":/verify "${IMAGE_TO_TEST}" -e /verify; then
endTime=$(date +%s)
echo "${folder} FAILED verify in $(delta start)"
status=FAILED
outputContainerLog "$logs"
result=1
else
endTime=$(date +%s)
echo "${folder} PASSED verify in $(delta start)"
fi
else
echo "${folder} PASSED in $(delta start)"
fi
echo "${folder} ${status}${verify} in $(delta start)"
docker compose down -v --remove-orphans >& /dev/null
cd ..
@@ -67,16 +65,17 @@ setupOnlyMinecraftTest(){
return $result
}
# go through each folder in setuponly and test setups
if (( $# > 0 )); then
for folder in "$@"; do
echo "Starting Tests in ${folder}"
setupOnlyMinecraftTest "$folder"
done
else
foldersList=("$@")
image=""
# Go through each folder in setuponly and test setups
if (( $# == 0 )); then
readarray -t folders < <(find . -maxdepth 2 -mindepth 2 -name docker-compose.yml -printf '%h\n')
for folder in "${folders[@]}"; do
echo "Starting Tests in ${folder} using $IMAGE_TO_TEST"
setupOnlyMinecraftTest "$folder"
done
foldersList=("${folders[@]}")
image=" using $IMAGE_TO_TEST"
fi
for folder in "${foldersList[@]}"; do
echo "Starting Tests in ${folder}${image}"
setupOnlyMinecraftTest "$folder"
done