From 3751eecfac836f455b900acfa10f05211a4b9d6e Mon Sep 17 00:00:00 2001 From: bravo-kernel Date: Mon, 23 Mar 2015 00:21:30 +0100 Subject: [PATCH 1/2] Adds customization_script key for specifying path to user bash script --- .cakebox/Vagrantfile.rb | 25 +++++++++++++++++-------- Cakebox.yaml.default | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.cakebox/Vagrantfile.rb b/.cakebox/Vagrantfile.rb index d5a7155..b723d95 100644 --- a/.cakebox/Vagrantfile.rb +++ b/.cakebox/Vagrantfile.rb @@ -17,7 +17,10 @@ def Cakebox.configure(config, user_settings) if user_settings == false user_settings = Hash.new end - # Deep merge user settings found in Cakebox.yaml without plugin dependency + + # Deep merge user settings found in Cakebox.yaml. Uses the Vagrant Util + # class to prevent a Vagrant plugin dependency + our custom 'compact' Hash + # cleaner class to prevent non-DRY checking per setting. settings = Vagrant::Util::DeepMerge.deep_merge(settings, user_settings.compact!) # Determine Cakebox Dashboard protocol only once @@ -259,13 +262,19 @@ def Cakebox.configure(config, user_settings) end end - # Upload and run user created post-install bash script if it is found to - # support fully re-provisionable non-standard user box customizations. - if File.exists?('Cakebox.sh') - config.vm.provision "file", source: "Cakebox.sh", destination: "/home/vagrant/.cakebox/last-known-cakebox.sh" - config.vm.provision "shell" do |s| - s.privileged = false - s.inline = "bash /home/vagrant/.cakebox/last-known-cakebox.sh" + # Upload and run user created customization bash script (if found) to allow + # the user to create fully re-provisionable box customizations. + unless settings['customization_script'].nil? + if ( settings['customization_script'] =~ /^~/ ) + settings['customization_script'] = settings['customization_script'].sub(/^~/, Dir.home) + end + + if File.exists?(settings['customization_script']) + config.vm.provision "file", source: settings['customization_script'], destination: "/home/vagrant/.cakebox/last-known-customization-script.sh" + config.vm.provision "shell" do |s| + s.privileged = false + s.inline = "bash /home/vagrant/.cakebox/last-known-customization-script.sh" + end end end diff --git a/Cakebox.yaml.default b/Cakebox.yaml.default index 7d06555..0232cf4 100644 --- a/Cakebox.yaml.default +++ b/Cakebox.yaml.default @@ -35,3 +35,5 @@ sites: databases: software: + +customization_script: From a1f967984bfab6681adc51d92a73d9036157310d Mon Sep 17 00:00:00 2001 From: bravo-kernel Date: Mon, 23 Mar 2015 09:07:29 +0100 Subject: [PATCH 2/2] Renames key to user_script --- .cakebox/Vagrantfile.rb | 12 ++++++------ Cakebox.yaml.default | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.cakebox/Vagrantfile.rb b/.cakebox/Vagrantfile.rb index b723d95..8656898 100644 --- a/.cakebox/Vagrantfile.rb +++ b/.cakebox/Vagrantfile.rb @@ -264,16 +264,16 @@ def Cakebox.configure(config, user_settings) # Upload and run user created customization bash script (if found) to allow # the user to create fully re-provisionable box customizations. - unless settings['customization_script'].nil? - if ( settings['customization_script'] =~ /^~/ ) - settings['customization_script'] = settings['customization_script'].sub(/^~/, Dir.home) + unless settings['user_script'].nil? + if ( settings['user_script'] =~ /^~/ ) + settings['user_script'] = settings['user_script'].sub(/^~/, Dir.home) end - if File.exists?(settings['customization_script']) - config.vm.provision "file", source: settings['customization_script'], destination: "/home/vagrant/.cakebox/last-known-customization-script.sh" + if File.exists?(settings['user_script']) + config.vm.provision "file", source: settings['user_script'], destination: "/home/vagrant/.cakebox/last-known-user-script.sh" config.vm.provision "shell" do |s| s.privileged = false - s.inline = "bash /home/vagrant/.cakebox/last-known-customization-script.sh" + s.inline = "bash /home/vagrant/.cakebox/last-known-user-script.sh" end end end diff --git a/Cakebox.yaml.default b/Cakebox.yaml.default index 0232cf4..2de8523 100644 --- a/Cakebox.yaml.default +++ b/Cakebox.yaml.default @@ -36,4 +36,4 @@ databases: software: -customization_script: +user_script: