From a8cf5deee205d51d91959a305af1b217090047c8 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 2 Mar 2013 16:47:44 -0300 Subject: [PATCH] Add middleware to run after create script on vagrant up --- lib/vagrant-lxc/action.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index 45483b7..513acf9 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -78,6 +78,7 @@ module Vagrant end end b.use action_start + b.use AfterCreate end end @@ -155,8 +156,18 @@ module Vagrant class Create < BaseAction def call(env) - machine_id = env[:machine].provider.container.create(env[:machine].box.metadata) - env[:machine].id = machine_id + machine_id = env[:machine].provider.container.create(env[:machine].box.metadata) + env[:machine].id = machine_id + env[:just_created] = true + @app.call env + end + end + + class AfterCreate < BaseAction + def call(env) + if env[:just_created] && (script = env[:machine].box.metadata['after-create-script']) + env[:machine].provider.container.run_after_create_script script + end @app.call env end end