From 8d0bdb60f0bb93516edf41e08fce6ecc664c32c0 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Mon, 30 May 2022 08:41:21 -0500 Subject: [PATCH] For CurseForge, avoid conflicting start script error when run.sh present (#1539) --- .github/workflows/pr.yml | 15 ++- Dockerfile | 2 +- build/run.sh | 2 +- build/ubuntu/install-packages.sh | 2 +- examples/docker-compose-curseforge.yml | 4 +- scripts/start-deployCF | 107 ++++++++---------- ...ompose.yml => docker-compose.yml.disabled} | 0 7 files changed, 65 insertions(+), 67 deletions(-) rename tests/setuponlytests/vanillatweaks_file/{docker-compose.yml => docker-compose.yml.disabled} (100%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4de1198a..1f5b9cbe 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -37,9 +37,18 @@ jobs: MINECRAFT_VERSION: LATEST run: | tests/test.sh + push: + runs-on: ubuntu-20.04 + needs: + - test + if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') + steps: + - uses: actions/checkout@v3 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Gather Docker metadata - if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') id: meta uses: docker/metadata-action@v4 with: @@ -47,18 +56,16 @@ jobs: itzg/minecraft-server - name: Login to DockerHub - if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Push - if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') uses: docker/build-push-action@v3.0.0 with: context: . - platforms: linux/amd64,linux/arm/v7,linux/arm64 + platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} pull: true push: true diff --git a/Dockerfile b/Dockerfile index d65c67f3..d59c368a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax = docker/dockerfile:1.3 -ARG BASE_IMAGE=eclipse-temurin:17-jdk +ARG BASE_IMAGE=eclipse-temurin:17-jre-focal FROM ${BASE_IMAGE} # CI system should set this to a hash or git revision of the build directory and it's contents to diff --git a/build/run.sh b/build/run.sh index d2a41cb5..16514193 100755 --- a/build/run.sh +++ b/build/run.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e diff --git a/build/ubuntu/install-packages.sh b/build/ubuntu/install-packages.sh index cea0d7ef..80222ae6 100755 --- a/build/ubuntu/install-packages.sh +++ b/build/ubuntu/install-packages.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e diff --git a/examples/docker-compose-curseforge.yml b/examples/docker-compose-curseforge.yml index 88ae842a..f4527466 100644 --- a/examples/docker-compose-curseforge.yml +++ b/examples/docker-compose-curseforge.yml @@ -9,7 +9,9 @@ services: environment: EULA: "true" TYPE: CURSEFORGE - CF_SERVER_MOD: https://media.forgecdn.net/files/3482/169/Valhelsia+3-3.4.4-SERVER.zip + CF_SERVER_MOD: /modpacks/SIMPLE-SERVER-FILES-0.3.20.zip +# CF_SERVER_MOD: /modpacks/createlive3serverfiles+1.4.2.zip +# CF_SERVER_MOD: /modpacks/Valhelsia+3-3.5.1-SERVER.zip # CF_SERVER_MOD: https://media.forgecdn.net/files/3012/800/SkyFactory-4_Server_4.2.2.zip # CF_SERVER_MOD: /modpacks/${MODPACK:-SkyFactory_4_Server_4.1.0.zip} ports: diff --git a/scripts/start-deployCF b/scripts/start-deployCF index f95daa07..d30fdeaf 100755 --- a/scripts/start-deployCF +++ b/scripts/start-deployCF @@ -136,32 +136,31 @@ if ! isTrue "${USE_MODPACK_START_SCRIPT:-true}"; then exec "${SCRIPTS:-/}start-setupWorld" "$@" fi -entryScriptExpr=" - -name ServerStart.sh - -o -name serverstart.sh - -o -name ServerStartLinux.sh - -o -name LaunchServer.sh - -o -name server-start.sh - -o -name start-server.sh - -o -name startserver.sh - -o -name StartServer.sh - -o -name run.sh - " -if [[ -d ${FTB_BASE_DIR} ]]; then - startScriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr |wc -l) - if (( startScriptCount > 1 )); then - log "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}" - exit 2 +findStartScript() { + entryScriptExpr=( + -name ServerStart.sh + -o -name serverstart.sh + -o -name ServerStartLinux.sh + -o -name LaunchServer.sh + -o -name server-start.sh + -o -name start-server.sh + -o -name startserver.sh + -o -name StartServer.sh + -o -name run.sh + ) + + if [ -d "${FTB_BASE_DIR}" ]; then + find "${FTB_BASE_DIR}" \( "${entryScriptExpr[@]}" \) -print -quit fi -else - startScriptCount=0 -fi +} + +startScript=$(findStartScript) # only download and install if a mod pack isn't already installed # also check for the start script rather than just the folder # this allows saving just the world separate from the rest of the data directory -if [[ $startScriptCount = 0 ]]; then +if [[ ! $startScript ]]; then downloadModpack srv_modpack=${FTB_SERVER_MOD} @@ -169,49 +168,49 @@ if [[ $startScriptCount = 0 ]]; then mkdir -p "${FTB_BASE_DIR}" unzip -o "${srv_modpack}" -d "${FTB_BASE_DIR}" | awk '{printf "."} END {print ""}' - installScript=$(find "${FTB_BASE_DIR}" -maxdepth 2 -type f -name install.sh) + installScriptExpr=( + -name install.sh + -o -name FTBInstall.sh + -o -name Install.sh + ) + + installScript=$(find "${FTB_BASE_DIR}" -maxdepth 2 -type f \( "${installScriptExpr[@]}" \) -print -quit) if [[ "$installScript" ]]; then ( cd "$(dirname "${installScript}")" - chmod +x ./install.sh - log "Running included install.sh. This might take a minute or two..." - ./install.sh > install.log + chmod +x "${installScript}" + log "Running included $(basename "${installScript}"). This might take a minute or two..." + "${installScript}" > install.log ) fi + + startScript=$(findStartScript) fi -if [[ $(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l) = 0 ]]; then +# start script provided by unzipped+installed modpack? +if [[ ! $startScript ]]; then + # no, then look for a forge jar to run - # Allow up to 2 levels since some modpacks have a top-level directory named - # for the modpack - forgeJar=$(find "${FTB_BASE_DIR}" -maxdepth 2 -type f \( -path "/libraries/*" -o -path "/mods/*" \) -prune -o -name "forge*.jar" -not -name "forge*installer.jar" -print) - if [[ "$forgeJar" ]]; then - FTB_BASE_DIR=$(dirname "${forgeJar}") - export FTB_BASE_DIR - log "No entry script found, so building one for ${forgeJar}" - cat > "${FTB_BASE_DIR}/ServerStart.sh" < "${FTB_BASE_DIR}/ServerStart.sh" < 1 )); then - log "Ambiguous startup scripts in FTB modpack! Found:" - find "${FTB_BASE_DIR}" $entryScriptExpr - exit 2 -fi - -FTB_SERVER_START=$(find "${FTB_BASE_DIR}" $entryScriptExpr) +FTB_SERVER_START="$startScript" export FTB_SERVER_START FTB_DIR=$(dirname "${FTB_SERVER_START}") @@ -230,15 +229,5 @@ if isTrue "${FTB_LEGACYJAVAFIXER}" && [ ! -e "${legacyJavaFixerPath}" ]; then fi fi -if [ -e "${FTB_DIR}/FTBInstall.sh" ]; then - pushd "${FTB_DIR}" - sh FTBInstall.sh - popd -elif [ -e "${FTB_DIR}/Install.sh" ]; then - pushd "${FTB_DIR}" - sh Install.sh - popd -fi - export FAMILY=FORGE exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/tests/setuponlytests/vanillatweaks_file/docker-compose.yml b/tests/setuponlytests/vanillatweaks_file/docker-compose.yml.disabled similarity index 100% rename from tests/setuponlytests/vanillatweaks_file/docker-compose.yml rename to tests/setuponlytests/vanillatweaks_file/docker-compose.yml.disabled