diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index 827de93d..5e3fac06 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -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 diff --git a/tests/setuponlytests/packwiz/docker-compose.yml b/tests/setuponlytests/packwiz/docker-compose.yml new file mode 100644 index 00000000..8adf17b2 --- /dev/null +++ b/tests/setuponlytests/packwiz/docker-compose.yml @@ -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 diff --git a/tests/setuponlytests/packwiz/fake.jar b/tests/setuponlytests/packwiz/fake.jar new file mode 100644 index 00000000..e69de29b diff --git a/tests/setuponlytests/packwiz/verify.sh b/tests/setuponlytests/packwiz/verify.sh new file mode 100644 index 00000000..92b30ff0 --- /dev/null +++ b/tests/setuponlytests/packwiz/verify.sh @@ -0,0 +1 @@ +mc-image-helper assert fileExists mods/architectury-5.7.28-fabric.jar diff --git a/tests/setuponlytests/packwiz/web/index.toml b/tests/setuponlytests/packwiz/web/index.toml new file mode 100644 index 00000000..b5b29c8b --- /dev/null +++ b/tests/setuponlytests/packwiz/web/index.toml @@ -0,0 +1,6 @@ +hash-format = "sha256" + +[[files]] +file = "mods/architectury-api.pw.toml" +hash = "c20179449fff711afb96ba0eadd3328fbf1aae639082d25d77c9080837685b79" +metafile = true \ No newline at end of file diff --git a/tests/setuponlytests/packwiz/web/mods/architectury-api.pw.toml b/tests/setuponlytests/packwiz/web/mods/architectury-api.pw.toml new file mode 100644 index 00000000..fd579c5b --- /dev/null +++ b/tests/setuponlytests/packwiz/web/mods/architectury-api.pw.toml @@ -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" \ No newline at end of file diff --git a/tests/setuponlytests/packwiz/web/pack.toml b/tests/setuponlytests/packwiz/web/pack.toml new file mode 100644 index 00000000..c1d08329 --- /dev/null +++ b/tests/setuponlytests/packwiz/web/pack.toml @@ -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" \ No newline at end of file diff --git a/tests/setuponlytests/test.sh b/tests/setuponlytests/test.sh index 412839c0..e1b5ffe8 100644 --- a/tests/setuponlytests/test.sh +++ b/tests/setuponlytests/test.sh @@ -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