Compare commits

...

22 Commits

Author SHA1 Message Date
Geoff Bourne
48414b3e87 Auto-merging via docker-versions-create 2022-02-08 19:18:43 -06:00
Jordy Hulck
4cb227629f Distro aware checksum (#1345) 2022-02-08 19:17:26 -06:00
dependabot[bot]
932cd8f89e build(deps): bump docker/build-push-action from 2.8.0 to 2.9.0 (#1339) 2022-02-07 06:54:56 -06:00
Geoff Bourne
f2f8d58d3b Only skip up-to-date files with MODS and MODS_FILE (#1338)
Fixes #1254
2022-02-06 17:46:17 -06:00
Luc Ritchie
b7bbe1b0a6 Support Spigot-style and vanilla-style world zips, for any server type (#1305) 2022-02-06 15:51:28 -06:00
itzg
1dd9a2e6e0 docs: Auto update markdown TOC 2022-02-06 18:45:40 +00:00
chblodg
aa7b997697 Adding support for crafting tweaks and resource packs (#1336)
Co-authored-by: christopher blodgett <christopher.blodgett@gmail.com>
Co-authored-by: Geoff Bourne <itzgeoff@gmail.com>
Co-authored-by: Floyd Everest <me@floydeverest.com>
2022-02-06 12:45:25 -06:00
Geoff Bourne
c2bf2bbcc5 Use rfc-2822 for log timestamp 2022-02-05 22:56:24 -06:00
Geoff Bourne
68b926f2b1 Auto-merging via docker-versions-create 2022-02-05 22:52:42 -06:00
Geoff Bourne
306671ffe7 Disabled world_from_tarzstd test for now 2022-02-05 22:50:12 -06:00
Geoff Bourne
be99d171f5 Added extract detection for application/x-zstd 2022-02-05 22:47:58 -06:00
Geoff Bourne
882f3b1cd8 Added zstd package 2022-02-05 22:44:13 -06:00
Geoff Bourne
eb6c7c98f0 build: adjusted discord workflow name 2022-02-05 22:40:42 -06:00
Geoff Bourne
3472c67ca8 build: give issue-label workflow a name 2022-02-05 16:10:12 -06:00
Geoff Bourne
8995e63b72 build: fixed typo in push condition 2022-02-05 16:03:40 -06:00
Geoff Bourne
b65f108917 build: also push git tag builds 2022-02-05 16:02:27 -06:00
itzg
2b374a2073 docs: Auto update markdown TOC 2022-02-05 18:38:46 +00:00
Geoff Bourne
b5b164d5d3 feat: added SKIP_GENERIC_PACK_UPDATE_CHECK and FORCE_GENERIC_PACK_UPDATE (#1333) 2022-02-05 12:38:33 -06:00
itzg
0cde40604e docs: Auto update markdown TOC 2022-02-05 18:27:33 +00:00
Geoff Bourne
22f2eb7308 feat: add option to include timestamp with init logs (#1332) 2022-02-05 12:27:17 -06:00
Geoff Bourne
4a1d2d2b80 build: adjusted for eclipse-temurin:8-jdk not being on armv7 2022-02-02 22:27:38 -06:00
Geoff Bourne
10922b261b build: build-multiarch tags were too broad 2022-02-02 22:18:54 -06:00
43 changed files with 449 additions and 110 deletions

View File

@@ -6,7 +6,6 @@ on:
- test/** - test/**
tags: tags:
- "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-*"
paths-ignore: paths-ignore:
- "*.md" - "*.md"
- "docs/**" - "docs/**"
@@ -39,7 +38,7 @@ jobs:
- variant: java8-multiarch - variant: java8-multiarch
baseImage: eclipse-temurin:8-jdk baseImage: eclipse-temurin:8-jdk
tagPrefix: java8- tagPrefix: java8-
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm64
mcVersion: 1.12.2 mcVersion: 1.12.2
- variant: java8-openj9 - variant: java8-openj9
baseImage: ibm-semeru-runtimes:open-8-jdk baseImage: ibm-semeru-runtimes:open-8-jdk
@@ -71,7 +70,7 @@ jobs:
itzg/minecraft-server itzg/minecraft-server
tags: | tags: |
type=ref,event=tag,enable=${{ matrix.variant == 'java17' }} type=ref,event=tag,enable=${{ matrix.variant == 'java17' }}
type=ref,event=tag,prefix=${{ matrix.variant }}- type=ref,event=tag,suffix=-${{ matrix.variant }}
type=raw,value=${{ matrix.variant }} type=raw,value=${{ matrix.variant }}
flavor: | flavor: |
latest=${{ matrix.variant == 'java17' }} latest=${{ matrix.variant == 'java17' }}
@@ -91,7 +90,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build for test - name: Build for test
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
platforms: linux/amd64 platforms: linux/amd64
tags: ${{ env.IMAGE_TO_TEST }} tags: ${{ env.IMAGE_TO_TEST }}
@@ -113,10 +112,10 @@ jobs:
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
platforms: ${{ matrix.platforms }} platforms: ${{ matrix.platforms }}
push: ${{ github.ref_name == 'master' }} push: ${{ github.ref_type == 'tag' || github.ref_name == 'master' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
# ensure latest base image is used # ensure latest base image is used
pull: true pull: true

View File

@@ -27,7 +27,7 @@ jobs:
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Build - name: Build
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64

View File

@@ -1,4 +1,4 @@
name: discord name: Discord notifications
on: on:
workflow_run: workflow_run:

View File

@@ -1,3 +1,5 @@
name: Issue labels
on: on:
issues: issues:
types: [labeled] types: [labeled]

View File

@@ -46,7 +46,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build for test - name: Build for test
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
if: github.ref_name == 'java8' if: github.ref_name == 'java8'
with: with:
context: . context: .
@@ -68,7 +68,7 @@ jobs:
- name: Build and push - name: Build and push
id: docker_build id: docker_build
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile

View File

@@ -24,7 +24,7 @@ jobs:
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Build - name: Build
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
context: . context: .
platforms: linux/amd64 platforms: linux/amd64
@@ -53,7 +53,7 @@ jobs:
- name: Push - name: Push
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
uses: docker/build-push-action@v2.8.0 uses: docker/build-push-action@v2.9.0
with: with:
context: . context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64,linux/arm/v7,linux/arm64

View File

@@ -15,8 +15,24 @@ Individual scripts can be iteratively developed, debugged, and tested using the
First, build a baseline of the image to include the packages needed by existing or new scripts: First, build a baseline of the image to include the packages needed by existing or new scripts:
```shell script PowerShell:
docker build -t mc-dev . ```powershell
$env:IMAGE_TO_TEST="mc-dev"
docker build -t $env:IMAGE_TO_TEST .
pushd tests/setuponlytests/vanillatweaks_file/
docker-compose run mc
docker-compose down --remove-orphans
popd
```
Bash:
```bash
export IMAGE_TO_TEST=mc-dev
docker build -t $IMAGE_TO_TEST .
pushd tests/setuponlytests/vanillatweaks_file/
docker-compose run mc
docker-compose down --remove-orphans
popd
``` ```
Using the baseline image, an interactive container can be started to iteratively run the scripts to be developed. By attaching the current workspace directory, you can use the local editor of your choice to iteratively modify scripts while using the container to run them. Using the baseline image, an interactive container can be started to iteratively run the scripts to be developed. By attaching the current workspace directory, you can use the local editor of your choice to iteratively modify scripts while using the container to run them.

View File

@@ -20,7 +20,8 @@ RUN apk add --no-cache -U \
nano \ nano \
sudo \ sudo \
knock \ knock \
ttf-dejavu ttf-dejavu \
zstd
RUN addgroup -g 1000 minecraft \ RUN addgroup -g 1000 minecraft \
&& adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \ && adduser -Ss /bin/false -u 1000 -G minecraft -h /home/minecraft minecraft \
@@ -61,7 +62,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --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 --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.16.3 ARG MC_HELPER_VERSION=1.16.5
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION} ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
| tar -C /usr/share -zxf - \ | tar -C /usr/share -zxf - \

View File

@@ -68,7 +68,7 @@ By default, the container will download the latest version of the "vanilla" [Min
* [Optional plugins, mods, and config attach points](#optional-plugins-mods-and-config-attach-points) * [Optional plugins, mods, and config attach points](#optional-plugins-mods-and-config-attach-points)
* [Auto-downloading SpigotMC/Bukkit/PaperMC plugins](#auto-downloading-spigotmcbukkitpapermc-plugins) * [Auto-downloading SpigotMC/Bukkit/PaperMC plugins](#auto-downloading-spigotmcbukkitpapermc-plugins)
* [Downloadable mod/plugin pack for Forge, Fabric, and Bukkit-like Servers](#downloadable-modplugin-pack-for-forge-fabric-and-bukkit-like-servers) * [Downloadable mod/plugin pack for Forge, Fabric, and Bukkit-like Servers](#downloadable-modplugin-pack-for-forge-fabric-and-bukkit-like-servers)
* [<strong>ForgeAPI</strong> usage to use non-version specific projects](#forgeapi-usage-to-use-non-version-specific-projects) * [ForgeAPI usage to use non-version specific projects](#forgeapi-usage-to-use-non-version-specific-projects)
* [Generic pack files](#generic-pack-files) * [Generic pack files](#generic-pack-files)
* [Mod/Plugin URL Listing File](#modplugin-url-listing-file) * [Mod/Plugin URL Listing File](#modplugin-url-listing-file)
* [Remove old mods/plugins](#remove-old-modsplugins) * [Remove old mods/plugins](#remove-old-modsplugins)
@@ -134,6 +134,7 @@ By default, the container will download the latest version of the "vanilla" [Min
* [Stop Duration](#stop-duration) * [Stop Duration](#stop-duration)
* [Setup only](#setup-only) * [Setup only](#setup-only)
* [Enable Flare Flags](#enable-flare-flags) * [Enable Flare Flags](#enable-flare-flags)
* [Enable timestamps in init logs](#enable-timestamps-in-init-logs)
* [Autopause](#autopause) * [Autopause](#autopause)
* [Description](#description) * [Description](#description)
* [Enabling Autopause](#enabling-autopause) * [Enabling Autopause](#enabling-autopause)
@@ -141,7 +142,7 @@ By default, the container will download the latest version of the "vanilla" [Min
* [Running on RaspberryPi](#running-on-raspberrypi) * [Running on RaspberryPi](#running-on-raspberrypi)
* [Contributing](#contributing) * [Contributing](#contributing)
<!-- Added by: runner, at: Wed Feb 2 02:53:20 UTC 2022 --> <!-- Added by: runner, at: Sun Feb 6 18:45:39 UTC 2022 -->
<!--te--> <!--te-->
@@ -746,9 +747,9 @@ 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 ... docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ...
### **ForgeAPI** usage to use non-version specific projects ### ForgeAPI usage to use non-version specific projects
**NOTE:** This potentially could lead to unexpected behavior if the Mod recieves an update with unexpected behavior. **NOTE:** This potentially could lead to unexpected behavior if the Mod receives an update with unexpected behavior.
This is more complicated because you will be pulling/using the latest mod for the release of your game. To get started make sure you have a [CursedForge API Key](https://docs.curseforge.com/#getting-started). Then use the environmental parameters in your docker build. This is more complicated because you will be pulling/using the latest mod for the release of your game. To get started make sure you have a [CursedForge API Key](https://docs.curseforge.com/#getting-started). Then use the environmental parameters in your docker build.
@@ -774,10 +775,10 @@ Example of expected forge api project ids, releases, and key:
Example of expected ForgeAPI file format. Example of expected ForgeAPI file format.
**Field Description**: **Field Description**:
* Name is currently unused, but can be used to document each entry. * `name` is currently unused, but can be used to document each entry.
* Project id is the id found on the CurseForge website for a particular mod * `projectId` id is the id found on the CurseForge website for a particular mod
* Release Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha). * `releaseType` Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha).
* FileName is used for version pinning if latest file will not work for you. * `fileName` is used for version pinning if latest file will not work for you.
```json ```json
[ [
@@ -802,7 +803,7 @@ Example of expected ForgeAPI file format.
### Generic pack files ### Generic pack files
To install all of the server content (jars, mods, plugins, configs, etc) from a zip or tgz file, such as a CurseForge modpack that is missing a server start script, then set `GENERIC_PACK` to the container path or URL of the archive file. To install all the server content (jars, mods, plugins, configs, etc.) from a zip or tgz file, then set `GENERIC_PACK` to the container path or URL of the archive file. This can also be used to apply a CurseForge modpack that is missing a server start script and/or Forge installer.
If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of archive file paths and/or URLs to files. If multiple generic packs need to be applied together, set `GENERIC_PACKS` instead, with a comma separated list of archive file paths and/or URLs to files.
@@ -816,6 +817,8 @@ GENERIC_PACKS_SUFFIX=.zip
would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.org/mods-v4.3.6.zip`. would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.org/mods-v4.3.6.zip`.
If applying large generic packs, the update check can be time-consuming since a SHA1 checksum is compared. To skip the update check set `SKIP_GENERIC_PACK_UPDATE_CHECK` to "true". Conversely, the generic pack(s) can be forced to be applied without comparing the checksum by setting `FORCE_GENERIC_PACK_UPDATE` to "true".
### Mod/Plugin URL Listing File ### 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 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
@@ -893,6 +896,9 @@ Datapacks will be placed in `/data/$LEVEL/datapacks`
VanillaTweaks datapacks can be installed with a share code from the website UI **OR** a json file to specify packs to download and install. VanillaTweaks datapacks can be installed with a share code from the website UI **OR** a json file to specify packs to download and install.
Datapacks will be placed in `/data/$LEVEL/datapacks`
Resourcepacks will be placed in `/data/resourcepacks`
Accepted Parameters: Accepted Parameters:
- `VANILLATWEAKS_FILE` - `VANILLATWEAKS_FILE`
@@ -903,13 +909,19 @@ Accepted Parameters:
- `REMOVE_OLD_VANILLATWEAKS_EXCLUDE` - `REMOVE_OLD_VANILLATWEAKS_EXCLUDE`
Example of expected Vanillatweaks sharecode: Example of expected Vanillatweaks sharecode:
**Note**: ResourcePacks, DataPacks, and CraftingTweaks all have separate sharecodes
```yaml ```yaml
VANILLATWEAKS_SHARECODE: MGr52E VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
``` ```
Example of expected Vanillatweaks file format: Example of expected Vanillatweaks file format:
```yaml
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
```
Datapacks Json:
```json ```json
{ {
"version": "1.18", "version": "1.18",
@@ -917,18 +929,39 @@ Example of expected Vanillatweaks file format:
"survival": [ "survival": [
"graves", "graves",
"multiplayer sleep", "multiplayer sleep",
"afk display",
"armor statues",
"unlock all recipes",
"fast leaf decay",
"coordinates hud"
], ],
"items": ["armored elytra"] "items": ["armored elytra"]
} }
} }
``` ```
Datapacks will be placed in `/data/$LEVEL/datapacks` Resourcepacks Json:
```json
{
"type": "resourcepacks",
"version": "1.18",
"packs": {
"aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"]
},
"result": "ok"
}
```
CraftingTweaks Json:
```json
{
"type": "craftingtweaks",
"version": "1.18",
"packs": {
"quality of life": [
"dropper to dispenser",
"double slabs",
"back to blocks"
]
},
"result": "ok"
}
```
## Server configuration ## Server configuration
@@ -1559,6 +1592,20 @@ To enable the JVM flags required to fully support the [Flare profiling suite](ht
Flare is built-in to Airplane/Pufferfish/Purpur, and is available in [plugin form](https://github.com/TECHNOVE/FlarePlugin) for other server types. Flare is built-in to Airplane/Pufferfish/Purpur, and is available in [plugin form](https://github.com/TECHNOVE/FlarePlugin) for other server types.
### Enable timestamps in init logs
Before the container starts the Minecraft Server its output is prefixed with `[init]`, such as
```
[init] Starting the Minecraft server...
```
To also include the timestamp with each log, set `LOG_TIMESTAMP` to "true". The log output will then look like:
```
[init] 2022-02-05 16:58:33+00:00 Starting the Minecraft server...
```
## Autopause ## Autopause
### Description ### Description

View File

@@ -29,7 +29,7 @@ if [[ "${PACKWIZ_URL}" ]]; then
if [[ -z "${latestPackwiz}" ]]; then if [[ -z "${latestPackwiz}" ]]; then
log "WARNING: Could not retrieve Packwiz bootstrap installer release information" log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
else else
isDebugging && log "Latest packwiz ${latestPackWiz}" isDebugging && log "Latest packwiz ${latestPackwiz}"
latestPackwizVer=$(echo ${latestPackwiz} | jq --raw-output '.tag_name') latestPackwizVer=$(echo ${latestPackwiz} | jq --raw-output '.tag_name')
latestPackwizUrl=$(echo ${latestPackwiz} | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url') latestPackwizUrl=$(echo ${latestPackwiz} | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url')
: "${PACKWIZ_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}" : "${PACKWIZ_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}"
@@ -92,7 +92,7 @@ elif [[ "$MODS" ]]; then
do do
if isURL "$i"; then if isURL "$i"; then
log "Downloading mod/plugin $i ..." log "Downloading mod/plugin $i ..."
if ! get -o "${out_dir}" "$i"; then if ! get --skip-up-to-date -o "${out_dir}" "$i"; then
log "ERROR: failed to download from $i into $out_dir" log "ERROR: failed to download from $i into $out_dir"
exit 2 exit 2
fi fi
@@ -128,7 +128,7 @@ elif [[ "$MODS_FILE" ]]; then
args=( args=(
-o "${out_dir}" -o "${out_dir}"
--log-progress-each --log-progress-each
--skip-existing --skip-up-to-date
--uris-file "${MODS_FILE}" --uris-file "${MODS_FILE}"
) )
if isTrue "${REMOVE_OLD_MODS}"; then if isTrue "${REMOVE_OLD_MODS}"; then
@@ -199,7 +199,8 @@ if [[ "${GENERIC_PACKS}" ]]; then
pack="${GENERIC_PACKS_PREFIX}${packEntry}${GENERIC_PACKS_SUFFIX}" pack="${GENERIC_PACKS_PREFIX}${packEntry}${GENERIC_PACKS_SUFFIX}"
if isURL "${pack}"; then if isURL "${pack}"; then
mkdir -p /data/packs mkdir -p /data/packs
if ! outfile=$(get -o /data/packs --output-filename --skip-existing "$pack"); then log "Downloading generic pack from $pack"
if ! outfile=$(get -o /data/packs --output-filename --skip-up-to-date "$pack"); then
log "ERROR: failed to download $pack" log "ERROR: failed to download $pack"
exit 2 exit 2
fi fi
@@ -210,7 +211,13 @@ if [[ "${GENERIC_PACKS}" ]]; then
done done
isDebugging && [ -f "$sum_file}" ] && cat "$sum_file" isDebugging && [ -f "$sum_file}" ] && cat "$sum_file"
if ! sha1sum -c "${sum_file}" --status 2> /dev/null; then
log "Checking if generic packs are up to date"
if isTrue "${SKIP_GENERIC_PACK_UPDATE_CHECK:-false}" && [ -f "$sum_file" ]; then
log "Skipping generic pack update check"
elif isTrue "${FORCE_GENERIC_PACK_UPDATE}" || ! checkSum "${sum_file}"; then
log "Generic pack(s) are out of date. Re-applying..."
base_dir=/tmp/generic_pack_base base_dir=/tmp/generic_pack_base
mkdir -p ${base_dir} mkdir -p ${base_dir}
for pack in "${packFiles[@]}"; do for pack in "${packFiles[@]}"; do
@@ -243,6 +250,7 @@ if [[ "${GENERIC_PACKS}" ]]; then
cp -R -f "${base_dir}"/* /data cp -R -f "${base_dir}"/* /data
rm -rf /tmp/generic_pack_base rm -rf /tmp/generic_pack_base
log "Saving generic pack(s) checksum"
sha1sum "${packFiles[@]}" > "${sum_file}" sha1sum "${packFiles[@]}" > "${sum_file}"
isDebugging && cat "$sum_file" isDebugging && cat "$sum_file"
fi fi

View File

@@ -12,73 +12,115 @@ set -e -o pipefail
. "${SCRIPTS:-/}start-utils" . "${SCRIPTS:-/}start-utils"
isDebugging && set -x isDebugging && set -x
out_dir=/data/${LEVEL:-world}/datapacks VT_VERSION=""
DATAPACKS_DIR="/data/${LEVEL:-world}/datapacks"
RESOURCEPACKS_DIR="/data/resourcepacks"
# Remove old VANILLATWEAKS # Remove old VANILLATWEAKS
if isTrue "${REMOVE_OLD_VANILLATWEAKS}" && [ -z "${VANILLATWEAKS_FILE}" ]; then if isTrue "${REMOVE_OLD_VANILLATWEAKS}"; then
if [ -d "$out_dir" ]; then # NOTE: datapacks include crafting tweaks.
find "$out_dir" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete if [ -d "$DATAPACKS_DIR" ]; then
find "$DATAPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
fi
if [ -d "$RESOURCEPACKS_DIR" ]; then
find "$RESOURCEPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
fi fi
fi fi
# Gets the download url and downloads the actual files.
getUrlAndDownload(){
VT_FILE=$1
URL_SUFFIX=$2
OUTPUT_FILE=$3
PACKS=$(jq -jc '.packs // empty' $VT_FILE)
if [ ! "$PACKS" ]; then
log "ERROR: unable to retrieve ${URL_SUFFIX} from ${VT_FILE}"
exit 2
fi
ZIPDATA_URL="https://vanillatweaks.net/assets/server/zip${URL_SUFFIX}.php"
DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $ZIPDATA_URL | jq -r '.link // empty')
if [ ! "$DOWNLOAD_URL" ]; then
log "ERROR: unable to retrieve ${URL_SUFFIX} packs from vanillatweaks.net!"
exit 2
fi
if ! get -o $OUTPUT_FILE "https://vanillatweaks.net${DOWNLOAD_URL}"; then
log "ERROR: failed to download ${URL_SUFFIX} from ${DOWNLOAD_URL}"
exit 2
fi
}
# Datapacks Handler
downloadDatapacks(){
VT_FILE=$1
URL_SUFFIX="datapacks"
OUTPUT_FILE="/tmp/vanillatweaks.zip"
getUrlAndDownload $VT_FILE $URL_SUFFIX $OUTPUT_FILE
mkdir -p "$DATAPACKS_DIR"
if ! unzip -o -d "$DATAPACKS_DIR" $OUTPUT_FILE; then
log "ERROR: failed to unzip the datapacks ${DATAPACKS} from ${OUTPUT_FILE}"
fi
rm -f $OUTPUT_FILE
}
# Crafting Tweaks Handler
downloadCraftingtweaks(){
VT_FILE=$1
mkdir -p "$DATAPACKS_DIR"
getUrlAndDownload $VT_FILE "craftingtweaks" "${DATAPACKS_DIR}/craftingtweaks.zip"
}
# Resourcepacks Handler
downloadResourcepacks(){
VT_FILE=$1
mkdir -p "$RESOURCEPACKS_DIR"
getUrlAndDownload $VT_FILE "resourcepacks" "${RESOURCEPACKS_DIR}/resourcepacks.zip"
}
# Example: VANILLATWEAKS_SHARECODE=MGr52E # Example: VANILLATWEAKS_SHARECODE=MGr52E
# Code generated from the UI website, typically a alphanumeric 6 digit code. # Code generated from the UI website, typically a alphanumeric 6 digit code.
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
VANILLATWEAKS_FILE=/tmp/vanillatweaksfile.json VANILLATWEAKS_FILE=()
SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${VANILLATWEAKS_SHARECODE}" for SHARECODE in ${VANILLATWEAKS_SHARECODE//,/ }; do
curl -f $SHARECODE_LOOKUP_URL -o $VANILLATWEAKS_FILE TMP_FILE="/tmp/${SHARECODE}.json"
if [ ! -f "$VANILLATWEAKS_FILE" ]; then SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${SHARECODE}"
log "ERROR: Unable to use share code provided to retreive vanillatweaks file" if ! get -o "$TMP_FILE" "$SHARECODE_LOOKUP_URL"; then
log "ERROR: Unable to use ${SHARECODE} share code provided to retrieve vanillatweaks file"
exit 2 exit 2
fi fi
VANILLATWEAKS_FILE+="${TMP_FILE},"
done
fi fi
# Use vanillatweaks file to specify VT and datapacks # Use vanillatweaks file to specify VT and datapacks and crafting tweaks
if [[ "$VANILLATWEAKS_FILE" ]]; then if [[ "$VANILLATWEAKS_FILE" ]]; then
if [ ! -f "$VANILLATWEAKS_FILE" ]; then for VT_FILE in ${VANILLATWEAKS_FILE//,/ }; do
if [ ! -f "$VT_FILE" ]; then
log "ERROR: given VANILLATWEAKS_FILE file does not exist" log "ERROR: given VANILLATWEAKS_FILE file does not exist"
exit 2 exit 2
fi fi
PACKS=$(jq -jc '.packs' $VANILLATWEAKS_FILE) VT_VERSION=$(jq -jc '.version // empty' $VT_FILE)
if [ ! "$PACKS" ]; then
log "ERROR: unable to retrieve packs from $VANILLATWEAKS_FILE"
exit 2
fi
VT_VERSION=$(jq -jc '.version' $VANILLATWEAKS_FILE)
if [ ! "$VT_VERSION" ]; then if [ ! "$VT_VERSION" ]; then
log "ERROR: unable to retrieve version from $VANILLATWEAKS_FILE" log "ERROR: unable to retrieve version from $VT_FILE"
exit 2
fi
fi
# Download and unzip packs
if [[ "$PACKS" ]] && [[ "$VT_VERSION" ]]; then
VT_ZIPDATA_URL=https://vanillatweaks.net/assets/server/zipdatapacks.php
DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $VT_ZIPDATA_URL | jq -r '.link')
if [ ! "$DOWNLOAD_URL" ]; then
log "ERROR: unable to retrieve DOWNLOAD_URL from vanillatweaks.net!"
exit 2 exit 2
fi fi
TEMPZIP=/tmp/vanillatweaks.zip TYPE=$(jq -jc '.type // empty' $VT_FILE)
if ! get -o $TEMPZIP "https://vanillatweaks.net${DOWNLOAD_URL}"; then if [[ "$TYPE" = "datapacks" ]]; then
log "ERROR: failed to download from ${DOWNLOAD_URL}" downloadDatapacks $VT_FILE
exit 2 elif [[ "$TYPE" = "craftingtweaks" ]]; then
downloadCraftingtweaks $VT_FILE
elif [[ "$TYPE" = "resourcepacks" ]]; then
downloadResourcepacks $VT_FILE
fi fi
mkdir -p "$out_dir"
if ! unzip -o -d "$out_dir" $TEMPZIP; then
log "ERROR: failed to unzip the ${PACKS} from ${$TEMPZIP}"
fi
# clean up files time!
rm -f $TEMPZIP
# cleans up temp vanilla tweaks file download to get stored packs # cleans up temp vanilla tweaks file download to get stored packs
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
rm -f $VANILLATWEAKS_FILE rm -f $VT_FILE
fi fi
done
fi fi
exec "${SCRIPTS:-/}start-setupDatapack" "$@" exec "${SCRIPTS:-/}start-setupDatapack" "$@"

View File

@@ -37,11 +37,7 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
exit 1 exit 1
fi fi
if [ "$FAMILY" = "SPIGOT" ]; then
baseDirs=$(find /tmp/world-data -name "level.dat" -not -path "*_nether*" -not -path "*_the_end*" -exec dirname "{}" \;)
else
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;) baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
fi
if ! [[ $baseDirs ]]; then if ! [[ $baseDirs ]]; then
log "ERROR world content is not valid since level.dat could not be found" log "ERROR world content is not valid since level.dat could not be found"
@@ -50,20 +46,65 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
count=$(echo "$baseDirs" | wc -l) count=$(echo "$baseDirs" | wc -l)
if [[ $count -gt 1 ]]; then if [[ $count -gt 1 ]]; then
baseDirsNoSpigotSuffix=$(echo "$baseDirs" | sed -re 's:(_nether|_the_end)/?$::' | sort -u)
if [ $(echo "$baseDirsNoSpigotSuffix" | wc -l) -eq 1 ]; then
baseDir="$baseDirsNoSpigotSuffix"
baseName=$(basename "$baseDir")
log "Found Spigot naming conventions, taking $baseName as main dimension"
else
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)" baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
baseName=$(basename "$baseDir") baseName=$(basename "$baseDir")
log "WARN multiple levels found, picking: $baseName" log "WARN multiple levels found, picking: $baseName"
fi
elif [[ $count -gt 0 ]]; then elif [[ $count -gt 0 ]]; then
baseDir="$baseDirs" baseDir="$baseDirs"
else else
log "ERROR invalid world content" log "ERROR invalid world content"
exit 1 exit 1
fi fi
if [ -d "${baseDir}_nether/DIM-1" ]; then
if [ -d "$baseDir/DIM-1" ]; then
log "WARN found Nether dimension in both $baseDir and ${baseDir}_nether, picking ${baseDir}_nether"
rm -r "$baseDir/DIM-1"
fi
fi
if [ -d "${baseDir}_the_end/DIM1" ]; then
if [ -d "$baseDir/DIM1" ]; then
log "WARN found End dimension in both $baseDir and ${baseDir}_the_end, picking ${baseDir}_the_end"
rm -r "$baseDir/DIM1"
fi
fi
log "Copying world..."
rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest" rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest"
if [ "$FAMILY" = "SPIGOT" ]; then if [ "$FAMILY" = "SPIGOT" ]; then
log "Copying end and nether ..." if [ -d "${baseDir}_nether" ]; then
[ -d "${baseDir}_nether" ] && rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether" log "Copying Spigot Nether..."
[ -d "${baseDir}_the_end" ] && rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end" rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether"
elif [ -d "$worldDest/DIM-1" ]; then
log "Moving Nether to Spigot location..."
mkdir -p "${worldDest}_nether"
mv -f "$worldDest/DIM-1" "${worldDest}_nether/"
fi
if [ -d "${baseDir}_the_end" ]; then
log "Copying Spigot End..."
rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end"
elif [ -d "$worldDest/DIM1" ]; then
log "Moving End to Spigot location..."
mkdir -p "${worldDest}_the_end"
mv -f "$worldDest/DIM1" "${worldDest}_the_end/"
fi
else
if [ -d "${baseDir}_nether/DIM-1" ]; then
log "Copying Spigot Nether to vanilla location..."
rsync --remove-source-files --recursive --delete "${baseDir}_nether/DIM-1" "${worldDest}/"
fi
if [ -d "${baseDir}_the_end/DIM1" ]; then
log "Copying Spigot End to vanilla location..."
rsync --remove-source-files --recursive --delete "${baseDir}_the_end/DIM1" "${worldDest}/"
fi
fi fi
elif [ -d "$WORLD" ]; then elif [ -d "$WORLD" ]; then
log "Cloning world directory from $WORLD ..." log "Cloning world directory from $WORLD ..."

View File

@@ -40,6 +40,10 @@ function getFilenameFromUrl() {
} }
function isTrue() { function isTrue() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace
local value=${1,,} local value=${1,,}
result= result=
@@ -53,6 +57,7 @@ function isTrue() {
;; ;;
esac esac
eval "$oldState"
return ${result} return ${result}
} }
@@ -82,7 +87,18 @@ function logn() {
} }
function log() { function log() {
echo "[init] $*" local oldState
# 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
if isDebugging || isTrue "${LOG_TIMESTAMP:-false}"; then
ts=" $(date --rfc-2822)"
else
ts=
fi
echo "[init]${ts} $*"
eval "$oldState"
} }
function logAutopause() { function logAutopause() {
@@ -211,7 +227,7 @@ function extract() {
application/zip) application/zip)
unzip -q -d "${destDir}" "${src}" unzip -q -d "${destDir}" "${src}"
;; ;;
application/x-tar|application/gzip|application/x-gzip|application/x-bzip2|application/zstd) application/x-tar|application/gzip|application/x-gzip|application/x-bzip2|application/zstd|application/x-zstd)
tar -C "${destDir}" -xf "${src}" tar -C "${destDir}" -xf "${src}"
;; ;;
*) *)
@@ -220,3 +236,20 @@ function extract() {
;; ;;
esac esac
} }
function checkSum() {
local sum_file=${1?}
# Get distro
distro=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2 | sed -e 's/"//g')
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
else
return 1
fi
}

View File

@@ -0,0 +1,15 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
TYPE: "PAPER"
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,5 @@
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

View File

@@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,5 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world/DIM-1/some_spigot_nether_file && \
mc-image-helper assert fileExists world/DIM1/some_spigot_end_file && \
! mc-image-helper assert fileExists world/DIM-1/some_vanilla_nether_file && \
! mc-image-helper assert fileExists world/DIM1/some_vanilla_end_file

View File

@@ -11,8 +11,14 @@ services:
image: ${IMAGE_TO_TEST:-itzg/minecraft-server} image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment: environment:
EULA: "true" EULA: "true"
SETUP_ONLY: "TRUE" SETUP_ONLY: "true"
GENERIC_PACKS: http://web/configs.zip,/packs/testing.zip GENERIC_PACKS: http://web/configs.zip,/packs/testing.zip
LOG_TIMESTAMP: "true"
# the following are only used to speed up test execution
TYPE: CUSTOM
CUSTOM_SERVER: /servers/fake.jar
VERSION: 1.18.1
volumes: volumes:
- ./packs:/packs - ./packs:/packs
- ./data:/data - ./data:/data
- ./fake.jar:/servers/fake.jar

View File

@@ -0,0 +1,15 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
TYPE: "PAPER"
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,4 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world/some_overworld_file && \
mc-image-helper assert fileExists world_nether/DIM-1/some_nether_file && \
mc-image-helper assert fileExists world_the_end/DIM1/some_end_file

View File

@@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,4 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world/some_overworld_file && \
mc-image-helper assert fileExists world/DIM-1/some_nether_file && \
mc-image-helper assert fileExists world/DIM1/some_end_file

View File

@@ -0,0 +1,15 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
TYPE: "PAPER"
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,3 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world_nether/DIM-1/some_nether_file && \
mc-image-helper assert fileExists world_the_end/DIM1/some_end_file

View File

@@ -0,0 +1,14 @@
version: "3"
services:
mc:
restart: "no"
image: ${IMAGE_TO_TEST:-itzg/minecraft-server}
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST}
WORLD: /worlds/world-for-testing.zip
volumes:
- ./worlds:/worlds:ro
- ./data:/data

View File

@@ -0,0 +1,3 @@
mc-image-helper assert fileExists world/level.dat && \
mc-image-helper assert fileExists world/DIM-1/some_nether_file && \
mc-image-helper assert fileExists world/DIM1/some_end_file

View File

@@ -8,7 +8,10 @@ services:
EULA: "TRUE" EULA: "TRUE"
SETUP_ONLY: "TRUE" SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST} VERSION: ${MINECRAFT_VERSION:-LATEST}
VANILLATWEAKS_FILE: /config/vanillatweaks-datapacks.json VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
REMOVE_OLD_VANILLATWEAKS: "TRUE" REMOVE_OLD_VANILLATWEAKS: "FALSE"
volumes: volumes:
- ./vanillatweaks-datapacks.json:/config/vanillatweaks-datapacks.json:ro - ./data:/data
- ./vt-datapacks.json:/config/vt-datapacks.json:ro
- ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro
- ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro

View File

@@ -0,0 +1,4 @@
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"

View File

@@ -0,0 +1,12 @@
{
"type": "craftingtweaks",
"version": "1.18",
"packs": {
"quality of life": [
"dropper to dispenser",
"double slabs",
"back to blocks"
]
},
"result": "ok"
}

View File

@@ -0,0 +1,8 @@
{
"type": "resourcepacks",
"version": "1.18",
"packs": {
"aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"]
},
"result": "ok"
}

View File

@@ -8,5 +8,7 @@ services:
EULA: "TRUE" EULA: "TRUE"
SETUP_ONLY: "TRUE" SETUP_ONLY: "TRUE"
VERSION: ${MINECRAFT_VERSION:-LATEST} VERSION: ${MINECRAFT_VERSION:-LATEST}
VANILLATWEAKS_SHARECODE: MGr52E VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
REMOVE_OLD_VANILLATWEAKS: "TRUE" REMOVE_OLD_VANILLATWEAKS: "FALSE"
volumes:
- ./data:/data

View File

@@ -0,0 +1,4 @@
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"