lib/dev-lxc/container.rb in dev-lxc-1.4.0 vs lib/dev-lxc/container.rb in dev-lxc-1.5.0
- old
+ new
@@ -45,26 +45,25 @@
def sync_mounts(mounts)
existing_mounts = self.config_item("lxc.mount.entry")
unless existing_mounts.nil?
preserved_mounts = existing_mounts.delete_if { |m| m.end_with?("## dev-lxc ##") }
- # self.clear_config_item('lxc.mount.entries') doesn't work as of liblxc 1.1.2 and at least up to 1.1.5-0ubuntu3~ubuntu15.04.1~ppa1
- DevLXC.search_file_delete_line(self.config_file_name, /^lxc.mount.entry/)
- self.clear_config
- self.load_config
+ self.clear_config_item('lxc.mount.entry')
self.set_config_item("lxc.mount.entry", preserved_mounts)
end
- mounts.each do |mount|
- unless File.exists?(mount.split.first)
- puts "ERROR: Mount source #{mount.split.first} does not exist."
- exit 1
- end
- if ! preserved_mounts.nil? && preserved_mounts.any? { |m| m.start_with?("#{mount} ") }
- puts "Skipping mount entry #{mount}, it already exists"
- next
- else
- puts "Adding mount entry #{mount}"
- self.set_config_item("lxc.mount.entry", "#{mount} none bind,optional,create=dir 0 0 ## dev-lxc ##")
+ unless mounts.nil?
+ mounts.each do |mount|
+ unless File.exists?(mount.split.first)
+ puts "ERROR: Mount source #{mount.split.first} does not exist."
+ exit 1
+ end
+ if ! preserved_mounts.nil? && preserved_mounts.any? { |m| m.start_with?("#{mount} ") }
+ puts "Skipping mount entry #{mount}, it already exists"
+ next
+ else
+ puts "Adding mount entry #{mount}"
+ self.set_config_item("lxc.mount.entry", "#{mount} none bind,optional,create=dir 0 0 ## dev-lxc ##")
+ end
end
end
self.save_config
end