o 2015.8.26
o ファーストリリース
o 2015.9.9
o wlan0とeth0の両方の切断検出と回復機能追加
o 2015.9.20
o eth0 ダウン時の回復機能修正
- #!/bin/sh
- # licence GPLv2 ; this scripts designed by Yamauchi.Isamu 2015.8.26 update 2015.9.22
- # ping watch of wlan0 or eth0 fail for rasberry pi
- # pepowlan_watch
- STARTUP=/usr/src/pepolinux/startup.s
- [ ! -e $STARTUP ] && exit
- WORKDIR=/www/remote-hand/tmp
- MSLEEP=300123
- GATEWAY=`cat $STARTUP|awk '/GATEWAY/{gsub("\"","",$1);split($1,I,"=");print I[2]}'`
- [ -z $GATEWAY ] && exit
- PING_HOST=$GATEWAY
- WLAN_YES_NO=`ip link show wlan0 2>&1|awk 'BEGIN{WLAN="YES"};/does not exist/{WLAN="NO"};END{printf WLAN}'`
- ETH0_YES_NO=`ip link show eth0|awk 'BEGIN{ETH0="NO"};/state UP/{ETH0="YES"};END{printf ETH0}'`
- if [ $ETH0_YES_NO = "YES" ];then
- ETH0_IP=`cat $STARTUP|awk '/SET_ETH0/{gsub("\"","",$1);split($1,I,"=");printf I[2]}'`
- fi
- PING_LOG=$WORKDIR/.pepowlan_watch.log
- CMD=$WORKDIR/pepowlan_watch.pepocmd
- cat>$CMD<<END
- #!/bin/sh
- error() {
- [ -e $PING_LOG ] && rm -f $PING_LOG
- exit
- }
- trap error SIGTERM SIGHUP SIGKILL SIGINT
- while true
- do
- date +"%Y/%m/%d %T" > $PING_LOG
- if ! ping -c 1 $PING_HOST 2>&1 >>$PING_LOG; then
- msleep 1000
- if ! ping -c 1 $PING_HOST 2>&1 >> $PING_LOG; then
- if [ $WLAN_YES_NO = "YES" ];then
- ifdown wlan0
- ifup wlan0
- else
- ifdown eth0
- ifup eth0
- ifconfig eth0 $ETH0_IP
- ip route del default
- ip route add default via $GATEWAY
- fi
- fi
- fi
- msleep $MSLEEP
- done
- END
[PageInfo]
LastUpdate: 2015-09-22 05:47:47, ModifiedBy: pepolinux
[License]
GNU Free Documentation License
[Permissions]
view:all, edit:doc editors, delete/config:doc editors