Apply host-UVL
[project/luci.git] / libs / httpd / host / runluci
index b82efce..bc56f15 100755 (executable)
@@ -1,22 +1,37 @@
-#!/usr/bin/lua
+#!/usr/bin/env lua
 require("luci.httpd")
 require("luci.httpd.server")
 require("luci.httpd.handler.file")
 require("luci.httpd.handler.luci")
 
-DOCROOT = arg[1]
+SYSROOT = arg[1]
+DOCROOT = SYSROOT .. arg[2]
 PORT = 8080
 
 collectgarbage("setpause", 150)
 
 serversocket = luci.httpd.Socket("0.0.0.0", PORT)
 
-
 server  = luci.httpd.server.Server()
 vhost   = luci.httpd.server.VHost()
 
 server:set_default_vhost(vhost)
 
+pcall(function()
+       require "uci"
+       require "luci.model.uci".cursor = function(config, save)
+               return uci.cursor(config or SYSROOT .. "/etc/config", save or SYSROOT .. "/tmp/.uci")
+       end
+
+       local x = require "luci.uvl".UVL.__init__
+       require "luci.uvl".UVL.__init__ = function(self, schemedir)
+               x(self, schemedir or SYSROOT .. "/lib/uci/schema")
+       end
+end)
+
+require("luci.sys")
+luci.sys.user.checkpasswd = function() return true end
+
 
 filehandler = luci.httpd.handler.file.Simple(DOCROOT)
 vhost:set_default_handler(filehandler)
@@ -27,7 +42,7 @@ vhost:set_handler("/luci", lucihandler)
 io.stderr:write("Starting LuCI HTTPD on port " .. PORT .. "...\n")
 io.stderr:write("Point your browser to http://localhost:" .. PORT .. "/luci\n")
 
-daemon = luci.httpd.Daemon()
+--daemon = luci.httpd.Daemon()
 --daemon.debug = true
-daemon:register(serversocket, server:create_daemon_handlers())
-daemon:run()
+luci.httpd.register(serversocket, server:create_daemon_handlers())
+luci.httpd.run()