summaryrefslogtreecommitdiffhomepage
path: root/build/setup.lua
blob: 7888d23eca0b58bc46dffcba77d2dd1e7fa37364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local SYSROOT = os.getenv("LUCI_SYSROOT")

-- override uci access
local uci_core  = require "uci"
local uci_model = require "luci.model.uci"

uci_model.cursor = function(config, save)
	return uci_core.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
end

uci_model.cursor_state = function()
	return uci_core.cursor(SYSROOT .. "/etc/config", SYSROOT .. "/var/state")
end

uci_model.inst = uci_model.cursor()
uci_model.inst_state = uci_model.cursor_state()

-- allow any password in local sdk
local sys = require "luci.sys"
sys.user.checkpasswd = function() return true end

-- dummy sysinfo on Darwin
require "nixio"

if not nixio.sysinfo then
	function nixio.sysinfo()
		return {
			bufferram = 0,
			freehigh = 0,
			freeram = 0,
			freeswap = 0,
			loads = { 0.0, 0.0, 0.0 },
			mem_unit = 1024,
			procs = 0,
			sharedram = 0,
			totalhigh = 0
		}
	end
end