• 搜索
  • 夜间模式
    ©2015-2025  Ethan's Blog Theme by OneBlog
    搜索
    标签
    # Amule # Gargoyle # LUCI # VIM # Python # Nginx # 反代 # Ansible # Apache # LNMP
  • 首页>
  • Openwrt>
  • 正文
  • 石像鬼+LUCI双界面实现

    2018年03月14日 36 阅读 0 评论 3082 字

    编辑文件

    vim /feeds/luci/modules/luci-mod-admin-full/luasrc/controller/admin/index.lua

    自行对比文件不同

    -- Copyright 2008 Steven Barth <steven@midlink.org>
    -- Licensed to the public under the Apache License 2.0.
     
    module("luci.controller.admin.index", package.seeall)
     
    function index()
        local root = node()
        if not root.target then
            root.target = alias("admin")
            root.index = true
        end
     
        local page   = node("admin")
        page.target  = firstchild()
        page.title   = _("Administration")
        page.order   = 10
        page.sysauth = "root"
        page.sysauth_authenticator = "htmlauth"
        page.ucidata = true
        page.index = true
     
        -- Empty services menu to be populated by addons
        entry({"admin", "services"}, firstchild(), _("Services"), 40).index = true
        
        entry({"admin", "switchUI"}, call("switch_ui"), _("石像鬼luci"), 89)
     
        entry({"admin", "logout"}, call("action_logout"), _("Logout"), 90)
    end
     
    function action_logout()
        local dsp = require "luci.dispatcher"
        local utl = require "luci.util"
        local sid = dsp.context.authsession
     
        if sid then
            utl.ubus("session", "destroy", { ubus_rpc_session = sid })
     
            dsp.context.urltoken.stok = nil
     
            luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
                sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
            })
        end
     
        luci.http.redirect(luci.dispatcher.build_url())
    end
     
    function switch_ui()
        luci.http.redirect("/login.sh")
    end

    石像鬼UI添加Luci跳转菜单:
    假设你的石像鬼 源码都在家目录下
    修改文件

    vim ~/gargoyle/package/gargoyle/files/etc/config/gargoyle
    config display display
    #在下面添加
    option luci 'Luci'
    
    config scripts scrips
    #在下面添加
    option luci 'cgi-bin/luci
    
    config 500 logout
    #在下面新建
    config 600 luci

    这样只是多了一个菜单,我们需要切换到Op的源码目录,然后更新下源码

    cd ./downloaded/chaos_calmer-e6fbf31/
    ./scripts/feeds update luci
    ./scripts/feeds install luci

    这样可以将luci的代码整合到固件里面,在编译的时候才会出现luci的菜单让你选择。
    需要注意的是不要使用以下命令,不然会出现自己的三方包编译的时候可能会出现不可知的错误,比如package冲突

    ./scripts/feeds {update,installl} -a

    如果要加入自己的三方包,将包放到op源码的package目录下,比如我自己的包都放在chaos_calmer-e6fbf31/package/custom目录下,这些包编译时需要用到的一些库也一起放到里面,避免和石像鬼的包冲突。
    编译后左侧菜单即有Luci菜单

    说几个编译参数:

    make FULL_BUILD=true BUILD_THREADS=3 cusom

    FULL_BUILD=true代表全新编译,会将之前编译的缓存全部删除,耗时久 false代表使用上一次的配置及文件编译,编译较快。
    BUILD_THREADS=3代表使用3个线程编译,与CPU核心数挂钩,比如你的CPU为8核,可以使用7个或者8个线程同时编译,可以大大加快编译速度,但是这样编译如果出错排错的时候就不大好找。
    custom代表自定义,你可以自行选择要编译进去的软件包,及调整各项参数。如果使用默认的值,比如ar71xx,那么会使用源码默认的config文件进行编译,所有软件包都是预先定义好的,不可更改。
    如果要进行内核参数调整,那么你需要进入到custom-src目录下运行make kernel_menuconfig命令调整保存后在此目录下进行编译。

    附上两个补丁:点击下载Patch

    解压后gargoyle.patch放到石像鬼源码根目录,执行

    patch -p0 < gargoyle.patch

    index.lua.patch放到openwrt的源码目录,比如10.0.x的目录为~/gargoyle/downloaded/15.05-216adcf/,然后执行

    patch -p0 < index.lua.patch

    即可

    本文著作权归作者 [ Ethan ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    GargoyleLUCI
    — END —
    Copyright©2015-2025  All Rights Reserved.  Load:0.007 s
    Theme by OneBlog V3.6.3
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。