Fixed some UCI transition fallout
[project/luci.git] / libs / httpd / host / runluci
1 #!/usr/bin/lua
2 require("luci.httpd")
3 require("luci.httpd.server")
4 require("luci.httpd.handler.file")
5 require("luci.httpd.handler.luci")
6
7 SYSROOT = arg[1]
8 DOCROOT = SYSROOT .. arg[2]
9 PORT = 8080
10
11 collectgarbage("setpause", 150)
12
13 serversocket = luci.httpd.Socket("0.0.0.0", PORT)
14
15 server  = luci.httpd.server.Server()
16 vhost   = luci.httpd.server.VHost()
17
18 server:set_default_vhost(vhost)
19
20 pcall(function()
21         require "uci"
22         require "luci.model.uci".cursor = function(config, save)
23                 return uci.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
24         end
25 end)
26
27 require("luci.sys")
28 luci.sys.user.checkpasswd = function() return true end
29
30
31 filehandler = luci.httpd.handler.file.Simple(DOCROOT)
32 vhost:set_default_handler(filehandler)
33
34 lucihandler = luci.httpd.handler.luci.Luci()
35 vhost:set_handler("/luci", lucihandler)
36
37 io.stderr:write("Starting LuCI HTTPD on port " .. PORT .. "...\n")
38 io.stderr:write("Point your browser to http://localhost:" .. PORT .. "/luci\n")
39
40 --daemon = luci.httpd.Daemon()
41 --daemon.debug = true
42 luci.httpd.register(serversocket, server:create_daemon_handlers())
43 luci.httpd.run()