summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKapil Chouhan <kapil.chouhan@msystechnologies.com>2018-12-24 17:02:25 +0530
committerKapil Chouhan <kapil.chouhan@msystechnologies.com>2018-12-24 17:02:25 +0530
commit4e977f8d306d104fc202daadd7a28fd379eaa186 (patch)
treeb07bc6c631b98f486334a399eb034dd9496b0abb
parent60c042414ccef8ca6fbfa1e974973ae6f3ebb241 (diff)
downloadchef-Kapil/MSYS-946_locale_resource_does_not_set_LC_ALL.tar.gz
now locale resource is setting LC_ALLKapil/MSYS-946_locale_resource_does_not_set_LC_ALL
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
-rw-r--r--lib/chef/resource/locale.rb28
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/chef/resource/locale.rb b/lib/chef/resource/locale.rb
index ca6ea510c0..d249f7bd02 100644
--- a/lib/chef/resource/locale.rb
+++ b/lib/chef/resource/locale.rb
@@ -36,13 +36,21 @@ class Chef
action :update do
description "Update the system's locale."
- if node["init_package"] == "systemd"
- # on systemd settings LC_ALL is (correctly) reserved only for testing and cannot be set globally
- execute "localectl set-locale LANG=#{new_resource.lang}" do
+ if node["init_package"] == "systemd" || ::File.exist?("/usr/sbin/update-locale")
+ execute "Generate locales" do
+ command "locale-gen #{new_resource.lang}"
+ # RHEL uses /etc/locale.conf
+ not_if { up_to_date?("/etc/locale.conf", new_resource.lang, new_resource.lc_all) } if ::File.exist?("/etc/locale.conf")
+ # Ubuntu 16.04 still uses /etc/default/locale
+ not_if { up_to_date?("/etc/default/locale", new_resource.lang, new_resource.lc_all) } if ::File.exist?("/etc/default/locale")
+ end
+
+ execute "Update locale" do
+ command "update-locale LANG=#{new_resource.lang} LC_ALL=#{new_resource.lc_all}"
# RHEL uses /etc/locale.conf
- not_if { up_to_date?("/etc/locale.conf", new_resource.lang) } if ::File.exist?("/etc/locale.conf")
+ not_if { up_to_date?("/etc/locale.conf", new_resource.lang, new_resource.lc_all) } if ::File.exist?("/etc/locale.conf")
# Ubuntu 16.04 still uses /etc/default/locale
- not_if { up_to_date?("/etc/default/locale", new_resource.lang) } if ::File.exist?("/etc/default/locale")
+ not_if { up_to_date?("/etc/default/locale", new_resource.lang, new_resource.lc_all) } if ::File.exist?("/etc/default/locale")
end
elsif ::File.exist?("/etc/sysconfig/i18n")
locale_file_path = "/etc/sysconfig/i18n"
@@ -64,16 +72,6 @@ class Chef
command "source /etc/sysconfig/i18n; source /etc/profile.d/lang.sh"
not_if { updated }
end
- elsif ::File.exist?("/usr/sbin/update-locale")
- execute "Generate locales" do
- command "locale-gen"
- not_if { up_to_date?("/etc/default/locale", new_resource.lang, new_resource.lc_all) }
- end
-
- execute "Update locale" do
- command "update-locale LANG=#{new_resource.lang} LC_ALL=#{new_resource.lc_all}"
- not_if { up_to_date?("/etc/default/locale", new_resource.lang, new_resource.lc_all) }
- end
else
raise "#{node["platform"]} platform not supported by the chef locale resource."
end