1、

1.1 打开 /barrier_breaker/package/base-files/files/etc/init.d

加入 disable_sta_mode_wifi_interfaces

#!/bin/sh /etc/rc.common 

START= # just before network start 

disable_sta_mode_wifi_interface() {
local section="$1"
config_get mode $section 'mode'
config_get ssid $section 'ssid'
config_get disabled $section 'disabled' #获取的是uci中的内容,如果uci中没有才获取配置文件
if [ sta == $mode ] ; then
if [ -eq $disabled ] || [ -z $disabled ] ; then #判断disabled是否为0或为空
logger -s -t fqrouter disable sta mode wifi interface $ssid
uci_set wireless $section disabled
else
subvar="no_need_sta"
echo "$subvar" > /tmp/temp.txt #不加目录不知存在什么地方
logger -s -t fqrouter does not need to open sta mode
exit
fi
fi
} start() {
config_load 'wireless'
config_foreach disable_sta_mode_wifi_interface 'wifi-iface'
uci_commit
logger -s -t fqrouter all sta mode wifi interfaces disabled
}

注意:(1)、其中包含两个条件的判断语句要这样写

if [ 0 -eq $disabled ] || [ -z $disabled ] ; then

if [[ 0 -eq $disabled || -z $disabled ]] ; then

注意中括号要和里面的内容要有空格隔开。

(2)、赋值语句要这样写

subvar="no_need_sta"

等号两边不能有空格

1.2 设置权限为775

2、

2.1 打开 /barrier_breaker/package/base-files/files/etc/hotplug.d/net

加入00-only-enable-connectable-sta-mode-wifi-interface

if [ -f /tmp/skip-only-enable-connectable-sta-mode-wifi-interface ] ; then
logger -s -t fqrouter skip-only-enable-connectable-sta-mode-wifi-interface found
return
fi if [ "remove" == "$ACTION" -a "wlan0" == "$INTERFACE" ] ; then #先remove sta模式的wifi,会禁用上级wifi
/etc/init.d/disable_sta_mode_wifi_interfaces start
fi
if [ "add" == "$ACTION" -a "wlan0" == "$INTERFACE" ] ; then #再搜索是否存在上级wifi,存在则添加
read pvar < /tmp/temp.txt
if [ "no_need_sta" == "$pvar" ] ; then
logger -s -t fqrouter exit sta mode success
rm /tmp/temp.txt
exit
else
logger -s -t fqrouter try to bring up sta mode wifi interface # try to bring up sta mode wifi interface为打印出来的内容
sta-mode-wifi-interface-up & #在后台运行
fi
fi

3.2 设置权限为664

3、

3.1 打开 barrier_breaker/package/base-files/files/sbin

加入 sta-mode-wifi-interface-up

