Sha256: f6cb556240e34df98a5ba333c2e4fae6c9632df5405d2a590a1b26f928098eb1

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require "log4r"

module VagrantPlugins
  module ManagedServers
    module Action
      class TakeSyncedFolderOwnership
        def initialize(app, _env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_managed_servers::action::take_synced_folder_ownership")
        end

        def call(env)
          take_synced_folder_ownership env[:machine], env[:ui]
          @app.call(env)
        end

        def take_synced_folder_ownership(machine, ui)
          return unless machine.config.orchestrate.take_synced_folder_ownership
          ui.info "Taking ownership of all guest synced folders"

          machine.config.vm.synced_folders.each do |synced_folder|
            name = synced_folder[0]
            options = synced_folder[1]
            next if options[:disabled]
            options[:owner] ||= machine.ssh_info[:username]
            @logger.debug "Taking ownership of #{name}"
            @logger.debug options
            machine.communicate.sudo "chown '#{options[:owner]}' -R #{options[:guestpath]}"
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.8.0.pre.2 lib/vagrant-managed-servers/action/take_synced_folder_ownership.rb