Rework LuCI build system
[project/luci.git] / applications / luci-app-ddns / luasrc / model / cbi / ddns / hints.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local CTRL = require "luci.controller.ddns" -- this application's controller
16 local DISP = require "luci.dispatcher"
17 local SYS = require "luci.sys"
18 local DDNS = require "luci.tools.ddns" -- ddns multiused functions
19
20 -- check supported options -- ##################################################
21 -- saved to local vars here because doing multiple os calls slow down the system
22 has_ssl = DDNS.check_ssl() -- HTTPS support
23 has_proxy = DDNS.check_proxy() -- Proxy support
24 has_dnstcp = DDNS.check_bind_host() -- DNS TCP support
25 need_update = CTRL.update_needed() -- correct ddns-scripts version
26
27 -- html constants
28 font_red = [[<font color="red">]]
29 font_off = [[</font>]]
30 bold_on = [[<strong>]]
31 bold_off = [[</strong>]]
32
33 -- cbi-map definition -- #######################################################
34 m = Map("ddns")
35
36 -- first need to close <a> from cbi map template our <a> closed by template
37 m.title = [[</a><a href="]] .. DISP.build_url("admin", "services", "ddns") .. [[">]] ..
38 translate("Dynamic DNS")
39
40 m.description = translate("Dynamic DNS allows that your router can be reached with " ..
41 "a fixed hostname while having a dynamically changing " ..
42 "IP address.")
43
44 m.redirect = DISP.build_url("admin", "services", "ddns")
45
46 -- SimpleSection definition -- #################################################
47 -- show Hints to optimize installation and script usage
48 s = m:section( SimpleSection,
49 translate("Hints"),
50 translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
51
52 -- ddns_scripts needs to be updated for full functionality
53 if need_update then
54 local dv = s:option(DummyValue, "_update_needed")
55 dv.titleref = DISP.build_url("admin", "system", "packages")
56 dv.rawhtml = true
57 dv.title = font_red .. bold_on ..
58 translate("Software update required") .. bold_off .. font_off
59 dv.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") ..
60 "<br />" ..
61 translate("Please update to the current version!")
62 end
63
64 -- DDNS Service disabled
65 if not SYS.init.enabled("ddns") then
66 local dv = s:option(DummyValue, "_not_enabled")
67 dv.titleref = DISP.build_url("admin", "system", "startup")
68 dv.rawhtml = true
69 dv.title = bold_on ..
70 translate("DDNS Autostart disabled") .. bold_off
71 dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "<br />" ..
72 "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" )
73 end
74
75 -- No IPv6 support
76 if not DDNS.check_ipv6() then
77 local dv = s:option(DummyValue, "_no_ipv6")
78 dv.titleref = 'http://www.openwrt.org" target="_blank'
79 dv.rawhtml = true
80 dv.title = bold_on ..
81 translate("IPv6 not supported") .. bold_off
82 dv.value = translate("IPv6 is currently not (fully) supported by this system" .. "<br />" ..
83 "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "<br />" ..
84 "or update your system to the latest OpenWrt Release")
85 end
86
87 -- No HTTPS support
88 if not has_ssl then
89 local dv = s:option(DummyValue, "_no_https")
90 dv.titleref = DISP.build_url("admin", "system", "packages")
91 dv.rawhtml = true
92 dv.title = bold_on ..
93 translate("HTTPS not supported") .. bold_off
94 dv.value = translate("Neither GNU Wget with SSL nor cURL installed to support updates via HTTPS protocol.") ..
95 "<br />- " ..
96 translate("You should install GNU Wget with SSL (prefered) or cURL package.") ..
97 "<br />- " ..
98 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
99 end
100
101 -- cURL without proxy support
102 if has_ssl and not has_proxy then
103 local dv = s:option(DummyValue, "_no_proxy")
104 dv.titleref = DISP.build_url("admin", "system", "packages")
105 dv.rawhtml = true
106 dv.title = bold_on ..
107 translate("cURL without Proxy Support") .. bold_off
108 dv.value = translate("cURL is installed, but libcurl was compiled without proxy support.") ..
109 "<br />- " ..
110 translate("You should install GNU Wget with SSL or replace libcurl.") ..
111 "<br />- " ..
112 translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.")
113 end
114
115 -- "Force IP Version not supported"
116 if not (has_ssl and has_dnstcp) then
117 local dv = s:option(DummyValue, "_no_force_ip")
118 dv.titleref = DISP.build_url("admin", "system", "packages")
119 dv.rawhtml = true
120 dv.title = bold_on ..
121 translate("Force IP Version not supported") .. bold_off
122 local value = translate("BusyBox's nslookup and Wget do not support to specify " ..
123 "the IP version to use for communication with DDNS Provider.")
124 if not has_ssl then
125 value = value .. "<br />- " ..
126 translate("You should install GNU Wget with SSL (prefered) or cURL package.")
127 end
128 if not has_dnstcp then
129 value = value .. "<br />- " ..
130 translate("You should install BIND host package for DNS requests.")
131 end
132 dv.value = value
133 end
134
135 -- "DNS requests via TCP not supported"
136 if not has_dnstcp then
137 local dv = s:option(DummyValue, "_no_dnstcp")
138 dv.titleref = DISP.build_url("admin", "system", "packages")
139 dv.rawhtml = true
140 dv.title = bold_on ..
141 translate("DNS requests via TCP not supported") .. bold_off
142 dv.value = translate("BusyBox's nslookup does not support to specify to use TCP instead of default UDP when requesting DNS server") ..
143 "<br />- " ..
144 translate("You should install BIND host package for DNS requests.")
145 end
146
147 return m