Sha256: 3549240452cc642e3538e3903daca06d55c47f67a2802764463fa13304ec2aaa

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module VagrantPlugins
  module SshConfig
    module Action
      class UpdateConfig

        def initialize(app, env)
          @app = app
          @env = env
        end

        def call(env)
          @app.call(env)
          @env[:ui].info "[vagrant-ssh-config] Updating SSH config..."
          config = `vagrant ssh-config #{@env[:machine].name} --host #{ENV["VAGRANT_SSH_ALIAS"]}`
          File.write("#{@env[:env].local_data_path}/ssh-config", config)
          line = "Include #{@env[:env].local_data_path}/ssh-config"
          file = "#{@env[:env].home_path}/ssh-configs"
          if File.exist?(file)
            if ! File.foreach(file).grep(/#{line}/).any?
              File.open(file, "a+") { |f| f.puts(line) }
            end
          else
            File.write(file, line)
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-ssh-config-0.0.1 lib/vagrant-ssh-config/Action/UpdateConfig.rb