#!/usr/bin/lua
require 'uci'
--require 'dumper'
require 'nixio'
x = uci.cursor() --move by tingpan
local pid_file = io.open('/tmp/sta-mode-wifi-interface-up.pid', 'r') --添加文件时,打开该文件
if pid_file ~= nil then --如果存在
local that_pid = pid_file:read('*a') --读取所有内容
io.close(pid_file) --关闭
os.execute('logger -s -t fqrouter sta-mode-wifi-interface-up that pid is: ' .. that_pid) --1有执行
local cmdline_file = io.open('/proc/' .. that_pid .. '/cmdline', 'r') --打开
if cmdline_file ~= nil then
io.close(cmdline_file)
os.execute('logger -s -t fqrouter sta-mode-wifi-interface-up found another instance ' .. that_pid) --2有执行,下次会继续执行到该处
x:set('wireless', 'cfg053579', 'disabled', ) --add by tingpan 恢复配置的初始值,为下次作准备。
x:commit('wireless')
os.exit()
end
end
local this_pid = nixio.getpid() --获取pid
os.execute('echo -n ' .. this_pid .. ' > /tmp/sta-mode-wifi-interface-up.pid')
os.execute('logger -s -t fqrouter sta-mode-wifi-interface-up.pid: ' .. this_pid) --[[
--检查是否已经开启sta模式,在最开始时有作判断,此处注释
x = uci.cursor() --可放x:foreach前试试
function exit_if_sta_mode_wifi_interface_enabled(section) --怎么似乎执行不到该处
if 'sta' == section.mode and '0' == section.disabled then --根据uci作判断,不按配置文件判断
os.execute('logger -s -t fqrouter std mod wifi interface ' .. section.ssid .. ' already enabled') --当一开始时没有关闭sta模式的wifi,则执行
os.exit()
end
end
x:foreach('wireless', 'wifi-iface', exit_if_sta_mode_wifi_interface_enabled)
os.execute('logger -s -t fqrouter no sta mode wifi interface enabled') --3有执行
]]--
function is_interface_up(ifname) --接口名字
local f = assert(io.popen('ifconfig '..ifname, 'r'))
local output = assert(f:read('*a'))
return output:find('RUNNING')
end
for count=, do
if is_interface_up('wlan0') then
break
end
os.execute('sleep 1')
end
if not is_interface_up('wlan0') then
os.execute('logger -s -t fqrouter wlan0 not up in given time') --如果有配置上级wifi,而又不存在时,有用
os.execute('wifi up') --add by tingpan 有用,如果按原来的话要再重启一次
x:set('wireless', 'cfg053579', 'disabled', ) --add by tingpan 恢复配置的初始值,为下次作准备。
x:commit('wireless')
os.exit()
end
os.execute('logger -s -t fqrouter wlan0 is up') --4有执行,已经开启wifi了 local ssid_list = {}
local ssid_present = {}
for i = , do
local iw = require'luci.sys'.wifi.getiwinfo('radio0')
for k, v in ipairs(iw.scanlist or {}) do
if v.ssid ~= nil and ssid_present[v.ssid] == nil then
table.insert(ssid_list, v.ssid)
ssid_present[v.ssid] = v
end
end
os.execute('logger -s -t fqrouter "ssid list: ' .. table.concat(ssid_list, ', ') .. '"') --5、会列出搜到的所有信号
end
local no_sta_mode_wifi_interface_configured = true
function enable_sta_mode_wifi_interface(section)
if 'sta' == section.mode then
no_sta_mode_wifi_interface_configured = false
if ssid_present[section.ssid] ~= nil then
--if not (ssid_present[section.ssid] ~= nil) or '0' == section.disabled then --同时满足两个条件要这样写
os.execute('logger -s -t fqrouter found ' .. section.ssid) --6、查找到想要的信号,之后继续执行脚本文件
x:set('wireless', section['.name'], 'disabled', ) --会执行到该句子 section['.name'] 为cfg053579
x:commit('wireless')
os.execute('touch /tmp/skip-only-enable-connectable-sta-mode-wifi-interface')
os.execute('wifi up') --相当于重启wifi
os.execute('rm /tmp/skip-only-enable-connectable-sta-mode-wifi-interface')
os.execute('sleep 10')
if is_interface_up('wlan0-1') then
os.execute('rm /tmp/upstream-status')
else
os.execute('echo "UPSTREAM_TIMEOUT" > /tmp/upstream-status')
os.execute('logger -s -t fqrouter sta mode wifi interface not up in given time')
x:set('wireless', section['.name'], 'disabled', ) --设置disabled为1
x:commit('wireless')
os.execute('touch /tmp/skip-only-enable-connectable-sta-mode-wifi-interface')
os.execute('wifi down') --关闭wifi,ap和sta模式都关闭
os.execute('wifi up')
os.execute('rm /tmp/skip-only-enable-connectable-sta-mode-wifi-interface')
end
x:set('wireless', section['.name'], 'disabled', ) --add by tingpan 恢复配置的初始值,为下次作准备。
x:commit('wireless')
os.exit()
end
end
end
x = uci.cursor()
x:foreach('wireless', 'wifi-iface', enable_sta_mode_wifi_interface) --3、
if no_sta_mode_wifi_interface_configured then --如果没有设置sta模式
os.execute('echo "UPSTREAM_NOT_CONFIGURED" > /tmp/upstream-status') --写入到该文件中
os.execute('logger -s -t fqrouter no sta mode wifi interface configured') --在log文件中记录
else --有设置却没搜到
os.execute('echo "UPSTREAM_NOT_AVAILABLE" > /tmp/upstream-status')
os.execute('logger -s -t fqrouter no sta mode wifi interface available')
x:set('wireless', 'cfg053579', 'disabled', ) --add by tingpan 恢复配置的初始值,为下次作准备。
x:commit('wireless')
end

3.2设置权限为775

相关资源:

http://pan.baidu.com/s/1bntXbd1

