From 37ea672f10f5c73ccf23d23b7cea28bf26663854 Mon Sep 17 00:00:00 2001 From: h8h Date: Tue, 30 Sep 2014 13:33:27 +0200 Subject: [PATCH 1/3] In Addition to #206, generate the locals before change to it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For my german box changing the locale failed: ´´´´/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) setup/functions.sh: line 6: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)´´´´ The first use / change happens in [function.sh](https://github.com/mail-in-a-box/mailinabox/blob/master/setup/functions.sh#L5) so in my opinion we have to generate it in bootstrap.sh. --- setup/bootstrap.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh index cbf2c7c3..b97042be 100755 --- a/setup/bootstrap.sh +++ b/setup/bootstrap.sh @@ -26,6 +26,11 @@ if [ ! -d mailinabox ]; then echo Downloading Mail-in-a-Box . . . git clone -b $TAG --depth 1 https://github.com/mail-in-a-box/mailinabox 2> /dev/null + + # Generate the locale en_US.UTF-8 + locale-gen en_US.UTF-8 + dpkg-reconfigure locales + cd mailinabox # If it does exist, update it. From d9ed25e6d8b29be448edc31e882818e8e6e882fd Mon Sep 17 00:00:00 2001 From: H8H Date: Tue, 30 Sep 2014 19:50:13 +0200 Subject: [PATCH 2/3] Fixed cannot change locale (en_US.UTF-8) #206 --- setup/functions.sh | 9 --------- setup/start.sh | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/setup/functions.sh b/setup/functions.sh index 9aab289b..23c2492b 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -1,12 +1,3 @@ -# Ensure Python reads/writes files in UTF-8. If the machine -# triggers some other locale in Python, like ASCII encoding, -# Python may not be able to read/write files. Here and in -# the management daemon startup script. -export LANGUAGE=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 -export LC_TYPE=en_US.UTF-8 - function hide_output { # This function hides the output of a command unless the command fails # and returns a non-zero exit code. diff --git a/setup/start.sh b/setup/start.sh index aa2cbe4e..46584a69 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -8,6 +8,21 @@ source setup/functions.sh # load our functions # machine with enough memory? If not, this shows an error and exits. . setup/preflight.sh +# Ensure Python reads/writes files in UTF-8. If the machine +# triggers some other locale in Python, like ASCII encoding, +# Python may not be able to read/write files. Here and in +# the management daemon startup script. + +if [ -z `locale -a | grep en_US.utf8` ]; then + # Generate locale if not exists + hide_output locale-gen en_US.UTF-8 +fi + +export LANGUAGE=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 +export LC_TYPE=en_US.UTF-8 + # Recall the last settings used if we're running this a second time. if [ -f /etc/mailinabox.conf ]; then # Run any system migrations before proceeding. Since this is a second run, From 216c557064d30ac5f6e2261d8d61046a46512d17 Mon Sep 17 00:00:00 2001 From: H8H Date: Tue, 30 Sep 2014 19:52:53 +0200 Subject: [PATCH 3/3] Revert "In Addition to #206, generate the locals before change to it." This reverts commit 37ea672f10f5c73ccf23d23b7cea28bf26663854. --- setup/bootstrap.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh index b97042be..cbf2c7c3 100755 --- a/setup/bootstrap.sh +++ b/setup/bootstrap.sh @@ -26,11 +26,6 @@ if [ ! -d mailinabox ]; then echo Downloading Mail-in-a-Box . . . git clone -b $TAG --depth 1 https://github.com/mail-in-a-box/mailinabox 2> /dev/null - - # Generate the locale en_US.UTF-8 - locale-gen en_US.UTF-8 - dpkg-reconfigure locales - cd mailinabox # If it does exist, update it.