diff --git a/hooks/update-lxc-configs b/hooks/update-lxc-configs new file mode 100755 index 0000000..5585505 --- /dev/null +++ b/hooks/update-lxc-configs @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +require "pathname" +require_relative "lib/lxc" + +LXC_CONTAINER_ROOT = Pathname.new("/data/containers") + +registry = Lxc::Registry.new +network = registry.data["network"] || {} +network.each do |name, container| + next if container["lxc"] == false + container = Lxc::Container.new(registry.data, + name: name, + ipv4: container["ipv4"], + ipv6: container["ipv6"], + rootfs: LXC_CONTAINER_ROOT.join(name, "rootfs"), + dn42_ipv4: container["dn42_ipv4"], + dn42_ipv6: container["dn42_ipv6"], + group: container["group"], + vars: container["vars"]) + container.write_config(LXC_CONTAINER_ROOT.join(name, "config")) +end