build: emulate nixio.sysinfo() on Darwin
[project/luci.git] / build / setup.lua
1 local SYSROOT = os.getenv("LUCI_SYSROOT")
2
3 -- override uci access
4 local uci_core = require "uci"
5 local uci_model = require "luci.model.uci"
6
7 uci_model.cursor = function(config, save)
8 return uci_core.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
9 end
10
11 uci_model.cursor_state = function()
12 return uci_core.cursor(SYSROOT .. "/etc/config", SYSROOT .. "/var/state")
13 end
14
15 uci_model.inst = uci_model.cursor()
16 uci_model.inst_state = uci_model.cursor_state()
17
18 -- override uvl access
19 local uvl_model = require "luci.uvl"
20 local uvl_init = uvl_model.UVL.__init__
21
22 uvl_model.UVL.__init__ = function(self, schemedir)
23 uvl_init(self, schemedir or SYSROOT .. "/lib/uci/schema")
24 end
25
26 -- allow any password in local sdk
27 local sys = require "luci.sys"
28 sys.user.checkpasswd = function() return true end
29
30 -- dummy sysinfo on Darwin
31 require "nixio"
32
33 if not nixio.sysinfo then
34 function nixio.sysinfo()
35 return {
36 bufferram = 0,
37 freehigh = 0,
38 freeram = 0,
39 freeswap = 0,
40 loads = { 0.0, 0.0, 0.0 },
41 mem_unit = 1024,
42 procs = 0,
43 sharedram = 0,
44 totalhigh = 0
45 }
46 end
47 end