luci的4个配置文件

参考:https://www.cnblogs.com/mayswind/p/3468124.html

1、/usr/lib/lua/luci/controller/njitclient.lua

module("luci.controller.njitclient", package.seeall)
function index()
        entry({"admin", "network", "njitclient"}, cbi("njitclient"), _("NJIT Client"), 100)
        end

module("luci.controller.控制器名", package.seeall)

function index()
        entry(路径, 调用目标, _("显示名称"), 显示顺序)
        end

2、/etc/config/njitclient
config login
    option username ''
    option password ''
    option ifname 'eth0'
    option domain ''

3、/usr/lib/lua/luci/model/cbi/njitclient.lua
require("luci.sys")

m = Map("njitclient", translate("NJIT Client"), translate("Configure NJIT 802.11x client."))


s = m:section(TypedSection, "login", "")
s.addremove = false
s.anonymous = true

enable = s:option(Flag, "enable", translate("Enable"))
name = s:option(Value, "username", translate("Username"))
pass = s:option(Value, "password", translate("Password"))
pass.password = true
domain = s:option(Value, "domain", translate("Domain"))


ifname = s:option(ListValue, "ifname", translate("Interfaces"))
for k, v in ipairs(luci.sys.net.devices()) do
    if v ~= "lo" then
        ifname:value(v)
    end
end

local apply = luci.http.formvalue("cbi.apply")
if apply then
    io.popen("/etc/init.d/njitclient restart")

end

return m


4、/etc/init.d/njitclient
#!/bin/sh /etc/rc.common
START=50

run_njit()
{
    local enable
    config_get_bool enable $1 enable
    
    if [ $enable ]; then
        local username
        local password
        local domain
        local ifname
        
        config_get username $1 username
        config_get password $1 password
        config_get domain $1 domain
        config_get ifname $1 ifname
        
        if [ "$domain" != "" ]; then
            njit-client $username@$domain $password $ifname &
        else
            njit-client $username $password $ifname &
        fi
        
        echo "NJIT Client has started."
    fi
}


start()
{
    config_load njitclient
    config_foreach run_njit login
}


stop()
{
    killall njit-client
    killall udhcpc
    
    echo "NJIT Client has stoped."
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值