diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-14 23:42:50 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-14 23:43:41 +0200 |
commit | 6d7429bf56cc52161ce1932cc13d0594265b4abf (patch) | |
tree | 8cd35796ed106362b131da82fb185fa147dd0895 /target/linux/ramips/base-files | |
parent | b395e3b40e026a437b7179b78f1beddf2d02a7bc (diff) | |
download | mtk-20170518-6d7429bf56cc52161ce1932cc13d0594265b4abf.zip mtk-20170518-6d7429bf56cc52161ce1932cc13d0594265b4abf.tar.gz mtk-20170518-6d7429bf56cc52161ce1932cc13d0594265b4abf.tar.bz2 |
target/linux/ramips: add all base-files changes
Diffstat (limited to 'target/linux/ramips/base-files')
-rw-r--r-- | target/linux/ramips/base-files/etc/config/fstab | 16 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/etc/diag.sh | 5 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/etc/uci-defaults/01_leds (renamed from target/linux/ramips/base-files/etc/board.d/01_leds) | 16 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/etc/uci-defaults/02_network (renamed from target/linux/ramips/base-files/etc/board.d/02_network) | 24 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/lib/ramips.sh | 363 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/lib/upgrade/platform.sh | 6 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/usr/bin/dat2uci | 218 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/usr/lib/lua/shuci.lua | 141 | ||||
-rwxr-xr-x | target/linux/ramips/base-files/usr/sbin/setsmp.sh | 9 |
9 files changed, 453 insertions, 345 deletions
diff --git a/target/linux/ramips/base-files/etc/config/fstab b/target/linux/ramips/base-files/etc/config/fstab new file mode 100644 index 0000000..c984b93 --- /dev/null +++ b/target/linux/ramips/base-files/etc/config/fstab @@ -0,0 +1,16 @@ +config 'global' + option anon_swap '0' + option anon_mount '1' + option auto_swap '1' + option auto_mount '1' + option delay_root '5' + option check_fs '0' + +config 'mount' + option target '/mnt/sd*' + option enabled '1' + +config 'mount' + option target '/mnt/mmcblk*' + option enabled '1' + diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh index 9ad7ccb..74b8867 100755 --- a/target/linux/ramips/base-files/etc/diag.sh +++ b/target/linux/ramips/base-files/etc/diag.sh @@ -73,8 +73,9 @@ get_status_led() { m4) status_led="m4:blue:status" ;; - mlw221) - status_led="kingston:blue:status" + mlw221|\ + mlwg2) + status_led="kingston:blue:system" ;; mofi3500-3gn) status_led="mofi3500-3gn:green:status" diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/uci-defaults/01_leds index 01e2363..5d6ed2b 100755 --- a/target/linux/ramips/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/base-files/etc/uci-defaults/01_leds @@ -1,6 +1,6 @@ #!/bin/sh -. /lib/functions/uci-defaults-new.sh +. /lib/functions/uci-defaults.sh . /lib/ramips.sh set_usb_led() { @@ -11,11 +11,8 @@ set_wifi_led() { ucidef_set_led_netdev "wifi_led" "wifi" "$1" "wlan0" } - board=$(ramips_board_name) -board_config_update - case $board in 3g-6200n) set_wifi_led "edimax:amber:wlan" @@ -116,7 +113,8 @@ case $board in hw550-3g) set_usb_led "hw550-3g:green:usb" ;; - mlw221) + mlw221|\ + mlwg2) set_wifi_led "kingston:blue:wifi" ucidef_set_led_default "system" "system" "kingston:blue:system" "1" ;; @@ -174,15 +172,15 @@ case $board in hg255d) set_wifi_led "hg255d:wlan" set_usb_led "hg255d:usb" - ucidef_set_led_interface "lan" "hg255d:internet" + ucidef_set_led_netdev "eth" "Internet" "hg255d:internet" "eth0.2" ;; wnce2001) set_wifi_led "netgear:green:wlan" ;; rt-n14u) ucidef_set_led_default "power" "power" "asus:blue:power" "1" - ucidef_set_led_interafce "lan" "asus:blue:lan" - ucidef_set_led_netdev "wan" "asus:blue:wan" + ucidef_set_led_netdev "lan" "lan" "asus:blue:lan" "eth0.1" + ucidef_set_led_netdev "wan" "wan" "asus:blue:wan" "eth0.2" set_wifi_led "asus:blue:air" set_usb_led "asus:blue:usb" ;; @@ -214,6 +212,6 @@ case $board in ;; esac -board_config_flush +ucidef_commit_leds exit 0 diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/uci-defaults/02_network index e027b3b..568b91b 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/uci-defaults/02_network @@ -2,7 +2,7 @@ . /lib/functions.sh . /lib/ramips.sh -. /lib/functions/uci-defaults-new.sh +. /lib/functions/uci-defaults.sh . /lib/functions/system.sh ramips_setup_rt3x5x_vlans() @@ -55,7 +55,7 @@ ramips_setup_interfaces() ucidef_set_interface_lan "eth0.2" ;; - wizard8800 | \ + mlwg2 | \ wl-330n | \ wmr300) ucidef_set_interface_lan "eth0.1" @@ -197,7 +197,12 @@ ramips_setup_interfaces() wli-tx4-ag300n) ucidef_set_interface_lan "eth0" ;; - + MT7620 | MT7628 | MT7688) + ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2" + ;; + MT7621 | MT7623) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ;; *) RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"` if [ -n "${RT3X5X}" ]; then @@ -287,6 +292,10 @@ ramips_setup_macs() wnce2001) wan_mac=$(mtd_get_mac_binary factory 46) ;; + #MT7620 | MT7621 | MT7623 | MT7628 | MT7688) + # lan_mac=$(eth_mac r lan) + # wan_mac=$(eth_mac r wan) + # ;; *) lan_mac=$(cat /sys/class/net/eth0/address) @@ -299,10 +308,15 @@ ramips_setup_macs() [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac } -board_config_update +[ -e /etc/config/network ] && exit 0 + +touch /etc/config/network + board=$(ramips_board_name) + ramips_setup_interfaces $board ramips_setup_macs $board -board_config_flush + +uci commit network exit 0 diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index bb42ace..64de7eb 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -9,338 +9,31 @@ RAMIPS_MODEL= ramips_board_detect() { local machine local name - - machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo) - - case "$machine" in - *"7Links PX-4885") - name="px4885" - ;; - *"8devices Carambola") - name="carambola" - ;; - *"Edimax 3g-6200n") - name="3g-6200n" - ;; - *"Edimax 3g-6200nl") - name="3g-6200nl" - ;; - *"Airlink101 AR725W") - name="ar725w" - ;; - *"AirLive Air3GII") - name="air3gii" - ;; - *"Edimax BR-6425") - name="br6425" - ;; - *"Allnet ALL0239-3G") - name="all0239-3g" - ;; - *"Allnet ALL0256N") - name="all0256n" - ;; - *"Allnet ALL5002") - name="all5002" - ;; - *"Allnet ALL5003") - name="all5003" - ;; - *"ARC FreeStation5") - name="freestation5" - ;; - *"Argus ATP-52B") - name="argus-atp52b" - ;; - *"AsiaRF AWM002 EVB") - name="awm002-evb" - ;; - *"AsiaRF AWM003 EVB") - name="awm003-evb" - ;; - *"AsiaRF AWAPN2403") - name="awapn2403" - ;; - *"Asus WL-330N") - name="wl-330n" - ;; - *"Asus WL-330N3G") - name="wl-330n3g" - ;; - *"Alpha ASL26555") - name="asl26555" - ;; - *"Aztech HW550-3G") - name="hw550-3g" - ;; - *"CY-SWR1100") - name="cy-swr1100" - ;; - *"DCS-930") - name="dcs-930" - ;; - *"DIR-300 B1") - name="dir-300-b1" - ;; - *"DIR-300 B7") - name="dir-300-b7" - ;; - *"DIR-320 B1") - name="dir-320-b1" - ;; - *"DIR-600 B1") - name="dir-600-b1" - ;; - *"DIR-600 B2") - name="dir-600-b2" - ;; - *"DIR-610 A1") - name="dir-610-a1" - ;; - *"DIR-620 A1") - name="dir-620-a1" - ;; - *"DIR-620 D1") - name="dir-620-d1" - ;; - *"DIR-615 H1") - name="dir-615-h1" - ;; - *"DIR-615 D") - name="dir-615-d" - ;; - *"DIR-645") - name="dir-645" - ;; - *"DIR-810L") - name="dir-810l" - ;; - *"DAP-1350") - name="dap-1350" - ;; - *"ESR-9753") - name="esr-9753" - ;; - *"EASYACC WI-STOR WIZARD 8800") - name="wizard8800" - ;; - *"Edimax BR-6475nD") - name="br-6475nd" - ;; - *"F7C027") - name="f7c027" - ;; - *"F5D8235 v1") - name="f5d8235-v1" - ;; - *"F5D8235 v2") - name="f5d8235-v2" - ;; - *"Hauppauge Broadway") - name="broadway" - ;; - *"Huawei D105") - name="d105" - ;; - *"La Fonera 2.0N") - name="fonera20n" - ;; - *"Asus RT-N14U") - name="rt-n14u" - ;; - *"Asus RT-N13U") - name="rt-n13u" - ;; - *"MoFi Network MOFI3500-3GN") - name="mofi3500-3gn" - ;; - *"HILINK HLK-RM04") - name="hlk-rm04" - ;; - *"HAME MPR-A1") - name="mpr-a1" - ;; - *"HAME MPR-A2") - name="mpr-a2" - ;; - *"Kingston MLW221") - name="mlw221" - ;; - *"Planex MZK-750DHP") - name="mzk-750dhp" - ;; - *"NBG-419N") - name="nbg-419n" - ;; - *"Netgear WNCE2001") - name="wnce2001" - ;; - *"NexAira BC2") - name="bc2" - ;; - *"NW718") - name="nw718" - ;; - *"Omnima EMB HPM") - name="omni-emb-hpm" - ;; - *"Omnima MiniEMBWiFi") - name="omni-emb" - ;; - *"Omnima MiniPlug") - name="omni-plug" - ;; - *"Petatel PSR-680W"*) - name="psr-680w" - ;; - *"Planex MZK-W300NH2"*) - name="mzk-w300nh2" - ;; - *"Poray IP2202") - name="ip2202" - ;; - *"Poray M3") - name="m3" - ;; - *"Poray M4") - name="m4" - ;; - *"Poray X5") - name="x5" - ;; - *"Poray X8") - name="x8" - ;; - *"PWH2004") - name="pwh2004" - ;; - *"Asus RP-N53") - name="rp-n53" - ;; - *"RT-G32 B1") - name="rt-g32-b1" - ;; - *"RT-N10+") - name="rt-n10-plus" - ;; - *"RT-N15") - name="rt-n15" - ;; - *"RT-N56U") - name="rt-n56u" - ;; - *"RUT5XX") - name="rut5xx" - ;; - *"Skyline SL-R7205"*) - name="sl-r7205" - ;; - *"Sparklan WCR-150GN") - name="wcr-150gn" - ;; - *"V22RW-2X2") - name="v22rw-2x2" - ;; - *"VoCore") - name="vocore" - ;; - *"W502U") - name="w502u" - ;; - *"WMR-300") - name="wmr300" - ;; - *"WHR-300HP2") - name="whr-300hp2" - ;; - *"WHR-600D") - name="whr-600d" - ;; - *"WHR-1166D") - name="whr-1166d" - ;; - *"WHR-G300N") - name="whr-g300n" - ;; - *"Sitecom WL-341 v3") - name="wl341v3" - ;; - *"Sitecom WL-351 v1 002") - name="wl-351" - ;; - *"Tenda 3G300M") - name="3g300m" - ;; - *"Tenda W306R V2.0") - name="w306r-v20" - ;; - *"Tenda W150M") - name="w150m" - ;; - *"TEW-691GR") - name="tew-691gr" - ;; - *"TEW-692GR") - name="tew-692gr" - ;; - *"Ralink V11ST-FE") - name="v11st-fe" - ;; - *"WLI-TX4-AG300N") - name="wli-tx4-ag300n" - ;; - *"WZR-AGL300NH") - name="wzr-agl300nh" - ;; - *"WR512-3GN-like router") - name="wr512-3gn" - ;; - *"UR-326N4G Wireless N router") - name="ur-326n4g" - ;; - *"UR-336UN Wireless N router") - name="ur-336un" - ;; - *"AWB WR6202") - name="wr6202" - ;; - *"XDX RN502J") - name="xdxrn502j" - ;; - *"HG255D") - name="hg255d" - ;; - *"V22SG") - name="v22sg" - ;; - *"WRTNODE") - name="wrtnode" - ;; - *"Wansview NCS601W") - name="ncs601w" - ;; - *"Sercomm NA930") - name="na930" - ;; - *"Zbtlink ZBT-WA05") - name="zbt-wa05" - ;; - *"ZBT WR8305RT") - name="wr8305rt" - ;; - *"Lenovo Y1") - name="y1" - ;; - *"Lenovo Y1S") - name="y1s" - ;; - *) - name="generic" - ;; + machine=$(cat /proc/cpuinfo | grep -i MT76) + case $machine in + *"MT7620"*) + name="MT7620" + ;; + *"MT7621"*) + name="MT7621" + ;; + *"MT7628"*) + name="MT7628" + ;; + *"MT7688"*) + name="MT7688" + ;; + *"MT7623"*) + name="MT7623" + ;; + *) # actually this is *NOT* acceptable. + name="generic" + ;; esac [ -z "$RAMIPS_BOARD_NAME" ] && RAMIPS_BOARD_NAME="$name" - [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="$machine" + # FIXME: define customer models here + [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="mtk-apsoc-demo" [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" @@ -356,3 +49,15 @@ ramips_board_name() { echo "$name" } + + +ramips_model_name() { + local name + + [ -f /tmp/sysinfo/model ] && name=$(cat /tmp/sysinfo/model) + [ -z "$name" ] && name="unknown" + + echo "$name" +} + + diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index 407c218..3a286c0 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -14,6 +14,11 @@ platform_check_image() { [ "$#" -gt 1 ] && return 1 case "$board" in + MT7620 | \ + MT7621 | \ + MT7628 | \ + MT7688 | \ + MT7623 | \ 3g-6200n | \ 3g-6200nl | \ 3g300m | \ @@ -56,6 +61,7 @@ platform_check_image() { m3 | \ m4 | \ mlw221 | \ + mlwg2 | \ mofi3500-3gn | \ mpr-a1 | \ mpr-a2 | \ diff --git a/target/linux/ramips/base-files/usr/bin/dat2uci b/target/linux/ramips/base-files/usr/bin/dat2uci new file mode 100755 index 0000000..88cb695 --- /dev/null +++ b/target/linux/ramips/base-files/usr/bin/dat2uci @@ -0,0 +1,218 @@ +#!/usr/bin/env lua + +--[[ + * A tool to translate ralink driver config (*.dat) into OpenWrt + * UCI files (/etc/config/wireless). + * --- Hua Shao <nossiac@163.com> + * + * For UCI: http://wiki.openwrt.org/doc/techref/uci + * http://wiki.openwrt.org/doc/uci + * + * Copyright (C) 2015 Mediatek CO.,LTD. All rights reserved. + * +]] + +require "shuci" + +T={} + +if #arg < 1 then + io.stderr:write("usage: dat2uci <datfile> [ucifile] \n") + return false +end + +local i,j = string.find(arg[1], ".dat") +if i then + datfile = arg[1] + ucifile = arg[2] or "/etc/config/wireless" +else + ucifile = arg[1] + datfile = arg[2] +end +print("ucifile="..ucifile) +print("datfile="..datfile) + +_,_,device = string.find(datfile, "(%w+).dat") +print("device="..device) + +local _2g_name = {"7601","7602","7603","7620","7623","7628","7688"} +for i=1, #_2g_name do + if string.find(device, _2g_name[i]) then band = "2.4G" break else band = "5G" end +end + +print("band="..band) + + +for line in io.lines(datfile) do + -- print(line) + i,j = string.find(line, "([^%s])") + if i and j then + ch = string.sub(line,i,j) + + if ch == "#" then + -- print("<comment> "..line) + else + _,_,k,v = string.find(line, "%s*([%w_]+)%s*=%s*([^#]*)%s*") + if k then + -- print("<k-v> ",k,v) + local t = {} + T[k] = v + end + end + end +end + +uci = UCI:new() +uci:load(ucifile) + + +--[[ Device related configurations ]] + + +uci:set("wifi-device", device) +uci:set(device, "type", device) +uci:set(device, "vendor", "ralink") +uci:set(device, "band", band) + +if T.AutoChannelSelect ~= 0 then + uci:set(device, "channel", "0") + uci:set(device, "autoch", T.AutoChannelSelect or "nil") +else + uci:set(device, "channel", T.Channel or "nil") + uci:set(device, "autoch", "0") +end +uci:set(device, "radio", T.RadioOn or "nil") +uci:set(device, "wifimode", T.WirelessMode or "nil") +-- bandwidth +if T.BW == 1 and T.VHT_BW == 1 then + uci:set(device, "bw", "2") +elseif T.BW == 0 and T.VHT_BW == 0 then + uci:set(device, "bw", "0") +else + uci:set(device, "bw", "1") +end +uci:set(device, "country", T.CountryCode or "TW") +uci:set(device, "region", T.CountryRegion or "1") +uci:set(device, "bgprotect", T.BGProtection or "0") +uci:set(device, "beacon", T.BeaconPeriod or "100") +uci:set(device, "dtim", T.DtimPeriod or "1") +uci:set(device, "fragthres", T.FragThreshold or "2346") +uci:set(device, "rtsthres", T.RTSThreshold or "2347") +uci:set(device, "txpower", T.TxPower or "100") +uci:set(device, "txpreamble", T.TxPreamble or "0") +uci:set(device, "shortslot", T.ShortSlot or "1") +uci:set(device, "txburst", T.TxBurst or "1") +uci:set(device, "pktaggre", T.PktAggregate or "0") +uci:set(device, "ieee80211h", T.IEEE80211H or "0") +uci:set(device, "ht_bsscoexist", T.HT_BSSCoexistence or "0") +uci:set(device, "ht_extcha", T.HT_EXTCHA or "0") +uci:set(device, "ht_opmode", T.HT_OpMode or "0") +uci:set(device, "ht_gi", T.HT_GI or "1") +uci:set(device, "ht_rdg", T.HT_RDG or "0") +uci:set(device, "ht_stbc", T.HT_STBC or "0") +uci:set(device, "ht_amsdu", T.HT_AMSDU or "0") +uci:set(device, "ht_autoba", T.HT_AutoBA or "1") +uci:set(device, "ht_badec", T.HT_BADecline or "0") +uci:set(device, "ht_distkip", T.HT_DisallowTKIP or "0") +uci:set(device, "ht_ldpc", T.HT_LDPC or "1") +uci:set(device, "ht_txstream", T.HT_TxStream or "1") +uci:set(device, "ht_txstream", T.HT_RxStream or "1") +if band == "5G" then + uci:set(device, "aregion", T.CountryRegionABand or "7") -- 5G + uci:set(device, "vht_stbc", T.VHT_STBC or "0") -- 5G + uci:set(device, "vht_sgi", T.VHT_SGI or "1") -- 5G + uci:set(device, "vht_bw_sig", T.VHT_BW_SIGNAL or "0") -- 5G + uci:set(device, "vht_ldpc", T.VHT_LDPC or "1") -- 5G + uci:set(device, "vht_disnonvht", T.VHT_DisallowNonVHT or "0") -- 5G +end + +--uci:dump() +--[[ Interface related configurations. ]] + +function split(inputstr, delimiter) + if delimiter == nil then + delimiter = "%s" + end + local t={} ; i=1 + for str in string.gmatch(inputstr, "([^"..delimiter.."]+)") do + t[i] = str + i = i + 1 + end + return t +end + + +local i = 0 -- index of wifi-iface +local j = 0 -- index of wifi-iface with give devname + +while j < tonumber(T.BssidNum) do + if not uci:get("wifi-iface["..i.."]", "device") then + if band == "2.4G" then + uci:set("wifi-iface["..i.."]", "ra"..j) + uci:set("wifi-iface["..i.."]", "ifname", "ra"..j) + else + uci:set("wifi-iface["..i.."]", "rai"..j) + uci:set("wifi-iface["..i.."]", "ifname", "rai"..j) + end + uci:set("wifi-iface["..i.."]", "device", device) + end + if device == uci:get("wifi-iface["..i.."]", "device") then + uci:set("wifi-iface["..i.."]", "ssid", loadstring("return T.SSID"..(j+1))()) + uci:set("wifi-iface["..i.."]", "hidden", T.HideSSID or "0") + -- openwrt specific + uci:set("wifi-iface["..i.."]", "mode", "ap") + uci:set("wifi-iface["..i.."]", "network", "lan") + + -- encryption + authmode = split(T.AuthMode, ";") + if authmode[j+1] == "OPEN" then + uci:set("wifi-iface["..i.."]", "encryption", "none") + elseif authmode[j+1] == "WPAPSK" then + uci:set("wifi-iface["..i.."]", "encryption", "psk") + uci:set("wifi-iface["..i.."]", "key", loadstring("return T.WPAPSK"..(j+1))()) + elseif authmode[j+1] == "WPA2PSK" then + uci:set("wifi-iface["..i.."]", "encryption", "psk2") + uci:set("wifi-iface["..i.."]", "key", loadstring("return T.WPAPSK"..(j+1))()) + elseif authmode[j+1] == "WPA" then + uci:set("wifi-iface["..i.."]", "encryption", "wpa") + elseif authmode[j+1] == "WPA2" then + uci:set("wifi-iface["..i.."]", "encryption", "wpa2") + elseif authmode[j+1] == "WPA1WPA2" then + uci:set("wifi-iface["..i.."]", "encryption", "wpa+wpa2") + else + uci:set("wifi-iface["..i.."]", "encryption", "open") + end + + -- cipher + --[[ + cipher = split(T.EncrypType, ";") + if authmode[j+1] == "OPEN" then + uci:set("wifi-iface["..i.."]", "cipher", "none") + elseif cipher[j+1] == "AES" then + uci:set("wifi-iface["..i.."]", "cipher", "ccmp") + elseif cipher[j+1] == "TKIP" then + uci:set("wifi-iface["..i.."]", "cipher", "tkip") + elseif cipher[j+1] == "TKIPAES" then + uci:set("wifi-iface["..i.."]", "cipher", "tkip+ccmp") + else + uci:set("wifi-iface["..i.."]", "cipher", "none") + end ]] + + --uci:set("wifi-iface["..i.."]", "wepkey", "xx") + if T.IEEE8021X == 1 then + uci:set("wifi-iface["..i.."]", "auth_server", T.RADIUS_Server or "nil") + uci:set("wifi-iface["..i.."]", "auth_port", T.RADIUS_Port or "nil") + uci:set("wifi-iface["..i.."]", "auth_secret", "xx") + end + --uci:set("wifi-iface["..i.."]", "pmkcacheperiod", T.PMKCachePeriod or "nil") + --uci:set("wifi-iface["..i.."]", "preauth", T.PreAuth or "nil") + --uci:set("wifi-iface["..i.."]", "rekeyinteval", T.RekeyInterval or "nil") + j = j + 1 + end + i = i + 1 +end + +--uci:dump() +uci:save(ucifile) + +return true diff --git a/target/linux/ramips/base-files/usr/lib/lua/shuci.lua b/target/linux/ramips/base-files/usr/lib/lua/shuci.lua new file mode 100755 index 0000000..1b0109f --- /dev/null +++ b/target/linux/ramips/base-files/usr/lib/lua/shuci.lua @@ -0,0 +1,141 @@ +#!/usr/bin/env lua + +--[[ + * A pure lua library to translate between: + * lua table <--> uci config + * + * For UCI: http://wiki.openwrt.org/doc/techref/uci + * http://wiki.openwrt.org/doc/uci + * + * Copyright (C) 2015 Hua Shao <nossiac@163.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +]] + + +local shuci = {} + +function shuci.decode(path) + function file_exists(name) + local f=io.open(name,"r") + if f~=nil then io.close(f) return true else return false end + end + local function linebreaker(str) + local i,_ = string.find(str, "([^%s])") + if not i then return nil end + if string.find(str, "config%s+%w+") then + local i,j,k,v = string.find(str, "config%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)") + return "section", k, v + elseif string.find(str, "option%s+%w+") then + local i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]") + if not k or not v then + i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)") + end + return "option", k, v + elseif string.find(str, "list%s+%w+") then + local i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]") + if not k or not v then + i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)") + end + return "list", k, v + end + end + + if not file_exists(path) then + return + end + + local _sect_ = nil + local t = {} + for line in io.lines(path) do + local _type, _name, _value = linebreaker(line) + if _type == "section" then + if not t[_name] then + t[_name] = {} + _sect_ = t[_name] + if _value then + _sect_[".name"] = _value + end + else + if t[_name][1] then -- already a list + else -- upgrade from dict to array + local _t = t[_name] + t[_name] = {} + t[_name][1] = _t + end + t[_name][#t[_name]+1] = {} + _sect_ = t[_name][#t[_name]] + if _value then + _sect_[".name"] = _value + end + end + end + if _type == "option" then + if _name and _value then + _sect_[_name] = _value + end + end + if _type == "list" and _name and _value then + local idx + if not _sect_[_name] then + _sect_[_name] = {} + _sect_[_name][1] = _value + else + idx = #_sect_[_name] + _sect_[_name][idx+1] = _value + end + end + end + + return t +end + + +function shuci.encode(t, path) + local dump = io.write + if path then + local fp = io.open(path, "w") + dump = function(str) fp:write(str) end + end + for stype,ss in pairs(t) do + if #ss > 0 then + for _,s in ipairs(ss) do + dump(string.format("config\t%s\t'%s'\n", stype, s[".name"] or "")) + for k,v in pairs(s) do + if type(v) == "table" then + for _,vv in ipairs(v) do + dump(string.format("\tlist\t%s\t'%s'\n",k,vv)) + end + elseif type(v) == "string" and k ~= ".name" then + dump(string.format("\toption\t%s\t'%s'\n",k,v)) + elseif type(v) == "number" and k ~= ".name" then + dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v))) + end + end + dump("\n") + end + else + dump(string.format("config\t%s\t'%s'\n", stype, ss[".name"] or "")) + for k,v in pairs(ss) do + if type(v) == "table" then + for _,vv in ipairs(v) do + dump(string.format("\tlist\t%s\t'%s'\n",k,vv)) + end + elseif type(v) == "string" and k ~= ".name" then + dump(string.format("\toption\t%s\t'%s'\n",k,v)) + elseif type(v) == "number" and k ~= ".name" then + dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v))) + end + end + end + end +end + +return shuci diff --git a/target/linux/ramips/base-files/usr/sbin/setsmp.sh b/target/linux/ramips/base-files/usr/sbin/setsmp.sh new file mode 100755 index 0000000..71a7699 --- /dev/null +++ b/target/linux/ramips/base-files/usr/sbin/setsmp.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -e /tmp/smb.flag ]; +then + smp.sh storage +else + smp.sh wifi +fi + |