Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user locale override #538

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 7 additions & 5 deletions docs/install/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down