1. 启动脚本, /etc/rc.loca
-
# Put your custom commands here that should be executed once
-
# the system init finished. By default this file does nothing.
-
-
#2014-11, 上级WiFi不存在则OP中继异常, 切换到AP模式
-
if ping -w 1 -c 1 www.baidu.com #ping测试
-
then #如果条件ping -c 1 $address为真,即通,则执行该命令;
-
echo "$address is online" #如果网络在线则放弃脚本
-
else #如果网络不在线则开始切换网络
-
/xutest/network_ap.sh
-
fi
-
-
#向上级路由映射UPNP端口
-
/xutest/upnp.sh
-
-
#将公网IP发到指定Email
-
/xutest/getip.sh
-
-
#解决3322.org的DDNS的不稳定
-
sleep 128 /bin/sh /usr/lib/ddns/dynamic_dns_updater.sh myddns 0 &
-
a=1
-
while [ $a -le 500 ]
-
do
-
/bin/sh /usr/lib/ddns/dynamic_dns_updater.sh myddns 0 &
-
sleep 1h
-
Done
-
-
-
exit 0
2. 定时脚本, /etc/contrabs/root
-
*/1 * * * * /xutest/703n_led_blink.sh
-
*/1 * * * * /xutest/lewei_dongle.sh
-
*/1 * * * * /xutest/yeelink_photo.sh
-
-
0 */1 * * * /xutest/upnp.sh
3. 按键处理, 相关2个文件, 无需重启即可有效
/etc/config/system
-
config system
-
option hostname 'OpenWrt'
-
option zonename 'Asia/Shanghai'
-
option timezone 'CST-8'
-
option conloglevel '8'
-
option cronloglevel '8'
-
-
config timeserver 'ntp'
-
list server '0.openwrt.pool.ntp.org'
-
list server '1.openwrt.pool.ntp.org'
-
list server '2.openwrt.pool.ntp.org'
-
list server '3.openwrt.pool.ntp.org'
-
option enable_server '0'
-
-
config restorefactory
-
option button 'reset'
-
option action 'pressed'
-
option timeout '2'
-
-
config led
-
option name 'flashing'
-
option sysfs 'tp-link:blue:config'
-
option trigger 'timer'
-
option delayon '800'
-
option delayoff '800'
-
-
config led
-
option name 'Relay'
-
option sysfs 'tp-link:blue:relay'
-
option trigger 'none'
-
option default '0'
/etc/hotplug.d/button/50-restorefactory, 必须具有X属性
-
#!/bin/sh
-
-
system_config() {
-
config_get button "$1" button "reset"
-
config_get action "$1" action "pressed"
-
config_get timeout "$1" timeout "2"
-
}
-
-
config_load system
-
config_foreach system_config restorefactory
-
-
[ "$BUTTON" = "$button" ] && {
-
-
[ -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"
-
-
[ "$ACTION" = "$action" ] && {
-
-
if [ "$timeout" -gt 0 ]
-
then
-
sleep "$timeout" && firstboot && reboot &
-
echo $! > /tmp/run/restorefactory.pid
-
logger -p user.info -t "restorefactory" "restoring to factory defaults in $timeout seconds"
-
elif [ "$timeout" -eq 0 ]
-
then
-
firstboot && reboot &
-
else
-
logger -p user.info -t "restorefactory" "invalid timeout value ($timeout)"
-
fi
-
}
-
}
-
-
[ "$BUTTON" = "$button" ] && [ "$ACTION" = "$action" ] && {
-
SW=$(uci get system.@led[-1].default)
-
[ $SW == '0' ] && (uci set system.@led[-1].default=1; echo 1 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness)
-
[ $SW == '0' ] || (uci set system.@led[-1].default=0; echo 0 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness)
-
uci commit
-
-
#/etc/init.d/led restart
-
}
阅读(9682) | 评论(0) | 转发(1) |