From 90c3e51e03b9f7404c27f9da2423f6dc4a7e9228 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 10 Apr 2022 11:17:38 -0500 Subject: [PATCH 1/2] Allow ICON to reference a local file Fixes #1449 --- scripts/start-finalExec | 23 ++++++++++++++---- .../icon-file-exact/docker-compose.yml | 17 +++++++++++++ .../4737386_minecraft_squircle_icon_64x64.png | Bin 0 -> 1247 bytes tests/setuponlytests/icon-file-exact/fake.jar | 0 .../setuponlytests/icon-file-exact/verify.sh | 1 + .../icon-file-scale/docker-compose.yml | 17 +++++++++++++ .../extra/4737386_minecraft_squircle_icon.png | Bin 0 -> 1131 bytes tests/setuponlytests/icon-file-scale/fake.jar | 0 .../setuponlytests/icon-file-scale/verify.sh | 1 + 9 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 tests/setuponlytests/icon-file-exact/docker-compose.yml create mode 100644 tests/setuponlytests/icon-file-exact/extra/4737386_minecraft_squircle_icon_64x64.png create mode 100644 tests/setuponlytests/icon-file-exact/fake.jar create mode 100644 tests/setuponlytests/icon-file-exact/verify.sh create mode 100644 tests/setuponlytests/icon-file-scale/docker-compose.yml create mode 100644 tests/setuponlytests/icon-file-scale/extra/4737386_minecraft_squircle_icon.png create mode 100644 tests/setuponlytests/icon-file-scale/fake.jar create mode 100644 tests/setuponlytests/icon-file-scale/verify.sh diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 46a0aaeeb18..98c93862a6e 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -7,14 +7,27 @@ 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 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 0000000000000000000000000000000000000000..9e82cc3d7f5113d36ac90cf10049ee1c0b414c35 GIT binary patch literal 1247 zcmV<51R(o~P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf1awJ6K~#8N?VHVS z+(a10pBa0-+rTz%X-*|lR^NjI^7)@0V>^<XglR-JmZ<%p0LN=f}MXGlS&?e`Al68ldCEk{Y1n#F84I20`QV&}0qN zzrO`_kA}h_wI~|To6qNA%^Uz4ZJoMx6rCc-K=Y98%?BS8n&bw-f@zGyUBN z2A4lJsR26fPdZQSww3-iUmc9>24bX97Ne$3(Vo43qabigg&~ai( z4bX97Ne$3(VoAIKvF8I;j{Ve`x$S`%v|x_rp_(Db>pUY|X`pqxsuQ|1`1Ldlp8JnD zAF%BPWRE|CJin|M@;yP3m2fYYQ2E6FJ;AsJZ2M1upAD$88#=TpAnGf&A?V*Wfa~QB ztXApoMsWM}_qhQ(P`ds$UVEY13sft(Y+LzGFCM-w?|q2U;8+rk zE2Yj8tZt`M;pF}t%)^6QdQ!Uqs+-((HWpTTzbHZGXI>xfEa(WCJ!|$BOuYE>th(bY z!4MG^L@-=9KkxVog%!UB>kgXt=NcFx`=)B)+1%5RGb0n;qQb~<0UVzYRXjtdcg=Hs zh?u?GYT)htuR)$3J>jjWOd55!jB{hNkmL3kj#4eCHf#FO-iNhL72m=Ud-T!LS$pm{ z>dHlak1wEP@wxvmon<)TjlyB9)Jk*j4U1T4?(gbyNBiRDp8GaRKUzo+XeNZ1|fCt4^9h9D>>|Fo=002ov JPDHLkV1m>iRlEQI literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9f8da2e5ce0aa0d653e7389d638df3a821692fb7 GIT binary patch literal 1131 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSoCO|{#S9GG!XV7ZFl&wk0|Se! zr;B4q#hkZyJ+p%YC60YuobguWWv^g*;FfdFTi3a;Zhd})bIZ9!N_j^rH9`+2K0KEH z;FNyidESWcU3#+LLhYNotRL@OIW^47)90*k@qc!?pj{dFx4+l_ey=!KDEU;(&K=8* zKYc3`*)4waMs44o-%@hjF7q$x?D;$8Yo0;PUHj?-y87kogx4>cIZ5{ke|qw7zq=|c z4essZEq?v?_09BoZ|{lBd%ON=?}RMHJ*Px+!d(xa7kjf&W83{FM<;uFTIkli*SKMv z%4^T_&(C7|p8#=RHOs_hCr$4hIbZX>&)^T6Uz5T%b#;s9#W(W5s2IzApQW%fB0$_d ztL4CM^OJn}Zx-(7<5J#wW`(ZO?>{2Pc7I>`P`&)elcNHjMXc9t_q<)*oYbN8EwSjI z{1tI0m5<+cYVPe=px3g(DCNfQ<>rBJ_DQ_^v(zH-TbfZ_!0Vr)N1rYBPJLOiEA|un zoS!SAZsTfVQIZp%FR{@Qo)3{DKWwXdK2Wp?0vAja@yBGV2| zhRP)jd26PA=VwrDc+D_@oq^#3;|?~E=(=?i!J^s>6WqBTe9Ef)&k(@0gN30I=y1t~ zYu#YsLt2&p|Jydae7$)S<2C1~b7f2pwk*{38O*c~?-@uK&yjb3Y~ zQ0g0qnDw1m;VuK8P96ipy}tos7mBhXH)h_RvuaZ1rqH13PZu{{y>_o|y*InUnR_l9 z|1M*3DCtc4t}4U$M!i(gW!l0gA_fuctpculYV(xd|9aXgAlksLCjPzT6u07}CpC4O zJ;Nq^2#e)eS-7V<-!05++ul!29=^ue3iTIy;vUY{zv?>imP*e5xY>(l8nHPnOW3_b z{lX7U@xSrbN!u^>Y~R%SC-LiC$4~siY0?aHB+7p%Yk&G?#vx^J`0)Gr1wR(+arGBj zWz1sqJ Mr>mdKI;Vst0L4qVHvj+t literal 0 HcmV?d00001 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 From c8a252fa3d7478fded09392995a19dba6d4281da Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 10 Apr 2022 11:25:47 -0500 Subject: [PATCH 2/2] Fix bugs --- scripts/start-finalExec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 98c93862a6e..6020456a398 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -7,7 +7,7 @@ isDebugging && set -x if [ -n "$ICON" ]; then if [ ! -e server-icon.png ] || isTrue "${OVERRIDE_ICON}"; then log "Using server icon from $ICON..." - if isUrl "$ICON"; then + 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" @@ -30,10 +30,10 @@ if [ -n "$ICON" ]; then 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