source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/facter/root_home.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 1.1 KB
Line 
1# A facter fact to determine the root home directory.
2# This varies on PE supported platforms and may be
3# reconfigured by the end user.
4
5module Facter::Util::RootHome
6 class << self
7 def get_root_home
8 root_ent = Facter::Util::Resolution.exec("getent passwd root")
9 # The home directory is the sixth element in the passwd entry
10 # If the platform doesn't have getent, root_ent will be nil and we should
11 # return it straight away.
12 root_ent && root_ent.split(":")[5]
13 end
14 end
15end
16
17Facter.add(:root_home) do
18 setcode { Facter::Util::RootHome.get_root_home }
19end
20
21Facter.add(:root_home) do
22 confine :kernel => :darwin
23 setcode do
24 str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
25 hash = {}
26 str.split("\n").each do |pair|
27 key,value = pair.split(/:/)
28 hash[key] = value
29 end
30 hash['dir'].strip
31 end
32end
33
34Facter.add(:root_home) do
35 confine :kernel => :aix
36 root_home = nil
37 setcode do
38 str = Facter::Util::Resolution.exec("lsuser -c -a home root")
39 str && str.split("\n").each do |line|
40 next if line =~ /^#/
41 root_home = line.split(/:/)[1]
42 end
43 root_home
44 end
45end
Note: See TracBrowser for help on using the repository browser.