From 0dd1b20053a35ce6ee9ef92152e01eb33cf341df Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 11 Feb 2014 23:53:07 -0200 Subject: [PATCH] `chmod` /tmp/vagrant-cache on guest VM to 777 to work around some permission issues as explained on GH-74 --- lib/vagrant-cachier/action/install_buckets.rb | 9 ++++++++- lib/vagrant-cachier/hooks.rb | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-cachier/action/install_buckets.rb b/lib/vagrant-cachier/action/install_buckets.rb index bb3adfd..96f83ef 100644 --- a/lib/vagrant-cachier/action/install_buckets.rb +++ b/lib/vagrant-cachier/action/install_buckets.rb @@ -4,17 +4,24 @@ module VagrantPlugins module Cachier class Action class InstallBuckets - def initialize(app, env) + def initialize(app, env, opts = {}) @app = app @logger = Log4r::Logger.new("vagrant::cachier::action::clean") + @opts = opts end def call(env) @app.call(env) + chmod_bucket_root(env[:machine]) if @opts[:chmod] configure_cache_buckets(env) end + def chmod_bucket_root(machine) + @logger.info "'chmod'ing bucket root dir to 777..." + machine.communicate.sudo 'chmod 777 /tmp/vagrant-cache' + end + def configure_cache_buckets(env) return unless env[:machine].config.cache.enabled? diff --git a/lib/vagrant-cachier/hooks.rb b/lib/vagrant-cachier/hooks.rb index 7030dd8..c2c235f 100644 --- a/lib/vagrant-cachier/hooks.rb +++ b/lib/vagrant-cachier/hooks.rb @@ -7,7 +7,7 @@ module VagrantPlugins hook.before Vagrant::Action::Builtin::Provision, Action::ConfigureBucketRoot # This will do the initial buckets installation - hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets + hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets, chmod: true end # This ensure buckets are reconfigured after provisioners runs