jow wrote:cconn, you would need to override the .write() method of the corresponding option:
m = Map(...)
m:chain("dhcp6c") -- this tells the system that we also may manipulate dhcp6c
...
s = section(...)
...
foo = s:taboption("blah", Flag, ...)
foo.rmempty = false -- means if unchecked, the option is written as "option blah 0" instead of being removed
function foo.write(self, section, value)
-- first do the normal action
Flag.write(self, section, value)
-- now manipulate the foreign options:
m.uci:set("network", "wan", "ipv6", "0")
m.uci:set("dhcp6c", "basic", "enabled", "0")
end
I am almost there. I am a bit confused as how the options are written when checked or unchecked, here is a bit of code;
if has_ipv6 then
ipv6 = s:taboption("ipv6", Flag, "ipv6", translate("Enable IPv6 on PPP link") )
ipv6:depends("proto", "ppp")
ipv6:depends("proto", "pppoa")
ipv6:depends("proto", "pppoe")
ipv6:depends("proto", "pptp")
ipv6:depends("proto", "3g")
ipv6.rmempty = false
function ipv6.write(self, section, value)
Flag.write(self, section, value)
m.uci:set("network", "6rdtun", "rdenabled", "0")
end
end
if has_dhcp6c then
usedhcp6c = s:taboption("ipv6", Flag, "dhcp6c", translate("Enable DHCP-PD client [dh
usedhcp6c.rmempty = false
usedhcp6c:depends("proto", "ppp")
usedhcp6c:depends("proto", "pppoe")
function usedhcp6c.write(self, section, value)
Flag.write(self, section, value)
m.uci:set("network", "wan", "ipv6", "1")
m.uci:set("dhcp6c", "basic", "enabled", "1")
m.uci:set("network", "6rdtun", "rdenabled", "0")
end
end
in essence, if ipv6 is enabled, I want to disable rdenabled on the 6rdtun interface. if usedhcp6c is enabled but ipv6 is not, I want it to enable ipv6 as well.
conversely, if ipv6 gets disabled on the wan, disable usedhcp6c as well by default.
it would be however fine to disable usedhcp6c but leave ipv6 enabled.
and finally, disable ipv6 on wan and usedhcp6c when rdenabled is set to true.
something is missing in my code, if I disable usedhcp6c it just gets re-enabled.
As well, I haven't figured out how to not create a "dhcp6c" option in the 'network' 'wan' 'dhcp6c' and just use whatever is set in 'dhcp6c' 'basic' 'enabled'
where can I read about the syntax of the taboption command, and in general, what the m: and s: represent in luci apps?