diff --git a/lib/vagrant-lxc/action/handle_box_metadata.rb b/lib/vagrant-lxc/action/handle_box_metadata.rb index 5a1ca81..f6784c8 100644 --- a/lib/vagrant-lxc/action/handle_box_metadata.rb +++ b/lib/vagrant-lxc/action/handle_box_metadata.rb @@ -17,9 +17,14 @@ module Vagrant metadata = box.metadata template_name = metadata['template-name'] + after_create = metadata['after-create-script'] ? + box.directory.join(metadata['after-create-script']).to_s : + nil + metadata.merge!( - 'template-name' => "vagrant-#{box.name}-#{template_name}", - 'tar-cache' => box.directory.join(metadata['tar-cache']).to_s + 'template-name' => "vagrant-#{box.name}-#{template_name}", + 'tar-cache' => box.directory.join(metadata['tar-cache']).to_s, + 'after-create-script' => after_create ) # Prepends "lxc-" to the template file so that `lxc-create` is able to find it diff --git a/spec/unit/action/handle_box_metadata_spec.rb b/spec/unit/action/handle_box_metadata_spec.rb index 384479e..afb2ec7 100644 --- a/spec/unit/action/handle_box_metadata_spec.rb +++ b/spec/unit/action/handle_box_metadata_spec.rb @@ -5,7 +5,8 @@ require 'vagrant-lxc/action/handle_box_metadata' describe Vagrant::LXC::Action::HandleBoxMetadata do let(:tar_cache) { 'template.zip' } let(:template_name) { 'ubuntu-lts' } - let(:metadata) { {'template-name' => template_name, 'tar-cache' => tar_cache} } + let(:after_create) { 'setup-vagrant-user.sh' } + let(:metadata) { {'template-name' => template_name, 'tar-cache' => tar_cache, 'after-create-script' => after_create} } let(:box) { mock(:box, name: 'box-name', metadata: metadata, directory: Pathname.new('/path/to/box')) } let(:machine) { mock(:machine, box: box) } let(:app) { mock(:app, call: true) } @@ -22,6 +23,10 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do metadata['tar-cache'].should == "#{box.directory.to_s}/#{tar_cache}" end + it 'prepends box directory to after-create-script' do + metadata['after-create-script'].should == "#{box.directory.to_s}/#{after_create}" + end + it 'prepends vagrant and box name to template-name' do metadata['template-name'].should == "vagrant-#{box.name}-#{template_name}" end