diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 46a0aaeeb18..6020456a398 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -7,20 +7,33 @@ isDebugging && set -x if [ -n "$ICON" ]; then if [ ! -e server-icon.png ] || isTrue "${OVERRIDE_ICON}"; then log "Using server icon from $ICON..." - # Not sure what it is yet...call it "img" - if ! get -o /tmp/icon.img "$ICON"; then - log "ERROR: failed to download icon from $ICON" + if isURL "$ICON"; then + # Not sure what it is yet...call it "img" + if ! get -o /tmp/icon.img "$ICON"; then + log "ERROR: failed to download icon from $ICON" + exit 1 + fi + ICON=/tmp/icon.img + iconSrc="url" + elif [ -f "$ICON" ]; then + iconSrc="file" + else + log "ERROR: $ICON does not appear to be a URL or existing file" exit 1 fi - read -r -a specs < <(identify /tmp/icon.img | awk 'NR == 1 { print $2, $3 }') + read -r -a specs < <(identify "$ICON" | awk 'NR == 1 { print $2, $3 }') if [ "${specs[0]} ${specs[1]}" = "PNG 64x64" ]; then - mv /tmp/icon.img /data/server-icon.png + if [ $iconSrc = url ]; then + mv -f /tmp/icon.img /data/server-icon.png + else + cp -f "$ICON" /data/server-icon.png + fi elif [ "${specs[0]}" = GIF ]; then log "Converting GIF image to 64x64 PNG..." - convert "/tmp/icon.img[0]" -resize 64x64! /data/server-icon.png + convert "$ICON"[0] -resize 64x64! /data/server-icon.png else log "Converting image to 64x64 PNG..." - convert /tmp/icon.img -resize 64x64! /data/server-icon.png + convert "$ICON" -resize 64x64! /data/server-icon.png fi fi fi diff --git a/tests/setuponlytests/icon-file-exact/docker-compose.yml b/tests/setuponlytests/icon-file-exact/docker-compose.yml new file mode 100644 index 00000000000..f08d4a70cbc --- /dev/null +++ b/tests/setuponlytests/icon-file-exact/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3" + +services: + mc: + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "true" + SETUP_ONLY: "true" + ICON: /extra/4737386_minecraft_squircle_icon_64x64.png + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 + volumes: + - ./data:/data + - ./extra:/extra + - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/icon-file-exact/extra/4737386_minecraft_squircle_icon_64x64.png b/tests/setuponlytests/icon-file-exact/extra/4737386_minecraft_squircle_icon_64x64.png new file mode 100644 index 00000000000..9e82cc3d7f5 Binary files /dev/null and b/tests/setuponlytests/icon-file-exact/extra/4737386_minecraft_squircle_icon_64x64.png differ diff --git a/tests/setuponlytests/icon-file-exact/fake.jar b/tests/setuponlytests/icon-file-exact/fake.jar new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/setuponlytests/icon-file-exact/verify.sh b/tests/setuponlytests/icon-file-exact/verify.sh new file mode 100644 index 00000000000..3bde55eb98f --- /dev/null +++ b/tests/setuponlytests/icon-file-exact/verify.sh @@ -0,0 +1 @@ +mc-image-helper assert fileExists server-icon.png \ No newline at end of file diff --git a/tests/setuponlytests/icon-file-scale/docker-compose.yml b/tests/setuponlytests/icon-file-scale/docker-compose.yml new file mode 100644 index 00000000000..213dc80b88b --- /dev/null +++ b/tests/setuponlytests/icon-file-scale/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3" + +services: + mc: + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "true" + SETUP_ONLY: "true" + ICON: /extra/4737386_minecraft_squircle_icon.png + # the following are only used to speed up test execution + TYPE: CUSTOM + CUSTOM_SERVER: /servers/fake.jar + VERSION: 1.18.1 + volumes: + - ./data:/data + - ./extra:/extra + - ./fake.jar:/servers/fake.jar diff --git a/tests/setuponlytests/icon-file-scale/extra/4737386_minecraft_squircle_icon.png b/tests/setuponlytests/icon-file-scale/extra/4737386_minecraft_squircle_icon.png new file mode 100644 index 00000000000..9f8da2e5ce0 Binary files /dev/null and b/tests/setuponlytests/icon-file-scale/extra/4737386_minecraft_squircle_icon.png differ diff --git a/tests/setuponlytests/icon-file-scale/fake.jar b/tests/setuponlytests/icon-file-scale/fake.jar new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/setuponlytests/icon-file-scale/verify.sh b/tests/setuponlytests/icon-file-scale/verify.sh new file mode 100644 index 00000000000..3bde55eb98f --- /dev/null +++ b/tests/setuponlytests/icon-file-scale/verify.sh @@ -0,0 +1 @@ +mc-image-helper assert fileExists server-icon.png \ No newline at end of file