OpenWrt Web Management Luci Interface modification

Source: Internet
Author: User
Tags php language lua

I've never heard of OpenWrt and Luci before, and I've only touched the simple PHP language. Due to work reasons, to modify the next Luci interface, it took me 2 days to simply understand the use of Luci. Here is a simple to share with you. (On contact 2 days, I was rookie level, master directly skipped it) we found that there is something wrong and I say everyone together to learn. I mainly want to modify the content of the next Open Background interface page.

Specific how to install has been introduced by someone, I will not say in detail. Here's how to modify the UI after the configuration is done

Enter in Browser: HTTP://192.168.1.1/will automatically jump to Http://192.168.1.1/cgi-bin/luci login The default root password is empty

The default number of first-level menus are in the modules\admin-full\luasrc\controller\admin\ directory

This is similar to the root directory of PHP. /etc/config/the file under this directory, the personal view is that it can be viewed as a database connection in PHP, which makes it easier to understand.

In fact, the Luci interface provides a very full, we do not have much need to create new pages, most of us are in the existing interface to add some content. For example, our company now needs to add both the isolate and Maxassoc properties of WiFi. Let me find it for a while.

The first thing to do is to find the network-wifi corresponding file,

Look for the file that corresponds to the click Edit Page.

Network.lua This file defines what level two directories are under the network.

For example, I want to change the WiFi, I see there is

If Has_wifi and has_wifi.size > 0 Then page = entry ({"admin", "Network", "Wireless"}, Arcombine ("Admin_network /wifi_overview "), CBI (" Admin_network/wifi ")), _ (" WiFi "), * Page.leaf = True Page.subindex = True

This has the CBI ("Admin_network/wifi") statement. Know the people know, do not know also does not matter, want to know can check it yourself.

At this point we can find a Wifi.lua file below the directory \modules\admin-full\luasrc\model\cbi\admin_network\, and the CBI statement is the one pointing to the file. After we open Wifi.lua, ——————— in ———————-Interface – this place adds

Isolate = S:taboption ("Advanced", Flag, "isolate", translate ("Separate clients"), translate ("Prevents client-to-client Communication "))

MAXASSOC = S:taboption ("Advanced", Value, "Maxassoc", Translate ("Connection limi"), translate ("specifies the maximum Number of clients to connect. "))

So two statements are all right. Enter Network-wifi edit to see the effect we have modified

After we enter Network-wifi, select a wireless network and click Edit to enter the page

Under the interface configuration below the advanced settings can be modified and then click Save & Apply

Where do you save these two items? Just now I said, the/etc/config/directory is equivalent to the function of the database.

At this point we vi/etc/config/wireless to see what we have just modified.

You can see that it has been modified to the 77 we just adjusted.

Some people want to add new pages and features, you can look at the following content.

The following content is derived from Chaochaoblog

It takes two things to complete a new module and use it inside.

First we find Usr/lib/lua/luci/controller in the inside to create a folder, that is, our module name, called Smustar Bar

Write the main file of our module under Smustar, it's called Smumodule.lua.

Refer to the official website, our module should be the same way

Module ("LuCI.controller.smustar.smumodule", Package.seeall)

Function index ()
Entry ({"admin", "Network", "802.1x"}, CBI ("Smustar-smumodule/netifaces"), "network Interfaces", +). Dependent=false
End

The first sentence is to declare this module, there is nothing to say.

The second sentence is the main function of our module, which is to tell it our entrance, rather than the entrance, rather than tell it is to be admin login to use, is in the network this menu, name, called 802.1x. The module executes the program in Smustar-smumodule/netifaces here.

All right, everybody's depressed. Smustar-smumodule/netifaces is what, this is we want to build another file, above not say to two

We found the path/usr/lib/lua/luci/module.

Create a folder below Smustar-smmodule create a file Netfaces.lua

OK next is to write our program in Netfaces.lua, refer to the official website that what Luci the coolest place, that is, modify the config file

Do not say you do not understand what is the config file, the simplest such as the network.

Let's set up a configuration file under/etc/config called Smuset.

So this is how a config file is written.

Config ' interface ' Smustar '

Option ' user ' ' Youruser '
Option ' Pass ' ' Yourpass '

OK, this config file is like this. then write Netfaces.lua.

m = Map ("Smuset", "Smustar")-we want to edit the UCI config File/etc/config/smustar here is the file we want to configure, the default path it has been able to distinguish, no tube
s = m:section (typedsection, "interface", "Smustar")-especially the "interface"-sections read out the interface area inside
S.addremove = true-allow The user to create and remove the interfaces

S:option (Value, "User", "Youruser") This can be an input box that reads the user item in the Smuset. Youruser is the tip of the language Luo

Key=s:option (Value, "Pass", "Your password")

Key.password=true; Password input box set to asterisk

Return M-returns the Map
Okay, the file is done, and then we go into the Luci configuration interface.

You can see the 802.1X option under the network

After entering the account and password input box after changing

save&apply, found the password has been modified. Our 802.1X configuration interface is ready!

This article by http://www.wifidog.pro/2015/07/30/openwrt-luci%E4%BF%AE%E6%94%B9.html compilation, reprint please indicate the source

OpenWrt Web Management Luci Interface modification

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.