OpenWrt Luci Managed Web Interface Instance

Source: Internet
Author: User
Tags lua

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.