Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6215
  • 博文数量: 5
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2014-12-25 16:43
文章分类
文章存档

2015年(1)

2014年(4)

我的朋友
最近访客

分类: 项目管理

2014-12-25 16:46:16

1. 启动脚本, /etc/rc.loca

点击(此处)折叠或打开

  1. # Put your custom commands here that should be executed once
  2. # the system init finished. By default this file does nothing.

  3. #2014-11, 上级WiFi不存在则OP中继异常, 切换到AP模式
  4. if ping -w 1 -c 1 www.baidu.com #ping测试
  5. then #如果条件ping -c 1 $address为真,即通,则执行该命令;
  6.     echo "$address is online" #如果网络在线则放弃脚本
  7. else #如果网络不在线则开始切换网络
  8.     /xutest/network_ap.sh
  9. fi

  10. #向上级路由映射UPNP端口
  11. /xutest/upnp.sh

  12. #将公网IP发到指定Email
  13. /xutest/getip.sh

  14. #解决3322.org的DDNS的不稳定
  15. sleep 128 /bin/sh /usr/lib/ddns/dynamic_dns_updater.sh myddns 0 &
  16. a=1
  17. while [ $a -le 500 ]
  18. do
  19.     /bin/sh /usr/lib/ddns/dynamic_dns_updater.sh myddns 0 &
  20.     sleep 1h
  21. Done


  22. exit 0

2. 定时脚本, /etc/contrabs/root

点击(此处)折叠或打开

  1. */1 * * * * /xutest/703n_led_blink.sh
  2. */1 * * * * /xutest/lewei_dongle.sh
  3. */1 * * * * /xutest/yeelink_photo.sh

  4. 0 */1 * * * /xutest/upnp.sh

3.  按键处理, 相关2个文件, 无需重启即可有效
/etc/config/system

点击(此处)折叠或打开

  1. config system
  2.     option hostname 'OpenWrt'
  3.     option zonename 'Asia/Shanghai'
  4.     option timezone 'CST-8'
  5.     option conloglevel '8'
  6.     option cronloglevel '8'

  7. config timeserver 'ntp'
  8.     list server '0.openwrt.pool.ntp.org'
  9.     list server '1.openwrt.pool.ntp.org'
  10.     list server '2.openwrt.pool.ntp.org'
  11.     list server '3.openwrt.pool.ntp.org'
  12.     option enable_server '0'

  13. config restorefactory
  14.     option button 'reset'
  15.     option action 'pressed'
  16.     option timeout '2'

  17. config led
  18.     option name 'flashing'
  19.     option sysfs 'tp-link:blue:config'
  20.     option trigger 'timer'
  21.     option delayon '800'
  22.     option delayoff '800'

  23. config led
  24.     option name 'Relay'
  25.     option sysfs 'tp-link:blue:relay'
  26.     option trigger 'none'
  27.     option default '0'

/etc/hotplug.d/button/50-restorefactory, 必须具有X属性

点击(此处)折叠或打开

  1. #!/bin/sh

  2. system_config() {
  3.     config_get button "$1" button "reset"
  4.     config_get action "$1" action "pressed"
  5.     config_get timeout "$1" timeout "2"
  6. }

  7. config_load system
  8. config_foreach system_config restorefactory

  9. [ "$BUTTON" = "$button" ] && {

  10.     [ -f /tmp/run/restorefactory.pid ] && read PID < /tmp/run/restorefactory.pid && kill $PID && rm /tmp/run/restorefactory.pid && logger -p user.info -t "restorefactory" "restore to factory defaults aborted"

  11.     [ "$ACTION" = "$action" ] && {

  12.         if [ "$timeout" -gt 0 ]
  13.         then
  14.             sleep "$timeout" && firstboot && reboot &
  15.             echo $! > /tmp/run/restorefactory.pid
  16.             logger -p user.info -t "restorefactory" "restoring to factory defaults in $timeout seconds"
  17.         elif [ "$timeout" -eq 0 ]
  18.         then
  19.             firstboot && reboot &
  20.         else
  21.             logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"
  22.         fi
  23.     }
  24. }

  25. [ "$BUTTON" = "$button" ] && [ "$ACTION" = "$action" ] && {
  26.     SW=$(uci get system.@led[-1].default)
  27.     [ $SW == '0' ] && (uci set system.@led[-1].default=1; echo 1 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness)
  28.     [ $SW == '0' ] || (uci set system.@led[-1].default=0; echo 0 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness)    
  29.     uci commit

  30.     #/etc/init.d/led restart
  31. }




阅读(918) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:双11纪念版, 安卓+openwrt联合调试

给主人留下些什么吧!~~