Improvements to Reboot and Shutdown

Issue #66 closed
rs232 created an issue
  • REBOOT: It would be good to allow a scheduled one-off reboot. I would modify the reboot popup from the current version (reboot yes/no) to a new version where the pop-up presents 3 option:

    • Reboot now
    • Reboot in N minutes from now (this can easily mapped into a cru a command). Perhaps when booked a countdown can appear somewhere e.g. on the header of the admin page.
    • Cancel

  • SHUTDOWN: The Shutdown menu on a router is used extremely rarely and it can cause unwanted hassle if a device is shut down mistakenly. Since Shutdown lives next to reboot in the menu and the pop up page is pretty much identical amongst the two, I would modify the popup behaviour of the Shutdown function to make sure the user is warned in case a rebooted is wanted but Shutdown is selected by error. An idea would be as follow:

    • On the pop-up where the user is requested to confirm whether to shutdown or not, if OK is selected, rather than proceed, I would make a second pop-up appearing (even in different colour to attract the user attention) asking “Are you really sure you want to shutdown this device?” and if OK is selected again then proceed. → DONE

Comments (8)

  1. rs232 reporter

    For the Shutdown I’ve done this via a modification to the tomato.js . Removing this:

    function shutdown() {
        if (confirm("Shutdown?")) form.submitHidden('shutdown.cgi', { });
    }
    

    And adding this instead:

    function shutdown()
    {
        if (confirm("Are you sure you want to Shutdown?")) shutdown2();
    }
    
    function shutdown2()
    {
        if (confirm("Are you really sure you want to Shutdown??\nThis will require a manual power cycle to boot again.")) form.submitHidden('shutdown.cgi', { });
    }
    

  2. rs232 reporter

    I think I’ve done the GUI part of the Reboot idea detailed above.

    function reboot()
    {
        var m = 0;
        var r = prompt("In how many minutes you want to reboot?\nuse 0 for an immediate action", "0");
        if (r = 0) {
            m = 0;
            form.submitHidden('tomato.cgi', { _reboot: 1, _commit: 0, _nvset: 0 });
        } else {
            m = r;
    //  convert minutes delay into absolute date in the future from now
    //  add cru a command to plan the reboot
        }   
    }
    

    Can anybody provide some inputs on what's the best way in tomato to actually execute system commands and specifically the cru a command for insertion into the crontable?

  3. DJK

    If you delay options will be minutes, consider sleep ?

    Usage: sleep [N]...
    
    Pause for a time equal to the total of the args given, where each arg can
    have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays
    

    Take into consideration nothing executes until it counts down… but then if it’s reboot, that’s likely pointless. (Of course you can always use an ampersand to background it)

    sleep 1m reboot or sleep 60s reboot for example.

    Should default to 0 for an immediate reboot with no additional user input.

  4. pedro repo owner

    I thought about it for a long time and came to the conclusion that it's not a good idea, so I won't add it.

  5. Log in to comment