既做无线客户端又做无线ap、又可只存在一种模式
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、又可只存在一种模式的更多相关文章
- 华为无线ap3010dn-agn刷成胖ap
刚买的华为ap3010dn-agn 版本为 v200R007C20SPC500 默认不带命令 ap-mode-switch [Huawei]dis version Huawei Versatile ...
- iOS 使用xmpp做聊天客户端
可以号称史上最详细的xmpp做iOS客户端聊天介绍. 简介:XMPP协议是一种基于Socket长连接.以XML格式进行基本信息交换.C/S S/S多种架构的聊天协议 XMPPServer 基于XMP ...
- Aircrack-ng无线审计工具破解无线密码
Aircrack-ng工具 Aircrack-ng是一个与802.11标准的无线网络分析的安全软件,主要功能有网络探测.数据包嗅探捕获.WEP和WPA/WPA2-PSK破解.Aircrack可以工作在 ...
- 「雕爷学编程」Arduino动手做(33)——ESP-01S无线WIFI模块
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里 ...
- [原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推)
[原创]上海好买基金招高级Java技术经理/运维主管/高级无线客户端开发等职位(内推) 内部推荐职位 高级JAVA技术经理: 岗位职责: 负责项目管理(技术方向),按照产品开发流 ,带领研发团队,制定 ...
- WLC5520无法通过无线客户端进行网管故障解决
客户反馈其办公环境中的WLC5520网管需要通过内部有线网络进行管理,通过无线客户端无法进行管理,远程协助其开启WLC5520的无线管理功能后故障解决.
- zookeeper原生API做java客户端
简介 本文是使用apache提供的原生api做zookeeper客户端 jar包 zookeeper-3.4.5.jar Demo package bjsxt.zookeeper.base; im ...
- 投资人的能量往往大多远远不仅于此,他能站在不同的角度和高度看问题(要早点拿投资,要舍得让出股份)——最好不要让 Leader 一边做技术、一边做管理,人的能力是有限的,精力也是有限的
摘要:在创业三年时间里作为联合创始人,虽然拿着大家均等的股份,我始终是没有什么话语权的,但是,这也给了我从旁观者的角度看清整个局面的机会.创业公司的成败绝大程度取决于技术大牛和公司 Leader, ...
- 对QT的理解——能在公司里不做Java,不做很偏门的产品,不使用偏门的语言,还有钱挣,要有感恩的心
我的理解: QT做应用软件可以很强大,界面足够漂亮(最有意思的是QSS,让我刮目相看),应该是足够了.同时QT也提供了源码,不过超级复杂,难以理解,所以还是无法深入底层.另外它提供了一个额外的好处,就 ...
随机推荐
- 实现自己的ls命令
一步步实现,先看最简单的ls的指令: ls不带参数,直接打印文件名 dst.txt main10.c main11.c main12.c main13.c main14.c~ main15.c~ ma ...
- 1strcat/strcpy应用
分析下列程序输出 #include<iostream> #include<string.h> using namespace std; int main() { ]=]=&qu ...
- sgu107. 987654321 problem 简单打表 难度:0
107. 987654321 problem time limit per test: 0.25 sec. memory limit per test: 4096 KB For given numbe ...
- python笔记03:使用字符串
3.1 基本字符串操作: 所有的标准序列操作(索引,分片,乘法,判断成员资格,求长度,取最小值,取最大值)对于字符串同样有效.但是,请记住:字符串都是不可变的 3.2 字符串格式化:精简版 字符串格式 ...
- bacula备份终端操作bconsole指令
1.list命令列出各种备份状态信息 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 list Jobs #列出所有备份记录状态 list jobid= ...
- IoC基础例子
一个简单的例子: 一般新建一个com.dao包,存放一些dao接口. com.dao.impl里面存放具体的dao com.service存放service接口 com.service.impl具体的 ...
- (转)git合并多个commit
原文地址:http://platinhom.github.io/2016/01/02/git-combine_commit/ 有时commit多了看着会不爽.所以想合并掉一些commit. 这里是最简 ...
- STL标准库-一个万用的hash function
技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性 在前面我介绍过hash的使用,本次主要介绍一下Hash Function Hash Function即获得hash code的函 ...
- 负margin
负margin理论: 何谓参考线?参考线就是 margin移动的基准点,此基准点相对于box(自身)是静止的.而margin的数值,就是box相对于参考线的位移量. 一个完整的margin属性是这么写 ...
- [LeetCode&Python] Problem 766. Toeplitz Matrix
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given ...