From 58d1951b927bd4eacdbf77d664d439313f928da1 Mon Sep 17 00:00:00 2001 From: Roman Zupancic Date: Thu, 24 Apr 2025 14:27:30 -0400 Subject: [PATCH] Added home discovery to arcgis-enterprise esri_properties Replaced current home path substitution with new shellout command to dynamically discover a users home directory - Before, the `esri_properties` module would assume the installing user's home directory was located under `/home/username` - Now, `esri_properties` will discover the home directory via `getent passwd \"#{user}\" | cut -d: -f6 | awk '{printf $0}'` This will accomodate use-cases where the installing user's home directory is not under `/home`. --- .../arcgis-enterprise/libraries/esri_properties.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cookbooks/arcgis-enterprise/libraries/esri_properties.rb b/cookbooks/arcgis-enterprise/libraries/esri_properties.rb index df634e5..cc0013d 100644 --- a/cookbooks/arcgis-enterprise/libraries/esri_properties.rb +++ b/cookbooks/arcgis-enterprise/libraries/esri_properties.rb @@ -19,8 +19,16 @@ module EsriProperties + def self.get_home(user) + cmd = Mixlib::ShellOut.new("getent passwd \"#{user}\" | cut -d: -f6 | awk '{printf $0}'", {:user => user}) + cmd.run_command + return "/home/#{user}" if cmd.error? + + cmd.stdout + end + def self.esri_properties(user, hostname, arcgis_version) - properties_file_path = "/home/#{user}/.ESRI.properties.*.#{arcgis_version}" + properties_file_path = "#{self.get_home(user)}/.ESRI.properties.*.#{arcgis_version}" cmd = Mixlib::ShellOut.new("cat #{properties_file_path}", { :user => user }) cmd.run_command @@ -55,4 +63,4 @@ def self.license_home(user, hostname, arcgis_version) esri_properties[:ARCLICENSEHOME] end -end \ No newline at end of file +end