花了大概有两个月时间,完成了Tomato Phoenix不死鸟UI部分的移植,系统采用的是lede,httpd采用的是uhttpd,cgi的语言采用的是lua,并没有基于luci而是从零开始编写的一套自由框架,文章后面有部分cgi的代码实现供网友研究。测试版系统会在近期发布。
BusyBox v1.25.1 () built-in shell (ash)
_________
/ /\ _ ___ ___ ___
/ LE / \ | | | __| \| __|
/ DE / \ | |__| _|| |) | _|
/________/ LE \ |____|___|___/|___| lede-project.org
\ \ DE /
\ LE \ / -----------------------------------------------------------
\ DE \ / Reboot (17.01-SNAPSHOT, r3473-a5822db)
\________\/ -----------------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@LEDE:~#
很多网友对lua底层实现代码感兴趣,所以我公布几个cgi的代码片段,供大家学习.
config-mac.lua -> 用户获取wan和lan的mac地址
#!/usr/bin/lua local webio = require("webio") local header = require("header") local uci = require("uci") local x = uci.cursor() header.send_header(200, nil, "text/javascript", 0) webio.puts("\nnvram = {\n") webio.printf("\tmac_lan:'%s'", x:get("network", "wan_dev", "macaddr")) webio.printf(",\n\tmac_wan:'%s'", x:get("network", "lan_dev", "macaddr")) webio.puts("};\n");
apply-mac.lua -> 用户保存wan,lan的mac地址并生效
#!/usr/bin/lua local cgi = require("cgi") local webio = require("webio") local header = require("header") local uci = require("uci") local x = uci.cursor() local args = cgi.get_uri_args() header.send_header(200, nil, "text/javascript", 0) webio.printf("@msg:重启过程中,网络会中断") local mac_lan = string.match(args["mac_lan"], "([a-fA-F0-9:]+)") if mac_lan then x:set("network", "lan_dev", "macaddr", mac_lan) end mac_wan = string.match(args["mac_wan"], "([a-fA-F0-9:]+)") if mac_wan then x:set("network", "wan_dev", "macaddr", mac_wan) end x:save("network") x:commit("network") os.execute("/etc/init.d/network restart&")