From c580865ab23f9818952881f4b9b4411d75a0f160 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 12 May 2014 23:06:45 -0300 Subject: [PATCH] driver: Fix lxc config customizations prunning [GH-279] --- lib/vagrant-lxc/driver.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 03f80d5..001efd4 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -143,7 +143,7 @@ module Vagrant # Use sed to just strip out the block of code which was inserted by Vagrant @logger.debug 'Prunning vagrant-lxc customizations' contents = config_string - config_string.gsub! /^# VAGRANT-BEGIN(.|\s)*# VAGRANT-END/, '' + contents.gsub! /^# VAGRANT-BEGIN(.|\s)*# VAGRANT-END\n/, '' write_config(contents) end @@ -154,14 +154,11 @@ module Vagrant "lxc.#{key}=#{value}" end customizations.unshift '# VAGRANT-BEGIN' - customizations << '# VAGRANT-END' - contents = config_string + customizations << "# VAGRANT-END\n" + + contents = config_string + contents << customizations.join("\n") - config_file = base_path.join('config').to_s - customizations.each do |line| - contents << line - contents << "\n" - end write_config(contents) end