既做无线客户端又做无线ap、又可只存在一种模式的更多相关文章

  1. 华为无线ap3010dn-agn刷成胖ap

    刚买的华为ap3010dn-agn 版本为 v200R007C20SPC500  默认不带命令 ap-mode-switch [Huawei]dis version Huawei Versatile ...

  2. iOS 使用xmpp做聊天客户端

    可以号称史上最详细的xmpp做iOS客户端聊天介绍. 简介:XMPP协议是一种基于Socket长连接.以XML格式进行基本信息交换.C/S  S/S多种架构的聊天协议 XMPPServer 基于XMP ...

  3. Aircrack-ng无线审计工具破解无线密码

    Aircrack-ng工具 Aircrack-ng是一个与802.11标准的无线网络分析的安全软件,主要功能有网络探测.数据包嗅探捕获.WEP和WPA/WPA2-PSK破解.Aircrack可以工作在 ...

  4. 「雕爷学编程」Arduino动手做(33)——ESP-01S无线WIFI模块

    37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里 ...

  5. [原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推)

    [原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推) 内部推荐职位 高级JAVA技术经理: 岗位职责: 负责项目管理(技术方向),按照产品开发流 ,带领研发团队,制定 ...

  6. WLC5520无法通过无线客户端进行网管故障解决

    客户反馈其办公环境中的WLC5520网管需要通过内部有线网络进行管理,通过无线客户端无法进行管理,远程协助其开启WLC5520的无线管理功能后故障解决.

  7. zookeeper原生API做java客户端

    简介 本文是使用apache提供的原生api做zookeeper客户端 jar包 zookeeper-3.4.5.jar   Demo package bjsxt.zookeeper.base; im ...

  8. 投资人的能量往往大多远远不仅于此,他能站在不同的角度和高度看问题(要早点拿投资,要舍得让出股份)——最好不要让 Leader 一边做技术、一边做管理,人的能力是有限的,精力也是有限的

      摘要:在创业三年时间里作为联合创始人,虽然拿着大家均等的股份,我始终是没有什么话语权的,但是,这也给了我从旁观者的角度看清整个局面的机会.创业公司的成败绝大程度取决于技术大牛和公司 Leader, ...

  9. 对QT的理解——能在公司里不做Java,不做很偏门的产品,不使用偏门的语言,还有钱挣,要有感恩的心

    我的理解: QT做应用软件可以很强大,界面足够漂亮(最有意思的是QSS,让我刮目相看),应该是足够了.同时QT也提供了源码,不过超级复杂,难以理解,所以还是无法深入底层.另外它提供了一个额外的好处,就 ...

随机推荐

  1. 在Windows下为PHP安装redis扩展

    1.使用phpinfo()函数查看PHP的版本信息,这会决定扩展文件版本 2.选择http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/ ht ...

  2. PHP:第一章——PHP中的数组运算符和类运算符

    数组运算符: $a+$b;//$a和$b的联合 $a == $b;//比较$a与$b的值相同为true; $a === $b;//如果$a与$b的值与顺讯完全相同为true; $a !=$b;//如果 ...

  3. KMP 求next数组

    一直没理解.看这个倒是看懂了.但是博主代码好像有点问题吖.测试并不正确.思想还是没错的. 转载自:http://www.tuicool.com/articles/yayeIbe

  4. html <table>标签信息

    table的属性 border pixcels 规定表格边框的宽度 cellpadding picels/% 规定单元格边沿与内容之间的空白 cellspacing picels/% 规定表格以及单元 ...

  5. css 设置背景色

    设置背景图 background:url($!{rc.contextPath}/assets/images/bady/date.png)repeat 50px center background:ur ...

  6. bzoj1082

    题解: 暴搜+二分+剪枝 二分答案,暴力判断是否有解 然后加上剪枝 代码: #include<bits/stdc++.h> using namespace std; ; int rest, ...

  7. C语言 string::size_type类型

    string::size_type类型 从逻辑上来讲,size()成员函数似乎应该返回整型数值,或如2.2节“建议”中所述的无符号整数.但事实上,size操作返回的是string::size_type ...

  8. L224

    Astronomers have revealed details of mysterious signals emanating from a distant galaxy, picked up b ...

  9. android源码追踪学习 RecipientsEditor

    RecipientsEditor 新建短信时输入收接者的editor, public class RecipientsEditor extends MultiAutoCompleteTextView  ...

  10. HDU 4240

    http://acm.hdu.edu.cn/showproblem.php?pid=4240 题意:求最大流和流量最大的一条路径的流量的比值 题解:流量最大的路径的流量在dinic的dfs每次搜到终点 ...