OpenWrt Luci Web Manager Add a new menu (iii)

Source: Internet
Author: User
Tags lua

Following the previous two articles: OpenWrt Luci Web Manager Add New menu and OpenWrt Luci Web Manager Add new menu (ii)


This extension is to implement a login interface, and the login interface to parse the input content into a configuration file


Step One:

To modify the /usr/lib/lua/luci/model/cbi/admin_myapp/Cbi_tab.lua file:

--Copyright fulinux <[email protected]>--Licensed to the public under the Apache License 2.0.m = Map ("Login", Translate ("Login client"), translate ("Please fill out the form below")) s = m:section (typedsection, "Login", "part login O f the form ") S.addremove = falses.anonymous = Trueenable = S:option (Flag," Enable ", Translate (" Enable ")) name = S:option (Val UE, "username", translate ("username")) pass = S:option (Value, "password", Translate ("password")) Pass.password = Truedomain = S:option (Value, "Domain", "Interfaces"); ifname = S:option (ListValue, "ifname", Translate ("Domain")) for K, V-ipairs (luci.sys.net.devices ()) do        if v ~= "Lo" Then                ifname:value (v)        Endends.optional=false;s.rmempty = false;local apply = Luci.http.formvalue ("cbi.apply" If Apply then        luci.sys.exec ("/etc/init.d/login start") Endreturn m

Step Two:Modify the/etc/config/login configuration file (the file formerly known as Cbi_file) with the following contents:
Config login        option username ' fulinux ' option        enable ' option        domain ' option        ifname '        option Password "

Step Three:Add the/etc/init.d/login script file with the following content:
#!/bin/sh/etc/rc.commonstart=14run_copyconfig () {        Local enable        Config_get_bool enable enable        if [$ Enable]; Then                local username                local password local                domain                local ifname                config_get username $ username                Config_get Password $ password                config_get domain domain                config_get ifname $ ifname                echo $username > /var/run/testfile.conf                echo $password >>/var/run/testfile.conf                echo $domain >>/var/run/ Testfile.conf                echo $ifname >>/var/run/testfile.conf                echo "Testfile has started."        Fi}start () {        config_load login        config_foreach run_copyconfig Login}

Works Show:1. Web interface:

2. configuration file:

3. Generated configuration file:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

OpenWrt Luci Web Manager Add a new menu (iii)

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.