diff --git a/Dockerfile b/Dockerfile index 03ecdea4..001a4cbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz -ARG MC_HELPER_VERSION=1.5.2 +ARG MC_HELPER_VERSION=1.6.1 RUN curl -fsSL https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ | tar -C /usr/share -zxf - \ && ln -s /usr/share/mc-image-helper-${MC_HELPER_VERSION}/bin/mc-image-helper /usr/bin diff --git a/start-configuration b/start-configuration index 40521fd6..fbff2a00 100755 --- a/start-configuration +++ b/start-configuration @@ -2,14 +2,17 @@ set -euo pipefail IFS=$'\n\t' +# shellcheck source=start-utils . ${SCRIPTS:-/}start-utils -: ${EULA:=} -: ${PROXY:=} -: ${RCON_PASSWORD_FILE:=} +: "${EULA:=}" +: "${PROXY:=}" +: "${RCON_PASSWORD_FILE:=}" shopt -s nullglob +isDebugging && set -x + #umask 002 export HOME=/data @@ -63,10 +66,16 @@ export VERSIONS_JSON=https://launchermeta.mojang.com/mc/game/version_manifest.js case "X$VERSION" in X|XLATEST|Xlatest) - VANILLA_VERSION=$(curl -fsSL $VERSIONS_JSON | jq -r '.latest.release') + if ! VANILLA_VERSION=$(get --json-path '$.latest.release' "$VERSIONS_JSON"); then + log "ERROR: version lookup failed: $VANILLA_VERSION" + exit 1 + fi ;; XSNAPSHOT|Xsnapshot) - VANILLA_VERSION=$(curl -fsSL $VERSIONS_JSON | jq -r '.latest.snapshot') + if ! VANILLA_VERSION=$(get --json-path '$.latest.snapshot' "$VERSIONS_JSON"); then + log "ERROR: version lookup failed: $VANILLA_VERSION" + exit 1 + fi ;; *) VANILLA_VERSION=$VERSION @@ -122,7 +131,7 @@ case "${TYPE^^}" in ;; VANILLA) - exec ${SCRIPTS:-/}start-deployVanilla "$@" + exec "${SCRIPTS:-/}start-deployVanilla" "$@" ;; SPONGEVANILLA) diff --git a/start-deployVanilla b/start-deployVanilla index 93582889..0b618800 100755 --- a/start-deployVanilla +++ b/start-deployVanilla @@ -1,41 +1,39 @@ #!/bin/bash -. ${SCRIPTS:-/}start-utils +# shellcheck source=start-utils +. "${SCRIPTS:-/}start-utils" isDebugging && set -x set -o pipefail export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar" -if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then +if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then log "Downloading $SERVER ..." debug "Finding version manifest for $VANILLA_VERSION" - versionManifestUrl=$(curl -fsSL 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url') + versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url') result=$? if [ $result != 0 ]; then log "ERROR failed to obtain version manifest URL ($result)" exit 1 fi - if [ $versionManifestUrl = "null" ]; then + if [ "$versionManifestUrl" = "null" ]; then log "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION" exit 1 fi debug "Found version manifest at $versionManifestUrl" - serverDownloadUrl=$(curl -fsSL ${versionManifestUrl} | jq --raw-output '.downloads.server.url') + serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}") result=$? if [ $result != 0 ]; then log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)" exit 1 - elif [ $serverDownloadUrl = null ]; then + elif [ "$serverDownloadUrl" = "null" ]; then log "ERROR version $VANILLA_VERSION does not provide a server download" exit 1 fi debug "Downloading server from $serverDownloadUrl" - if isDebugging; then - verbose=-v - fi - curl $verbose -fsSL -o $SERVER $serverDownloadUrl + get -o "$SERVER" "$serverDownloadUrl" result=$? if [ $result != 0 ]; then log "ERROR failed to download server from $serverDownloadUrl ($result)" @@ -45,4 +43,4 @@ fi isDebugging && ls -l -exec ${SCRIPTS:-/}start-setupWorld $@ +exec "${SCRIPTS:-/}start-setupWorld" "$@" diff --git a/start-utils b/start-utils index 9e1cdd6c..497a4257 100755 --- a/start-utils +++ b/start-utils @@ -183,7 +183,7 @@ function removeOldMods { function get() { local flags=() - if isDebugging; then + if isTrue "${DEBUG_GET:-false}"; then flags+=("--debug") fi mc-image-helper "${flags[@]}" get "$@"