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

最新文章

  1. Bimmap 成像用bitblt 缩放问题
  2. [整理]Matlab之中心平滑滤波
  3. Shell基础-ech0,cat,history,alias,unalias,bash快捷键,wc,执行结果写入文件
  4. ubuntu 下载额外数据不成功”的恼人提示通知
  5. zoj 3261 Connections in Galaxy War
  6. Swift学习:闭包(Closures)
  7. C# IO流的操作
  8. [转载]WCF 几种常见错误
  9. IOS开发中怎样验证邮箱的合法性
  10. java实现简单计算器
  11. form表单的action提交写到js中来,同时onclick事件也写在js中来。其action也可以通过ajax来提交的。
  12. [shiro学习笔记]第三节 使用myeclipse导入apache shiro中的QuikStart example例子
  13. 接口测试---Python数据处理需要注意的细节
  14. js中文编码到C#后台解码
  15. Spring3.2+mybatis3.2+Struts2.3整合
  16. 如何用MAT分析Android程序的内存泄露
  17. 在kali linux之下 下载并解压的文件名呈现乱码 解决方案
  18. WP8.1学习系列(第二十一章)——本地应用数据
  19. 预备作业03:虚拟机安装及Linux操作系统练习
  20. Phaser3跟随自定义路径移动的赛车 -- iFIERO游戏教程

热门文章

  1. setuid和setgid
  2. 060——VUE中vue-router之路由嵌套在文章系统中的使用方法:
  3. 1strcat/strcpy应用
  4. codeforce 853A Planning
  5. 驱动程序多线程 PsCreateSystemThread
  6. 项目使用Nuget,然后SVN checkout后显示缺少引用
  7. the usage of String
  8. Bugzilla使用规范
  9. 清除的通用样式 css
  10. 【HDU5421】Victor and String(回文树)