-svc.rmempty = true
-svc:value("")
-svc:value("dyndns.org")
-svc:value("changeip.com")
-svc:value("zoneedit.com")
-svc:value("no-ip.com")
-svc:value("freedns.afraid.org")
-
-s:option(Value, "domain", translate("Hostname")).rmempty = true
-s:option(Value, "username", translate("Username")).rmempty = true
-pw = s:option(Value, "password", translate("Password"))
+svc.rmempty = false
+svc.default = "dyndns.org"
+
+local services = { }
+local fd = io.open("/usr/lib/ddns/services", "r")
+if fd then
+ local ln
+ repeat
+ ln = fd:read("*l")
+ local s = ln and ln:match('^%s*"([^"]+)"')
+ if s then services[#services+1] = s end
+ until not ln
+ fd:close()
+end
+
+local v
+for _, v in luci.util.vspairs(services) do
+ svc:value(v)
+end
+
+function svc.cfgvalue(...)
+ local v = Value.cfgvalue(...)
+ if not v or #v == 0 then
+ return "-"
+ else
+ return v
+ end
+end
+
+function svc.write(self, section, value)
+ if value == "-" then
+ m.uci:delete("ddns", section, self.option)
+ else
+ Value.write(self, section, value)
+ end
+end
+
+svc:value("-", "-- "..translate("custom").." --")
+
+local url = s:option(Value, "update_url", translate("Custom update-URL"))
+url:depends("service_name", "-")
+url.rmempty = true
+
+local hostname = s:option(Value, "domain", translate("Hostname"))
+hostname.rmempty = true
+hostname.default = "mypersonaldomain.dyndns.org"
+hostname.datatype = "host"
+
+local username = s:option(Value, "username", translate("Username"))
+username.rmempty = true
+
+local pw = s:option(Value, "password", translate("Password"))