Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ jobs:
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
VARIANT: ${{ matrix.variant }}
MODS_FORGEAPI_KEY: ${{ secrets.MODS_FORGEAPI_KEY }}
DEBUG: ${{ runner.debug }}
run: |
tests/test.sh
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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

ARG MC_HELPER_VERSION=1.22.4
ARG MC_HELPER_VERSION=1.22.6
ARG MC_HELPER_RELEASE=v${MC_HELPER_VERSION}
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/${MC_HELPER_RELEASE}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
Expand Down
3 changes: 2 additions & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/data/
/data/
modpacks/
21 changes: 21 additions & 0 deletions examples/docker-compose-mods-mount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
minecraft:
image: itzg/minecraft-server
volumes:
- data:/data
- ./mods:/mods
ports:
- "25565:25565"
environment:
EULA: "true"
TYPE: "FORGE"
VERSION: "1.19.2"
DEBUG: "true"
SETUP_ONLY: "true"
tty: True
stdin_open: True

volumes:
data: {}
21 changes: 21 additions & 0 deletions examples/valhelsia2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
mc:
image: itzg/minecraft-server:java8-multiarch
volumes:
- data:/data
- ./modpacks:/modpacks:ro
environment:
EULA: "true"
TYPE: FORGE
VERSION: "1.15.2"
GENERIC_PACK: /modpacks/Valhelsia_2-2.3.4-SERVER.zip
MEMORY: "2G"
ports:
- "25565:25565"
healthcheck:
test: NONE

volumes:
data: {}
4 changes: 2 additions & 2 deletions scripts/start-setupEnvVariables
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -e
if isTrue "${REPLACE_ENV_IN_PLACE}"; then
log "Replacing env variables in ${REPLACE_ENV_PATHS} that match the prefix $REPLACE_ENV_VARIABLE_PREFIX ..."

mc-image-helper --debug=${DEBUG} interpolate \
mc-image-helper interpolate \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
Expand All @@ -27,7 +27,7 @@ fi

if [[ ${PATCH_DEFINITIONS} ]]; then
log "Applying patch definitions from ${PATCH_DEFINITIONS}"
mc-image-helper --debug=${DEBUG} patch \
mc-image-helper patch \
--patch-env-prefix="${REPLACE_ENV_VARIABLE_PREFIX}" \
"${PATCH_DEFINITIONS}"
fi
Expand Down
56 changes: 26 additions & 30 deletions scripts/start-setupModpack
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,26 @@ if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then
rm -f "$sum_file"
fi

# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
# Ensure we have the latest packwiz bootstrap installer
latestPackwiz=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest")
if [[ -z "${latestPackwiz}" ]]; then
log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
else
isDebugging && log "Latest packwiz ${latestPackwiz}"
latestPackwizVer=$(echo "${latestPackwiz}" | jq --raw-output '.tag_name')
latestPackwizUrl=$(echo "${latestPackwiz}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url')
: "${PACKWIZ_BOOTSTRAP_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}"
if [[ ! -e $PACKWIZ_BOOTSTRAP_JAR ]]; then
log "Downloading Packwiz ${latestPackwizVer}"
if ! curl -H "Accept:application/octet-stream" -o "$PACKWIZ_BOOTSTRAP_JAR" -fsSL ${latestPackwizUrl}; then
log "ERROR: failed to download Packwiz bootstrap installer"
exit 1
fi
function handlePackwiz() {
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
if ! packwizInstaller=$(mc-image-helper maven-download \
--maven-repo=https://maven.packwiz.infra.link/repository/release/ \
--group=link.infra.packwiz --artifact=packwiz-installer --classifier=dist \
--skip-existing); then
log "ERROR: failed to get packwiz installer"
exit 1
fi

log "Running packwiz installer against URL: ${PACKWIZ_URL}"
if ! java -cp "${packwizInstaller}" link.infra.packwiz.installer.Main "${PACKWIZ_URL}"; then
log "ERROR failed to run packwiz installer"
exit 1
fi
fi
log "Running packwiz installer against URL: ${PACKWIZ_URL}"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -s server "${PACKWIZ_URL}"
#if bootstrap download fails, download installer manually - then run without updating
returnVal=$?
if [[ $returnVal ]]; then
latestPackwizInstaller=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer/releases/latest")
latestPackwizInstallerVer=$(echo "${latestPackwizInstaller}" | jq --raw-output '.tag_name')
latestPackwizInstallerUrl=$(echo "${latestPackwizInstaller}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer.jar")) | .url')
log "Packwiz couldn't update - Downloading Packwiz Installer ${latestPackwizInstallerVer}"
get_from_gh "${latestPackwizInstallerUrl}" -H "Accept:application/octet-stream" -o "packwiz-installer.jar"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
fi
fi
}

