1.

Solve : Why did this autoReboot.sh hurt the system??

Answer»

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;Please indicate what version of Linux you ave and why you need
autoReboot.sh on your box.
Not everybody reading this will understand.
It is a sway to have you own stuff get on board at start up time. It is not way foolproof. Here is a GENERAL reference:
http://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup
As the article suggests, you take responsibility. Advanced users may use special stuff that requires that kind of thing.
IMHO, IF it don't work, don't use it.
Sorry I can not offer any more help.Sorry for not stating something very clearly. The platform I ran is Ubuntu 11.10.
The reason I would like to ran this autoRestart.sh is for burn-in test for my boards.



Discussion

No Comment Found