1#!/bin/bash 2 3delay=8 4total=${1:-10000} 5CNT=/userdata/rockchip-test/reboot_cnt 6 7if [ ! -e "/userdata//rockchip-test" ]; then 8 echo "no /userdata/rockchip-test" 9 mkdir -p /userdata/rockchip-test 10fi 11 12if [ ! -e "/userdata/rockchip-test/auto_reboot.sh" ]; then 13 cp /rockchip-test/auto_reboot/auto_reboot.sh /userdata/rockchip-test 14 echo $total > /userdata/rockchip-test/reboot_total_cnt 15 sync 16fi 17 18while true 19do 20 21if [ -e $CNT ] 22then 23 cnt=`cat $CNT` 24else 25 echo reset Reboot count. 26 echo 0 > $CNT 27fi 28 29echo Reboot after $delay seconds. 30 31let "cnt=$cnt+1" 32 33if [ $cnt -ge $total ] 34then 35 echo AutoReboot Finisned. 36 echo "off" > $CNT 37 echo "do cleaning ..." 38 rm -rf /userdata/rockchip-test/auto_reboot.sh 39 rm -rf /userdata/rockchip-test/reboot_total_cnt 40 rm -f $CNT 41 sync 42 exit 0 43fi 44 45echo $cnt > $CNT 46echo "current cnt = $cnt, total cnt = $total" 47echo "You can stop reboot by: echo off > /userdata/rockchip-test/reboot_cnt" 48sleep $delay 49cnt=`cat $CNT` 50if [ $cnt != "off" ]; then 51 sync 52 if [ -e /sys/fs/pstore/console-ramoops-0 ]; then 53 echo "check console-ramoops-o message" 54 grep -q "Restarting system" /sys/fs/pstore/console-ramoops-0 55 if [ $? -ne 0 -a $cnt -ge 2 ]; then 56 echo "no found 'Restarting system' log in last time kernel message" 57 echo "consider kernel crash in last time reboot test" 58 echo "quit reboot test" 59 rm -rf /userdata/rockchip-test/auto_reboot.sh 60 rm -rf /userdata/rockchip-test/reboot_total_cnt 61 sync 62 exit 1 63 else 64 reboot 65 fi 66 else 67 reboot 68 fi 69else 70 echo "Auto reboot is off" 71 rm -rf /userdata/rockchip-test/auto_reboot.sh 72 rm -rf /userdata/rockchip-test/reboot_total_cnt 73 rm -f $CNT 74 sync 75fi 76exit 0 77done 78