lxc-config/hooks/cleanup-lxc-config
2015-08-05 15:33:37 +00:00

21 lines
375 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "lib/lxc"
registry = Lxc::Registry.new
containers = `lxc-ls -1`.split(/\n/)
modified = false
network = registry.data["network"] || {}
network.each do |host, value|
unless containers.include?(host) or value["lxc"] == false
network.delete(host)
modified = true
end
end
if modified
registry.save
else
puts "Unchanged"
end