lib/dev-lxc/container.rb in dev-lxc-0.2.2 vs lib/dev-lxc/container.rb in dev-lxc-0.2.3
- old
+ new
@@ -27,12 +27,15 @@
puts "Destroying container #{self.name}"
super
end
def sync_mounts(mounts)
- preserved_mounts = self.config_item("lxc.mount.entry").delete_if { |m| m.end_with?("## dev-lxc ##") }
- self.clear_config_item('lxc.mount.entries')
- self.set_config_item("lxc.mount.entry", preserved_mounts)
+ existing_mounts = self.config_item("lxc.mount.entry")
+ if existing_mounts.is_a?(Array)
+ preserved_mounts = existing_mounts.delete_if { |m| m.end_with?("## dev-lxc ##") }
+ self.clear_config_item('lxc.mount.entries')
+ self.set_config_item("lxc.mount.entry", preserved_mounts)
+ end
mounts.each do |mount|
raise "Mount source #{mount.split.first} does not exist." unless File.exists?(mount.split.first)
puts "Adding mount entry #{mount}"
self.set_config_item("lxc.mount.entry", "#{mount} none bind,optional,create=dir 0 0 ## dev-lxc ##")
end