Skip to content

Commit

Permalink
Accounting for if '/usr/share/zoneinfo/#{Facter.value('timezone')}' d…
Browse files Browse the repository at this point in the history
…oesn't exist
  • Loading branch information
michael-riddle committed Dec 11, 2023
1 parent f24b6a0 commit f7d8a52
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/facter/timezone_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
Facter.add("timezone_file") do
setcode do
# If /etc/localtime doesn't exist, use the appropriate file in /usr/share/zoneinfo
timezone_file = File.exist?('/etc/localtime') ? '/etc/localtime' : "/usr/share/zoneinfo/#{Facter.value('timezone')}"
timezone_file = ''
if File.exist?('/etc/localtime')
timezone_file = '/etc/localtime'
elsif File.exist?("/usr/share/zoneinfo/#{Facter.value('timezone')}")
timezone_file = "/usr/share/zoneinfo/#{Facter.value('timezone')}"
else
timezone_file = '/usr/share/zoneinfo/UTC'
end
timezone_file
end
end

0 comments on commit f7d8a52

Please sign in to comment.