Skip to content
Snippets Groups Projects
Unverified Commit 6884aad7 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-core: simplify 820-dns-config code

parent cd9ee858
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
dnsmasq=uci:get_first("dhcp", "dnsmasq") local dns = site.dns or {}
local next_node = site.next_node or {}
local dnsmasq = uci:get_first("dhcp", "dnsmasq")
uci:set('dhcp', dnsmasq, 'localise_queries', true) uci:set('dhcp', dnsmasq, 'localise_queries', true)
uci:set('dhcp', dnsmasq, 'localservice', false) uci:set('dhcp', dnsmasq, 'localservice', false)
if site.dns and site.dns.servers then uci:set('dhcp', dnsmasq, 'server', dns.servers)
uci:set('dhcp', dnsmasq, 'server', site.dns.servers) uci:set('dhcp', dnsmasq, 'cachesize', dns.cacheentries)
else
uci:delete('dhcp', dnsmasq, 'server')
end
if site.dns and site.dns.cacheentries then if next_node.name and next_node.ip4 then
uci:set('dhcp', dnsmasq, 'cachesize', site.dns.cacheentries) uci:section('dhcp', 'domain', 'nextnode4', {
else name = next_node.name,
uci:delete('dhcp', dnsmasq, 'cachesize') ip = next_node.ip4,
end
if site.next_node and site.next_node.name and site.next_node.ip4 then
uci:section('dhcp','domain','nextnode4',{
name=site.next_node.name,
ip=site.next_node.ip4,
}) })
else else
uci:delete('dhcp', 'domain', 'nextnode4') uci:delete('dhcp', 'domain', 'nextnode4')
end end
if site.next_node and site.next_node.name and site.next_node.ip6 then if next_node.name and next_node.ip6 then
uci:section('dhcp','domain','nextnode6',{ uci:section('dhcp', 'domain', 'nextnode6', {
name=site.next_node.name, name = next_node.name,
ip=site.next_node.ip6, ip = next_node.ip6,
}) })
else else
uci:delete('dhcp', 'domain', 'nextnode6') uci:delete('dhcp', 'domain', 'nextnode6')
end end
uci:save('dhcp')
uci:save('dhcp')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment