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. IOS UI-滚动视图(UIScrollView)

    #import "ViewController.h" /* 1.UIScrollView控件是什么? (1)移动设备的屏幕⼤小是极其有限的,因此直接展示在⽤用户眼前的内容也相当有限 ...

  2. iOS调用第三方地图App进行导航方法

    前言 App内根据手机上装载的地图App将其显示在弹出的选择框,选择对应地图跳转进入地图导航.需要用到- (BOOL)canOpenURL:(NSURL *)url NS_AVAILABLE_IOS( ...

  3. 2018-北航-面向对象第三次OO作业分析与小结

    1. 规格设计的发展历史 规格设计用于对程序设提供分解,抽象等的手段.在撰写代码规格的时候,需要对组成部件进行抽象. 在1960s,软件设计出现危机,例如Dijkstra提出了goto语句的种种危害, ...

  4. Beta 冲刺(7/7)

    前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/10129067.html 作业博客:https://edu.cnblogs.com/campus ...

  5. uDig配图与GeoServer添加Style

    软件介绍: uDig是一个开源的桌面GIS软件,可以进行shp与栅格数据地图文件的编辑和查看,对OpenGIS标准,关于互联网GIS.网络地图服务器和网络功能服务器有特别的加强.通常和GeoServe ...

  6. magento优化

    magento -- SEO优化继续往前走一步 magento的SEO做的实在太好了,让其它的电子商务平台与之相比实在是不是一个重级的,这也许就是magento成功的原因.尽管现在结合apache,实 ...

  7. liunx服务程序的安装及配置

    1.系统运行级别:

  8. [LeetCode&Python] Problem 682. Baseball Game

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

  9. Codeforces123E. Maze【树形dp】【概率dp】【证明题】

    LINK 题目大意 一棵树,上面的每个点都有一定概率成为起点和终点 从起点出发,随机游走,并按照下列规则统计count: DFS(x) if x == exit vertex then finish ...

  10. Immutable集合

    转自:https://blog.csdn.net/michaellufhl/article/details/6314333 大家都知道JDK提供了Collections.UnmodifiableLis ...