Просмотр исходного кода

run UTF-8 locale (#4704)

* ensure UTF-8 locale, switch to 1.9.5.sh upgrade

commit history for the old branch got messy, re-created from main.

* nit

* nit
divinity76 3 месяцев назад
Родитель
Сommit
b6b976b155
2 измененных файлов с 46 добавлено и 0 удалено
  1. 23 0
      install/hst-install.sh
  2. 23 0
      install/upgrade/versions/1.9.5.sh

+ 23 - 0
install/hst-install.sh

@@ -77,6 +77,29 @@ if [ "$type" = "NoSupport" ]; then
 	no_support_message
 fi
 
+ensure_utf8_locale() {
+	local locale_file="/etc/default/locale"
+
+	if locale | grep -qi 'utf-8'; then
+		return
+	fi
+
+	echo "[ * ] Enabling UTF-8 locale support via C.UTF-8"
+	if ! locale-gen C.UTF-8; then
+		echo "[ ! ] Failed to generate C.UTF-8 locale. Leaving existing locale untouched."
+		return
+	fi
+
+	if ! update-locale LANG=C.UTF-8; then
+		echo "[ ! ] Failed to update LANG in $locale_file. Leaving existing locale untouched."
+		return
+	fi
+
+	export LANG=C.UTF-8
+}
+
+ensure_utf8_locale
+
 check_wget_curl() {
 	# Check wget
 	if [ -e '/usr/bin/wget' ]; then

+ 23 - 0
install/upgrade/versions/1.9.5.sh

@@ -23,6 +23,29 @@ upgrade_config_set_value 'UPGRADE_UPDATE_MAIL_TEMPLATES' 'false'
 upgrade_config_set_value 'UPGRADE_REBUILD_USERS' 'no'
 upgrade_config_set_value 'UPGRADE_UPDATE_FILEMANAGER_CONFIG' 'false'
 
+ensure_utf8_locale() {
+	local locale_file="/etc/default/locale"
+
+	if locale | grep -qi 'utf-8'; then
+		return
+	fi
+
+	echo "[ * ] Enabling UTF-8 locale support via C.UTF-8"
+	if ! locale-gen C.UTF-8; then
+		echo "[ ! ] Failed to generate C.UTF-8 locale. Leaving existing locale untouched."
+		return
+	fi
+
+	if ! update-locale LANG=C.UTF-8; then
+		echo "[ ! ] Failed to update LANG in $locale_file. Leaving existing locale untouched."
+		return
+	fi
+
+	export LANG=C.UTF-8
+}
+
+ensure_utf8_locale
+
 #Fix: avoid spamd execution in Exim when reject_spam is off for current installations
 if [ "$MAIL_SYSTEM" = "exim4" ]; then
 	echo "[ * ] Fixing spamd execution in Exim when reject_spam is off"