I got a program as below, named autoReboot.sh. I added " [ -e /boot/autoReboot.sh ] && bash /boot/autoReboot.sh " at the end of /etc/rc.local. I re-started my ubuntu to test it. The first time, it started up but didn't re-started automatically. I re-started it manually and then it ran to show prompt ("reboot or not...") and then hung. The system will never work and needed to re-download f/w. How come? It seems nothing in autoReboot.sh will hurt the system. Why does this system never works again? It only ran to show prompt in autoReboot.sh.
#!/bin/bash
#usage: autoRoboot.sh 300
[ -z $1 ] && time=300
[ $1 == "--help" -o $1 == "-h" ] && {
printf $0 100\t\treboot 100 times.\n
printf $0\t\t reboot 300 times.(default)\n
printf $0 infinite\t reboot infinitely.
exit 0;
}
function infinite() {
[ ! -e /boot/count ] && echo "0" > /boot/count
declare -i count=$(cat /boot/count)
while true; do
echo "$[ $count+1 ]" > /boot/count
/sbin/reboot
done
}
function finiteRun() {
[ ! -e /boot/count ] && echo "0" > /boot/count
declare -i count=$(cat /boot/count)
while [ $count -le $time ]
do
echo "$[ $count+1 ]" > /boot/count
read -p "reboot or not \(yYnN\)" ttt
[ $ttt == "y" ] && shutdown -r now
exit 0
done
}
## Main function stream
[ "$1" == infinite ] && {
infinite;
} || {
finiteRun;
}
exit 0;