diff --git a/bin/install-site.sh b/bin/install-site.sh index 57b0f173..4160113b 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="" && . /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: @@ -392,7 +403,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 @@ -524,8 +535,7 @@ EOF chmod a+rx /etc/rc.local } -generate_locales -set_locale +setup_locale add_unix_user