From ddbf002df28951b0a498c58130f9b85d80df2806 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 16 Jul 2014 18:07:02 +0100 Subject: [PATCH 1/4] Only set up default locale on FixMyStreet install. FixMyStreet uses the default locale in order to have working URIs with floating point numbers. This could be moved to the FixMyStreet install script with its next release and then removed from here. --- bin/install-site.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/install-site.sh b/bin/install-site.sh index 57b0f173..dc882be3 100755 --- a/bin/install-site.sh +++ b/bin/install-site.sh @@ -524,8 +524,10 @@ EOF chmod a+rx /etc/rc.local } -generate_locales -set_locale +if [ $SITE = "fixmystreet" ]; then + generate_locales + set_locale +fi add_unix_user From c9252ea9363a11094246ee842846cc226d916bd8 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 18 Jul 2014 14:50:31 +0100 Subject: [PATCH 2/4] Quieten installation of PostGIS template. --- bin/install-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-site.sh b/bin/install-site.sh index dc882be3..ab0c1dbd 100755 --- a/bin/install-site.sh +++ b/bin/install-site.sh @@ -392,7 +392,7 @@ install_nginx() { install_postgis() { echo -n "Installing PostGIS... " POSTGIS_SCRIPT='https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-debian.sh' - su -l -c "curl '$POSTGIS_SCRIPT' | bash -s" postgres + su -l -c "curl -s '$POSTGIS_SCRIPT' | bash -s >/dev/null" postgres # According to Matthew's installation instructions, these two SRID # may be missing the appropriate +datum from the proj4text column, # depending on what PostGIS version is being used. Check whether From 3c8f92abf56746913e9d1aace8916885dd8b27b4 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 18 Jul 2014 18:28:21 +0100 Subject: [PATCH 3/4] Better set up of initial locale. Rather than always installing en_GB.UTF-8 and setting it as the default, we instead do the following: * If the current LANG (perhaps passed in via SSH) is UTF-8, make sure it is generated, and remove any default locale setup if different; * If it isn't, but the default locale is UTF-8, use that; * If not, set up en_GB.UTF-8 as before. --- bin/install-site.sh | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/bin/install-site.sh b/bin/install-site.sh index ab0c1dbd..7d69c009 100755 --- a/bin/install-site.sh +++ b/bin/install-site.sh @@ -206,21 +206,32 @@ add_locale() { echo $DONE_MSG } -generate_locales() { - echo "Generating locales... " - # If language-pack-en is present, install that: - apt-get -qq install -y language-pack-en >/dev/null || true - add_locale en_GB +setup_locale() { + echo "Setting up locale... " + default=$(LANG="" && source /etc/default/locale && echo $LANG) + if [ x"$(LC_ALL=$LANG locale -k LC_CTYPE | grep -c 'charmap="UTF-8"')" = x1 ]; then + # Current is UTF-8, make sure it's generated and use that + add_locale $LANG + if [ $default != $lang && -n "$default" ]; then + echo '' > /etc/default/locale + fi + elif [ x"$(LC_ALL=$default locale -k LC_CTYPE | grep -c 'charmap="UTF-8"')" = x1 ]; then + # current not UTF-8, but default is, let's use that as current + export LANG="$default" + export LC_ALL="$default" + else + # Fall back to installing and using en_GB.UTF-8 + # If language-pack-en is present, install that: + apt-get -qq install -y language-pack-en >/dev/null || true + add_locale en_GB + echo 'LANG="en_GB.UTF-8"' > /etc/default/locale + echo 'LC_ALL="en_GB.UTF-8"' >> /etc/default/locale + export LANG="en_GB.UTF-8" + export LC_ALL="en_GB.UTF-8" + fi echo $DONE_MSG } -set_locale() { - echo 'LANG="en_GB.UTF-8"' > /etc/default/locale - echo 'LC_ALL="en_GB.UTF-8"' >> /etc/default/locale - export LANG="en_GB.UTF-8" - export LC_ALL="en_GB.UTF-8" -} - add_unix_user() { echo -n "Adding unix user... " # Create the required user if it doesn't already exist: @@ -524,10 +535,7 @@ EOF chmod a+rx /etc/rc.local } -if [ $SITE = "fixmystreet" ]; then - generate_locales - set_locale -fi +setup_locale add_unix_user From 975e309862d6b3869fbfea0ee56d56f3c377152f Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 21 Jul 2014 15:13:24 +0100 Subject: [PATCH 4/4] source not present in Bourne shell. --- bin/install-site.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-site.sh b/bin/install-site.sh index 7d69c009..4160113b 100755 --- a/bin/install-site.sh +++ b/bin/install-site.sh @@ -208,7 +208,7 @@ add_locale() { setup_locale() { echo "Setting up locale... " - default=$(LANG="" && source /etc/default/locale && echo $LANG) + default=$(LANG="" && . /etc/default/locale && echo $LANG) if [ x"$(LC_ALL=$LANG locale -k LC_CTYPE | grep -c 'charmap="UTF-8"')" = x1 ]; then # Current is UTF-8, make sure it's generated and use that add_locale $LANG