while true; do pings $target if [ $? -ne 0 ]; then echo "ping $target error" case $target in $A) target=$B stats[0]=1;; $B) target=$C stats[1]=1;; $C) target=$A stats[2]=1;; esac else echo "ping $target ok" case $target in $A) target=$B stats[0]=0;; $B) target=$C stats[1]=0;; $C) target=$A stats[2]=0;; esac # shutdown -c #ping成功其中一个则取消关机 echo "shutdown cancled" fi echo "Connections' stat: ${stats[*]}"
if check_stat $l 0; then #如果ping都成功 echo "All connection is ok." # sleep 3 else echo "Some Target error." fi if check_stat $l 1; then #如果ping都失败 echo "All connection error. Shutdown system." # shutdown -h +5 else echo "Some connection error." fi done