Class: VagrantPlugins::SimpleCloud::Actions::ModifyProvisionPath
- Inherits:
-
Object
- Object
- VagrantPlugins::SimpleCloud::Actions::ModifyProvisionPath
- Defined in:
- lib/vagrant-simplecloud/actions/modify_provision_path.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ModifyProvisionPath
constructor
A new instance of ModifyProvisionPath.
Constructor Details
#initialize(app, env) ⇒ ModifyProvisionPath
Returns a new instance of ModifyProvisionPath.
5 6 7 8 9 10 |
# File 'lib/vagrant-simplecloud/actions/modify_provision_path.rb', line 5 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::simplecloud::modify_provision_path') end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-simplecloud/actions/modify_provision_path.rb', line 12 def call(env) # check if provisioning is enabled enabled = true enabled = env[:provision_enabled] if env.has_key?(:provision_enabled) return @app.call(env) if !enabled username = @machine.ssh_info()[:username] # change ownership of the provisioning path recursively to the # ssh user # # TODO submit patch to vagrant to set appropriate permissions # based on ssh username @machine.config.vm.provisioners.each do |provisioner| cfg = provisioner.config path = cfg.upload_path if cfg.respond_to? :upload_path path = cfg.provisioning_path if cfg.respond_to? :provisioning_path @machine.communicate.sudo("chown -R #{username} #{path}", :error_check => false) end @app.call(env) end |