function handleModpackListOrFile() {
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
if [[ "$MODPACK" ]]; then
if isURL "${MODPACK}"; then
Expand Down Expand Up @@ -149,7 +136,9 @@ elif [[ "$MODS_FILE" ]]; then
exit 1
fi
fi
}

function handleCurseForgeManifest() {
if [[ "$MANIFEST" ]]; then
if [[ -e "$MANIFEST" ]]; then
EFFECTIVE_MANIFEST_FILE=$MANIFEST
Expand Down Expand Up @@ -192,6 +181,7 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
;;
esac
fi
}

function genericPacks() {
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
Expand Down Expand Up @@ -291,6 +281,12 @@ function modrinthProjects() {
fi
}

handlePackwiz

handleModpackListOrFile

handleCurseForgeManifest

genericPacks

modrinthProjects
Expand Down
6 changes: 3 additions & 3 deletions scripts/start-setupMounts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ -d /plugins ]; then
mkdir -p /data/plugins
log "Copying plugins over..."
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
Expand All @@ -46,7 +46,7 @@ fi
if [ -d /mods ]; then
log "Copying any mods over..."
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
Expand All @@ -59,7 +59,7 @@ fi
if [ -d /config ]; then
log "Copying any configs from /config to ${COPY_CONFIG_DEST}"
mc-image-helper \
--debug=${DEBUG} ${subcommand} $updateArg \
${subcommand} $updateArg \
--replace-env-file-suffixes="${REPLACE_ENV_SUFFIXES}" \
--replace-env-excludes="${REPLACE_ENV_VARIABLES_EXCLUDES}" \
--replace-env-exclude-paths="${REPLACE_ENV_VARIABLES_EXCLUDE_PATHS}" \
Expand Down
40 changes: 10 additions & 30 deletions scripts/start-utils
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,27 @@ function getFilenameFromUrl() {
}

function isTrue() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace

local value=${1,,}

result=

case ${value} in
true | on)
result=0
local arg="${1?}"
case ${arg,,} in
true | on | 1)
return 0
;;
*)
result=1
return 1
;;
esac

eval "$oldState"
return ${result}
}

function isFalse() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace

local value=${1,,}

result=

case ${value} in
false | off)
result=0
local arg="${1?}"
case ${arg,,} in
false | off | 0)
return 0
;;
*)
result=1
return 1
;;
esac

eval "$oldState"
return ${result}
}

function isDebugging() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world_nether/DIM-1/some_spigot_nether_file && \
mc-image-helper assert fileExists world_the_end/DIM1/some_spigot_end_file && \
! mc-image-helper assert fileExists world_nether/DIM-1/some_vanilla_nether_file && \
! mc-image-helper assert fileExists world_the_end/DIM1/some_vanilla_end_file
mc-image-helper assert fileExists \
world/level.dat \
world_nether/DIM-1/some_spigot_nether_file \
world_the_end/DIM1/some_spigot_end_file
mc-image-helper assert fileNotExists \
world_nether/DIM-1/some_vanilla_nether_file \
world_the_end/DIM1/some_vanilla_end_file
2 changes: 1 addition & 1 deletion tests/setuponlytests/packwiz/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ services:
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "true"
SETUP_ONLY: "true"
PACKWIZ_URL: http://web/pack.toml
TYPE: CUSTOM
CUSTOM_SERVER: /servers/fake.jar
VERSION: 1.19
DEBUG_HELPER: "true"
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar
4 changes: 3 additions & 1 deletion tests/setuponlytests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ setupOnlyMinecraftTest(){
fi
fi

# false positive since it's used in delta calculations below
# shellcheck disable=SC2034
start=$(date +%s)
if ! logs=$(docker compose run mc 2>&1); then
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
Expand Down