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
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

View file

@ -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

View file

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

View file

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

View file

@ -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:

View file

@ -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" <<EOF
# 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" <<EOF
#!/bin/sh
. ./settings-local.sh
java \${JAVA_PARAMETERS} -Xmx\${MAX_RAM} -jar $(basename "${forgeJar}") nogui
EOF
chmod +x "${FTB_BASE_DIR}/ServerStart.sh"
else
log "Please make sure you are using the server version of the FTB modpack!"
exit 2
fi
startScript="${FTB_BASE_DIR}/ServerStart.sh"
chmod +x "$startScript"
else
log "ERROR: Modpack missing start script and unable to find Forge jar to generate one"
exit 2
fi
fi
scriptCount=$(find "${FTB_BASE_DIR}" $entryScriptExpr | wc -l)
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)
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" "$@"