|
@@ -22,32 +22,19 @@ local UCI = require "luci.model.uci"
|
22
|
22
|
local SYS = require "luci.sys"
|
23
|
23
|
local UTIL = require "luci.util"
|
24
|
24
|
|
25
|
|
-version_luci_app = "1.0.0" -- luci-application / openwrt Makefile compatible version
|
26
|
|
-version_required = "3.0.22" -- minimum required service version
|
|
25
|
+version_luci_app = "1.0.1" -- luci-application / openwrt Makefile compatible version
|
|
26
|
+version_required = "3.0.22-1" -- minimum required service version
|
27
|
27
|
|
28
|
28
|
function index()
|
29
|
|
- local _service = "privoxy"
|
30
|
|
- local _vermin = "3.0.22"
|
31
|
|
- local _verinst
|
32
|
|
- local _util = require "luci.util"
|
33
|
|
- local _ipkg = require "luci.model.ipkg"
|
34
|
|
- local _info = _ipkg.info(_service)
|
35
|
|
- for _, v in pairs(_info) do
|
36
|
|
- if v.Package == _service and v.Status.installed then
|
37
|
|
- _verinst = v.Version
|
38
|
|
- break
|
39
|
|
- end
|
40
|
|
- end
|
41
|
|
- local _sver = _util.split(_verinst, "[%.%-]", nil, true)
|
42
|
|
- local _rver = _util.split(_vermin , "[%.%-]", nil, true)
|
43
|
|
-
|
44
|
|
- -- check config file and version
|
45
|
|
- if not nixio.fs.access("/etc/config/" .. _service )
|
46
|
|
- or (tonumber(_sver[1]) or 0) < (tonumber(_rver[1]) or 0)
|
47
|
|
- or (tonumber(_sver[2]) or 0) < (tonumber(_rver[2]) or 0)
|
48
|
|
- or (tonumber(_sver[3]) or 0) < (tonumber(_rver[3]) or 0)
|
49
|
|
- or (tonumber(_sver[4]) or 0) < (tonumber(_rver[4]) or 0) then
|
50
|
|
- entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror",
|
|
29
|
+ local _sys = require "luci.sys"
|
|
30
|
+ local _vermin = "3.0.22-1"
|
|
31
|
+ local _verinst = _sys.exec([[opkg list-installed ]] .. "privoxy" .. [[ | awk '{print $3}']])
|
|
32
|
+ local _cmd = [[opkg compare-versions "]] .. _verinst .. [[" ">=" "]] .. _vermin .. [["]]
|
|
33
|
+ local _verok = tonumber(_sys.call(_cmd))
|
|
34
|
+
|
|
35
|
+ -- check config file and version
|
|
36
|
+ if not nixio.fs.access("/etc/config/privoxy") or (_verok == 0) then
|
|
37
|
+ entry( {"admin", "services", "privoxy"}, cbi("privoxy/apperror",
|
51
|
38
|
{hideapplybtn=true, hidesavebtn=true, hideresetbtn=true }), _("Privoxy WEB proxy"), 59)
|
52
|
39
|
else
|
53
|
40
|
entry( {"admin", "services", "privoxy"}, cbi("privoxy/detail"), _("Privoxy WEB proxy"), 59)
|
|
@@ -122,35 +109,6 @@ function get_theme()
|
122
|
109
|
return nil
|
123
|
110
|
end
|
124
|
111
|
|
125
|
|
-function ipkg_version(package)
|
126
|
|
- if not package then
|
127
|
|
- return nil
|
128
|
|
- end
|
129
|
|
- local _info = IPKG.info(package)
|
130
|
|
- local _data = {}
|
131
|
|
- local _version = ""
|
132
|
|
- local i = 0
|
133
|
|
- for k, v in pairs(_info) do
|
134
|
|
- if v.Package == package and v.Status.installed then
|
135
|
|
- _version = v.Version
|
136
|
|
- i = i + 1
|
137
|
|
- end
|
138
|
|
- end
|
139
|
|
- if i > 1 then -- more then one valid record
|
140
|
|
- return _data
|
141
|
|
- end
|
142
|
|
- local _sver = UTIL.split(_version, "[%.%-]", nil, true)
|
143
|
|
- _data = {
|
144
|
|
- version = _version,
|
145
|
|
- major = tonumber(_sver[1]) or 0,
|
146
|
|
- minor = tonumber(_sver[2]) or 0,
|
147
|
|
- patch = tonumber(_sver[3]) or 0,
|
148
|
|
- build = tonumber(_sver[4]) or 0
|
149
|
|
- }
|
150
|
|
- return _data
|
151
|
|
-end
|
152
|
|
-
|
153
|
112
|
-- replacement of build-in Flag.parse of cbi.lua
|
154
|
113
|
-- modified to mark section as changed if value changes
|
155
|
114
|
-- current parse did not do this, but it is done AbstaractValue.parse()
|