Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Why did this autoReboot.sh hurt the system?  (Read 4192 times)

0 Members and 1 Guest are viewing this topic.

Stan Huang

    Topic Starter


    Beginner

    • Experience: Experienced
    • OS: Windows 7
    Why did this autoReboot.sh hurt the system?
    « on: October 23, 2013, 09:54:59 PM »
    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;

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Why did this autoReboot.sh hurt the system?
    « Reply #1 on: October 23, 2013, 11:30:17 PM »
    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.
    « Last Edit: October 23, 2013, 11:41:18 PM by Geek-9pm »

    Stan Huang

      Topic Starter


      Beginner

      • Experience: Experienced
      • OS: Windows 7
      Re: Why did this autoReboot.sh hurt the system?
      « Reply #2 on: October 23, 2013, 11:52:25 PM »
      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.