Sha256: 68a20f7f4e4077436d8dc0cf08642b93766d710c541351e79e2a56de9fb9046b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "log4r"

module VagrantPlugins
  module ShellCommander
    # Action for shell command hooking
    class Action
      include Vagrant::Action::Builtin

      # Constructor
      #
      # @param app [Action] Next middleware to call
      # @param env [Hash] Action environment
      # @return nil
      #
      def initialize(app, env)
        @app       = app
        @env       = env
        @logger    = Log4r::Logger.new("vagrant::plugins::shell-commander::action")
      end
      
      # Call method of this middleware
      #
      # @param env [Hash] Action environment
      # @return nil
      #
      def call(env)
        @logger.debug("hook fired for action #{@env[:action_name]}, machine_action: #{@env[:machine_action]}")
        @app.call(env)
        if @env[:machine] && @env[:machine].state.id != :poweroff &&
           ! @env[:machine].config.sh.after_share_folders.nil?
          @env[:machine].action(:ssh_run, 
                                ssh_run_command: @env[:machine].config.sh.after_share_folders,
                                ssh_opts: {extra_args: []})
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-shell-commander-0.3.2 lib/vagrant-shell-commander/action.rb