Class: VagrantPlugins::ProfitBricks::Action::RunInitScript

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-profitbricks/action/run_init_script.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ RunInitScript

Returns a new instance of RunInitScript.



9
10
11
12
# File 'lib/vagrant-profitbricks/action/run_init_script.rb', line 9

def initialize(app, _env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_profitbricks::action::run_init_script')
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-profitbricks/action/run_init_script.rb', line 14

def call(env)
  config           = env[:machine].provider_config
  machine_config   = env[:machine].config
  begin
    communicator = machine_config.vm.communicator ||= :ssh
  rescue NoMethodError
    communicator = :ssh
  end

  # Can we handle Windows config here?
  @app.call(env)
  env[:machine].communicate.sudo config.init_script if config.init_script && communicator == :ssh
end