Handle packwiz bootstrap installer already being present (#1595)

This commit is contained in:
Geoff Bourne 2022-07-11 22:27:07 -05:00 committed by GitHub
parent 51f1a08f6e
commit e3a29180fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 19 deletions

View File

@ -23,37 +23,35 @@ if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then
fi
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL}" ]]; then
if [[ "${PACKWIZ_URL:-}" ]]; then
# Ensure we have the latest packwiz bootstrap installer
latestPackwiz=$(curl -fsSL 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_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}"
if [[ ! -e $PACKWIZ_JAR ]]; then
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}"
curl -H "Accept:application/octet-stream" -o "$PACKWIZ_JAR" -fsSL ${latestPackwizUrl}
ln -sf "${PACKWIZ_JAR}" packwiz-installer-bootstrap.jar
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
fi
fi
if [[ ! -f packwiz-installer-bootstrap.jar ]]; then
log "ERROR: Packwiz not available or could not be downloaded from Github!"
exit 1
fi
log "Running packwiz against URL: ${PACKWIZ_URL}"
java -jar packwiz-installer-bootstrap.jar -g -s server "${PACKWIZ_URL}"
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=$(curl -fsSL 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')
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}"
curl -H "Accept:application/octet-stream" -o "packwiz-installer.jar" -fsSL ${latestPackwizInstallerUrl}
java -jar packwiz-installer-bootstrap.jar -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
curl -H "Accept:application/octet-stream" -o "packwiz-installer.jar" -fsSL "${latestPackwizInstallerUrl}"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
fi
fi

View File

@ -0,0 +1,21 @@
version: "3"
services:
web:
image: nginx
volumes:
- ./web:/usr/share/nginx/html
mc:
depends_on:
- web
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
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar

View File

View File

@ -0,0 +1 @@
mc-image-helper assert fileExists mods/architectury-5.7.28-fabric.jar

View File

@ -0,0 +1,6 @@
hash-format = "sha256"
[[files]]
file = "mods/architectury-api.pw.toml"
hash = "c20179449fff711afb96ba0eadd3328fbf1aae639082d25d77c9080837685b79"
metafile = true

View File

@ -0,0 +1,13 @@
name = "Architectury API"
filename = "architectury-5.7.28-fabric.jar"
side = "both"
[download]
url = "https://cdn.modrinth.com/data/lhGA9TYQ/versions/5.7.28+fabric/architectury-5.7.28-fabric.jar"
hash-format = "sha1"
hash = "aa38ae9cc2e978e4ec87ff891f7b02ea0c0ee1b8"
[update]
[update.modrinth]
mod-id = "lhGA9TYQ"
version = "Hf0Bau1j"

View File

@ -0,0 +1,13 @@
name = "Vanillia Server"
author = "itzg"
version = "2.0.0"
pack-format = "packwiz:1.1.0"
[index]
file = "index.toml"
hash-format = "sha256"
hash = "1a27b406c3fb6d35167fe659384ab528a6b3f8a66e6c05d593058e646aec591f"
[versions]
fabric = "0.14.8"
minecraft = "1.19"

View File

@ -40,7 +40,7 @@ setupOnlyMinecraftTest(){
fi
start=$(date +%s)
if ! logs=$(docker-compose run mc 2>&1); then
if ! logs=$(docker compose run mc 2>&1); then
outputContainerLog "$logs"
result=1
elif [ -f verify.sh ]; then
@ -57,7 +57,7 @@ setupOnlyMinecraftTest(){
echo "${folder} PASSED in $(delta start)"
fi
docker-compose down -v --remove-orphans > /dev/null
docker compose down -v --remove-orphans >& /dev/null
cd ..
return $result