Method: Puppetize::Controler#initialize

Defined in:
lib/puppetize/puppetize.rb

#initializeControler

Returns a new instance of Controler.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/puppetize/puppetize.rb', line 6

def initialize

  # Check distribution dependency
  puts "\nSorry, Distribution not supported, only redhat based at the moment \n\n" unless File.exist?('/etc/redhat-release') 

  # Verify necessary commands are installed:

  commands = ['puppet','git']

  commands.each do |command|

    begin

      test = ENV['PATH'].split(':').map do |folder| 
        File.exists?(File.join(folder,command)) 
      end

      if ! test.include? true 
        puts "ERROR - #{command} is not installed or not available on default path"
        exit 1
      end

    rescue => e

      STDERR.puts "ERROR - #{e}"
      exit 1

    end

  end

  # Create config dir if it doesn't exists:
  @config_dir = File.join(File.expand_path('~'),'.puppetize')
  @module_dir = File.join(File.expand_path('~'),'puppetize-module')
  @rpm_db = File.join(@config_dir,'rpmlist.db')
  @trackdirs = [
    { 
    :path => '/etc',
    :ignoredir => [
      'group',
      'gshadow',
      'ld.so.cache',
      'passwd',
      'shadow',
      'group-',
      'gshadow-',
      'passwd-',
      'shadow-',
      'rc.d' 
      ]
    }
  ]

  FileUtils.mkdir @config_dir if Dir.glob(@config_dir).empty?

end