The first part:
Template way to implement Web page display Hello World, show:
The first step:/usr/lib/lua/luci/controller/admin/system.lua registration options:
Entry ({"admin", "system", "Test-template"}, Template ("Test/hello"), _ ("Test"), 3). Dependent = False
Step Two: Add the appropriate test/hello.htm file in the View directory:
[Email protected]:~# cat/usr/lib/lua/luci/view/test/hello.htm
<%+header%>
<%+footer%>
Step three: After adding the above files, save the login routing background to see the results (sometimes you may need to exit and then log in)
Part II:
The CBI way to implement IP address settings:
The first step:/usr/lib/lua/luci/controller/admin/system.lua registration options:
Entry ({"admin", "system", "TEST-CBI"}, CBI ("Admin_system/test"), _ ("TEST-CBI"), 4). Dependent = False
Step Two:
[Email protected]:~# Cat/usr/lib/lua/luci/model/cbi/admin_system/test.lua
m = Map ("Network", Translate ("Test page by Wayne"), Translate ("On this page we can learn how the. Lua work")
M:chain ("Luci")
s = m:section (typedsection, "Netset", Translate ("Network Configuration"))
S.anonymous = True
S.addremove = True
S:tab ("Wan1", Translate ("Config wan1"))
IPADDR1 = S:taboption ("Wan1", Value, "IPADDR1", Translate ("address"))
Ipaddr1.datatype = "Ip4addr"
Netmask1 = S:taboption ("Wan1", Value, "Netmask1", Translate ("netmask"))
Netmask1.datatype = "Ip4addr"
Netmask1:value ("255.255.255.0")
Netmask1:value ("255.255.0.0")
Netmask1:value ("255.0.0.0")
Gateway1 = S:taboption ("Wan1", Value, "Gateway1", Translate ("gateway"))
Gateway1.datatype = "Ip4addr"
return m
The third step is to add the following after the/etc/config/network file:
Config Netset
After saving login to set the IP address, and then see the changes in the/etc/config/network file, as follows:
Config Netset
Option Ipaddr1 ' 192.168.1.11 '
Option Netmask1 ' 255.255.255.0 '
Option Gateway1 ' 192.168.1.1 '
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
OpenWrt Luci Managed Web Interface Instance