For CurseForge, avoid conflicting start script error when run.sh present (#1539)

This commit is contained in:
Geoff Bourne 2022-05-30 08:41:21 -05:00 committed by GitHub
parent 0f23414198
commit 8d0bdb60f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 67 deletions

View file

@ -37,9 +37,18 @@ jobs:
MINECRAFT_VERSION: LATEST MINECRAFT_VERSION: LATEST
run: | run: |
tests/test.sh 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 - name: Gather Docker metadata
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
@ -47,18 +56,16 @@ jobs:
itzg/minecraft-server itzg/minecraft-server
- name: Login to DockerHub - name: Login to DockerHub
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push - name: Push
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
uses: docker/build-push-action@v3.0.0 uses: docker/build-push-action@v3.0.0
with: with:
context: . context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64 platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
pull: true pull: true
push: true push: true

View file

@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1.3 # syntax = docker/dockerfile:1.3
ARG BASE_IMAGE=eclipse-temurin:17-jdk ARG BASE_IMAGE=eclipse-temurin:17-jre-focal
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
# CI system should set this to a hash or git revision of the build directory and it's contents to # CI system should set this to a hash or git revision of the build directory and it's contents to

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
set -e set -e

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
set -e set -e

View file

@ -9,7 +9,9 @@ services:
environment: environment:
EULA: "true" EULA: "true"
TYPE: CURSEFORGE 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: 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} # CF_SERVER_MOD: /modpacks/${MODPACK:-SkyFactory_4_Server_4.1.0.zip}
ports: ports:

View file

@ -136,32 +136,31 @@ if ! isTrue "${USE_MODPACK_START_SCRIPT:-true}"; then
exec "${SCRIPTS:-/}start-setupWorld" "$@" exec "${SCRIPTS:-/}start-setupWorld" "$@"
fi 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 findStartScript() {
startScriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr |wc -l) entryScriptExpr=(
if (( startScriptCount > 1 )); then -name ServerStart.sh
log "Conflicting FTB/CurseForge packages have been installed. Please cleanup ${FTB_BASE_DIR}" -o -name serverstart.sh
exit 2 -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 fi
else }
startScriptCount=0
fi startScript=$(findStartScript)
# only download and install if a mod pack isn't already installed # only download and install if a mod pack isn't already installed
# also check for the start script rather than just the folder # 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 # this allows saving just the world separate from the rest of the data directory
if [[ $startScriptCount = 0 ]]; then if [[ ! $startScript ]]; then
downloadModpack downloadModpack
srv_modpack=${FTB_SERVER_MOD} srv_modpack=${FTB_SERVER_MOD}
@ -169,49 +168,49 @@ if [[ $startScriptCount = 0 ]]; then
mkdir -p "${FTB_BASE_DIR}" mkdir -p "${FTB_BASE_DIR}"
unzip -o "${srv_modpack}" -d "${FTB_BASE_DIR}" | awk '{printf "."} END {print ""}' 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 if [[ "$installScript" ]]; then
( (
cd "$(dirname "${installScript}")" cd "$(dirname "${installScript}")"
chmod +x ./install.sh chmod +x "${installScript}"
log "Running included install.sh. This might take a minute or two..." log "Running included $(basename "${installScript}"). This might take a minute or two..."
./install.sh > install.log "${installScript}" > install.log
) )
fi fi
startScript=$(findStartScript)
fi 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 # Allow up to 2 levels since some modpacks have a top-level directory named for the modpack
# 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)
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
if [[ "$forgeJar" ]]; then FTB_BASE_DIR=$(dirname "${forgeJar}")
FTB_BASE_DIR=$(dirname "${forgeJar}") export FTB_BASE_DIR
export FTB_BASE_DIR log "No entry script found, so building one for ${forgeJar}"
log "No entry script found, so building one for ${forgeJar}" cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
cat > "${FTB_BASE_DIR}/ServerStart.sh" <<EOF
#!/bin/sh #!/bin/sh
. ./settings-local.sh . ./settings-local.sh
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
EOF EOF
chmod +x "${FTB_BASE_DIR}/ServerStart.sh" startScript="${FTB_BASE_DIR}/ServerStart.sh"
else chmod +x "$startScript"
log "Please make sure you are using the server version of the FTB modpack!" else
exit 2 log "ERROR: Modpack missing start script and unable to find Forge jar to generate one"
fi exit 2
fi
fi fi
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l) FTB_SERVER_START="$startScript"
if [[ $scriptCount = 0 ]]; then
log "Please make sure you are using the server version of the FTB modpack!"
exit 2
elif (( scriptCount > 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)
export FTB_SERVER_START export FTB_SERVER_START
FTB_DIR=$(dirname "${FTB_SERVER_START}") FTB_DIR=$(dirname "${FTB_SERVER_START}")
@ -230,15 +229,5 @@ if isTrue "${FTB_LEGACYJAVAFIXER}" && [ ! -e "${legacyJavaFixerPath}" ]; then
fi fi
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 export FAMILY=FORGE
exec "${SCRIPTS:-/}start-setupWorld" "$@" exec "${SCRIPTS:-/}start-setupWorld" "$@"