Skip to content

Commit

Permalink
Add support for setting domain for the cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
G10h4ck committed Aug 7, 2016
1 parent 64f0657 commit ca022d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/lime-system/files/etc/config/lime-defaults
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

config lime system
option hostname 'LiMe-%M4%M5%M6'
option domain 'lan'

config lime network
option primary_interface eth0
Expand Down
1 change: 1 addition & 0 deletions packages/lime-system/files/etc/config/lime-example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

config lime system
option hostname 'LiMeNode-%M4%M5%M6' # Parametrizable with %Mn
option domain 'lan' # DNS domain for the L2 cloud it could be something like mycloud.mynetwork.tld, hosts that get their IP by DHCP will also get a fully qualified domain name like hostname.mycloud.mynetwork.tld


### Network general option
Expand Down
16 changes: 12 additions & 4 deletions packages/lime-system/files/usr/lib/lua/lime/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ function network.setup_rp_filter()
end

function network.setup_dns()
local content = {}
for _,server in pairs(config.get("network", "resolvers")) do
table.insert(content, server)
local cloudDomain = config.get("system", "domain")
local resolvers = config.get("network", "resolvers")

local function setup_dnsmasq(s)
uci:set("dhcp", s[".name"], "domain", cloudDomain)
uci:set("dhcp", s[".name"], "local", "/"..cloudDomain.."/")
uci:set("dhcp", s[".name"], "expandhosts", "1")
uci:set("dhcp", s[".name"], "domainneeded", "1")
uci:set("dhcp", s[".name"], "server", resolvers)
end

local uci = libuci:cursor()
uci:foreach("dhcp", "dnsmasq", function(s) uci:set("dhcp", s[".name"], "server", content) end)
uci:foreach("dhcp", "dnsmasq", setup_dnsmasq)
uci:set("dhcp", "lan", "leasetime", "1h")
uci:save("dhcp")

fs.writefile("/etc/dnsmasq.conf", "conf-dir=/etc/dnsmasq.d\n")
fs.mkdir("/etc/dnsmasq.d")
end
Expand Down

0 comments on commit ca022d1

Please sign in to comment.