From 5d1538eb8a1fbaacc0ba2b2220a24c42a04c9e48 Mon Sep 17 00:00:00 2001 From: ACertainCoder Date: Sun, 18 Feb 2024 17:14:07 +0100 Subject: [PATCH 1/2] Add user locale override --- Dockerfile | 2 +- Dockerfile.dev | 2 +- entrypoint.sh | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e79f2f40..b1137740 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,4 +50,4 @@ ENTRYPOINT ["/entrypoint.sh"] EXPOSE 8443 25565-25570 VOLUME /var/games/minecraft -ENV USER_PASSWORD=random_see_log USER_NAME=mc USER_UID=1000 USE_HTTPS=true SERVER_PORT=8443 +ENV USER_PASSWORD=random_see_log USER_NAME=mc USER_LOCALE=en_US USER_UID=1000 USE_HTTPS=true SERVER_PORT=8443 diff --git a/Dockerfile.dev b/Dockerfile.dev index 6cf28521..638735db 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -55,4 +55,4 @@ ENTRYPOINT ["/entrypoint.sh"] EXPOSE 8443 25565-25570 VOLUME /var/games/minecraft VOLUME /etc/ssl/certs -ENV USER_PASSWORD=random_see_log USER_NAME=mc USER_UID=1000 USE_HTTPS=true SERVER_PORT=8443 +ENV USER_PASSWORD=random_see_log USER_NAME=mc USER_LOCALE=en_US USER_UID=1000 USE_HTTPS=true SERVER_PORT=8443 diff --git a/entrypoint.sh b/entrypoint.sh index 08f83ba5..d3687179 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,6 +28,19 @@ else USER_NAME=mc fi +if [ "$USER_LOCALE" ]; then + # user locale provided, will overwrite 'en_US' + USER_LOCALE="$(ls -1 /usr/games/minecraft/html/locales/ | grep -o -E -e '[a-z]{2}_[A-Z]{2}' | grep -wo "$USER_LOCALE")" + + if [ -z "$USER_LOCALE" ]; then + echo >&2 'USER_LOCALE must be one of the available ones' + exit 1 + fi +else + echo >&2 'USER_LOCALE not provided; defaulting to "en_US"' + USER_LOCALE=en_US +fi + if [ "$GROUP_NAME" ]; then # group name specifically provided, will overwrite 'mc' if [[ "$GROUP_NAME" =~ [^a-zA-Z0-9] ]]; then @@ -76,10 +89,13 @@ fi echo >&2 "Setting user password for '$USER_NAME'" echo "$USER_NAME:$USER_PASSWORD" | chpasswd --crypt-method SHA512 +echo >&2 "Setting user locale to: $USER_LOCALE" +sed -i "s/webui_locale = .*/webui_locale = '$USER_LOCALE'/" /etc/mineos.conf + if [ ! -z "$USE_HTTPS" ]; then # update mineos.conf from environment sed -i 's/use_https = .*/use_https = '${USE_HTTPS}'/g' /etc/mineos.conf - echo >&2 "Setting use_https to: " $USE_HTTPS + echo >&2 "Setting use_https to: $USE_HTTPS" if [[ -z $SERVER_PORT ]] && [ "$USE_HTTPS" = "true" ]; then Port=8443 elif [[ -z $SERVER_PORT ]] && [ "$USE_HTTPS" = "false" ]; then @@ -88,7 +104,7 @@ if [ ! -z "$USE_HTTPS" ]; then Port=$SERVER_PORT fi sed -i 's/socket_port = .*/socket_port = '${Port}'/g' /etc/mineos.conf - echo >&2 "Setting server port to: "$Port + echo >&2 "Setting server port to: $Port" fi if [[ ! -f /etc/ssl/certs/mineos.crt ]] && [[ ! -z $( grep 'use_https = true' /etc/mineos.conf) ]]; then From ba245fe6fef22b80587e3e447beca40cd43af871 Mon Sep 17 00:00:00 2001 From: ACertainCoder Date: Sun, 18 Feb 2024 17:34:06 +0100 Subject: [PATCH 2/2] Update install docs --- docs/install/docker.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/install/docker.md b/docs/install/docker.md index d3b87b1b..a5363e00 100644 --- a/docs/install/docker.md +++ b/docs/install/docker.md @@ -39,16 +39,18 @@ Create a docker volume to contain the /var/games/minecraft filetree, allowing th Start the container, and let docker keep it restart it anytime it is down, unless deliberately stopped via command line. ``` -# export MINEOS_UN=mc -# read -s MINEOS_PW -# export MINEOS_PW +# export USER_NAME=mc +# export USER_LOCALE=en_US +# read -s USER_PASSWORD +# export USER_PASSWORD # docker run -td \ --name=mineos \ -p 8443:8443 \ -p 25565:25565 \ --e MINEOS_UN \ --e MINEOS_PW \ +-e USER_NAME \ +-e USER_LOCALE \ +-e USER_PASSWORD \ -v mineos:/var/games/minecraft \ --restart=unless-stopped \ hexparrot/mineos:latest