Provide option to use existing bedrock server executable (#563)
This commit is contained in:
1 parent
41ef36c5f8
commit
be0a795d98
2 files changed
+34
-6
No files matched your search
@@ -38,6 +38,7 @@ For Minecraft Java Edition you'll need to use this image instead:
|
|||||||
- `VERSION` (default is `LATEST`) : can be set to a specific server version or the following special values can be used:
|
- `VERSION` (default is `LATEST`) : can be set to a specific server version or the following special values can be used:
|
||||||
- `LATEST` : determines the latest (non-preview) version and can be used to auto-upgrade on container start
|
- `LATEST` : determines the latest (non-preview) version and can be used to auto-upgrade on container start
|
||||||
- `PREVIEW` : determines the latest preview version and will auto-upgrade
|
- `PREVIEW` : determines the latest preview version and will auto-upgrade
|
||||||
|
- `EXISTING`: use existing bedrock server executable in `/data`. Must be named either `bedrock_server-{version}` or just `bedrock_server`
|
||||||
- otherwise any specific server version can be provided. If it is a preview version, also set `PREVIEW` to "true"
|
- otherwise any specific server version can be provided. If it is a preview version, also set `PREVIEW` to "true"
|
||||||
- `UID` (default derived from `/data` owner) : can be set to a specific user ID to run the
|
- `UID` (default derived from `/data` owner) : can be set to a specific user ID to run the
|
||||||
bedrock server process
|
bedrock server process
|
||||||
|
|||||||
+33
-6
@@ -23,6 +23,20 @@ function replace_version_in_url() {
|
|||||||
echo "$modified_url"
|
echo "$modified_url"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function versionFromExisting() {
|
||||||
|
# shellcheck disable=SC2012
|
||||||
|
# since find doesn't support sort by version numbers, -v
|
||||||
|
if [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then
|
||||||
|
VERSION=${BASH_REMATCH[1]}
|
||||||
|
return 0
|
||||||
|
elif ls bedrock_server 2> /dev/null; then
|
||||||
|
VERSION=none
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function lookupVersion() {
|
function lookupVersion() {
|
||||||
platform=${1:?Missing required platform indicator}
|
platform=${1:?Missing required platform indicator}
|
||||||
customVersion=${2:-}
|
customVersion=${2:-}
|
||||||
@@ -74,8 +88,7 @@ function lookupVersion() {
|
|||||||
# shellcheck disable=SC2012
|
# shellcheck disable=SC2012
|
||||||
if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then
|
if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then
|
||||||
VERSION=${BASH_REMATCH[1]}
|
VERSION=${BASH_REMATCH[1]}
|
||||||
elif [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then
|
elif versionFromExisting; then
|
||||||
VERSION=${BASH_REMATCH[1]}
|
|
||||||
echo "WARN Minecraft download page failed, so using existing download of $VERSION"
|
echo "WARN Minecraft download page failed, so using existing download of $VERSION"
|
||||||
else
|
else
|
||||||
echo "Failed to lookup download URL: ${DOWNLOAD_URL}"
|
echo "Failed to lookup download URL: ${DOWNLOAD_URL}"
|
||||||
@@ -128,6 +141,14 @@ else # Original logic: if DIRECT_DOWNLOAD_URL is NOT set, proceed with lookup
|
|||||||
echo "Looking up latest version..."
|
echo "Looking up latest version..."
|
||||||
lookupVersion serverBedrockLinux
|
lookupVersion serverBedrockLinux
|
||||||
;;
|
;;
|
||||||
|
EXISTING)
|
||||||
|
if versionFromExisting; then
|
||||||
|
echo "Using existing bedrock server executable"
|
||||||
|
else
|
||||||
|
echo "ERROR unable to locate existing bedrock server executable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# use the given version exactly
|
# use the given version exactly
|
||||||
if isTrue "$PREVIEW"; then
|
if isTrue "$PREVIEW"; then
|
||||||
@@ -141,7 +162,13 @@ else # Original logic: if DIRECT_DOWNLOAD_URL is NOT set, proceed with lookup
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "bedrock_server-${VERSION}" ]]; then
|
if [[ $VERSION = none ]]; then
|
||||||
|
SERVER=bedrock_server
|
||||||
|
else
|
||||||
|
SERVER="bedrock_server-${VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$SERVER" ]]; then
|
||||||
|
|
||||||
[[ $DOWNLOAD_DIR != /tmp ]] && mkdir -p "$DOWNLOAD_DIR"
|
[[ $DOWNLOAD_DIR != /tmp ]] && mkdir -p "$DOWNLOAD_DIR"
|
||||||
TMP_ZIP="$DOWNLOAD_DIR/$(basename "${DOWNLOAD_URL}")"
|
TMP_ZIP="$DOWNLOAD_DIR/$(basename "${DOWNLOAD_URL}")"
|
||||||
@@ -199,7 +226,7 @@ if [[ ! -f "bedrock_server-${VERSION}" ]]; then
|
|||||||
[[ $DOWNLOAD_DIR != /tmp ]] && rm -rf "$DOWNLOAD_DIR"
|
[[ $DOWNLOAD_DIR != /tmp ]] && rm -rf "$DOWNLOAD_DIR"
|
||||||
|
|
||||||
chmod +x bedrock_server
|
chmod +x bedrock_server
|
||||||
mv bedrock_server "bedrock_server-${VERSION}"
|
mv bedrock_server "$SERVER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$OPS" || -n "$MEMBERS" || -n "$VISITORS" ]]; then
|
if [[ -n "$OPS" || -n "$MEMBERS" || -n "$VISITORS" ]]; then
|
||||||
@@ -283,7 +310,7 @@ fi
|
|||||||
|
|
||||||
echo "Starting Bedrock server..."
|
echo "Starting Bedrock server..."
|
||||||
if [[ -f /usr/local/bin/box64 ]] ; then
|
if [[ -f /usr/local/bin/box64 ]] ; then
|
||||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" box64 ./"bedrock_server-${VERSION}"
|
exec mc-server-runner "${mcServerRunnerArgs[@]}" box64 ./"$SERVER"
|
||||||
else
|
else
|
||||||
exec mc-server-runner "${mcServerRunnerArgs[@]}" ./"bedrock_server-${VERSION}"
|
exec mc-server-runner "${mcServerRunnerArgs[@]}" ./"$SERVER"
|
||||||
fi
|
fi
|
||||||
Reference in new issue
Block a user