Commit 75bd2375 authored by Benoit Rat's avatar Benoit Rat Committed by Adam Wujek

www: improve reboot procedure with variable timeout

Rebooting can now be done with a different timeout:

* Flashing the full wrs-firmware.tar takes ~120s
* Flashing some part takes ~90s
* Rebooting is ~30s
parent 584ec43d
...@@ -677,7 +677,7 @@ function wrs_management(){ ...@@ -677,7 +677,7 @@ function wrs_management(){
unlink($uploadfile); unlink($uploadfile);
//Reboot switch //Reboot switch
sleep(1); sleep(1);
wrs_reboot(); wrs_reboot(90); //Updating only one part of the firmware take ~90s.
} }
else if(substr($uploadfname,0,14)=="wr-switch-sw-v" && substr($uploadfname,-13)=="_binaries.tar") else if(substr($uploadfname,0,14)=="wr-switch-sw-v" && substr($uploadfname,-13)=="_binaries.tar")
{ {
...@@ -685,7 +685,7 @@ function wrs_management(){ ...@@ -685,7 +685,7 @@ function wrs_management(){
unlink($uploadfile); unlink($uploadfile);
//Reboot switch //Reboot switch
sleep(1); sleep(1);
wrs_reboot(); wrs_reboot(150); //120s should be enough but we prefer to keep safe
} }
else else
{ {
...@@ -1250,9 +1250,9 @@ function echoSelectedClassIfRequestMatches($requestUri) ...@@ -1250,9 +1250,9 @@ function echoSelectedClassIfRequestMatches($requestUri)
return 'class="selected"'; return 'class="selected"';
} }
function wrs_reboot(){ function wrs_reboot($timeout=40){
sleep(1); sleep(1);
header ('Location: reboot.php'); header ('Location: reboot.php?timeout='.$timeout);
} }
/* /*
......
...@@ -55,6 +55,7 @@ function showPopup(url) { ...@@ -55,6 +55,7 @@ function showPopup(url) {
* Reboots the switch * Reboots the switch
* *
* @author José Luis Gutiérrez <jlgutierrez@ugr.es> * @author José Luis Gutiérrez <jlgutierrez@ugr.es>
* @author Benoit Rat <benoit@sevensols.com>
* *
* Reboots the switch using the rebooter.php file. * Reboots the switch using the rebooter.php file.
* This has been done to display the "rebooting" message after any * This has been done to display the "rebooting" message after any
...@@ -64,10 +65,19 @@ function showPopup(url) { ...@@ -64,10 +65,19 @@ function showPopup(url) {
$(document).ready( $(document).ready(
function() { function() {
setTimeout(function() { setTimeout(function() {
var path = window.location.pathname; var pageid=$('body').attr('id');
var page = path.split("/").pop(); if (pageid=="reboot")
if (page == "reboot.php"){ {
$('#rebootingtext').text("Rebooting WRS. The web interface will refresh automatically after 50s."); //Obtain timeout from the hidden input (#reboot_to) or set it by default to 40s
tout=$('#reboot_to').val()
if($.isNumeric(tout)==false || tout < 30) tout=40
//Improve how to print the timeout when more than 1 minute
if(tout>60) tout_str=Math.floor(tout/60)+"m "+(tout%60)+"s."
else tout_str=tout+"s."
//Update the HTML and call the rebooter.
$('#rebootingtext').text("Rebooting WRS. The web interface will refresh automatically after "+tout_str);
$('#rebooting').load('rebooter.php'); $('#rebooting').load('rebooter.php');
} }
}, 1500); }, 1500);
...@@ -77,18 +87,24 @@ $(document).ready( ...@@ -77,18 +87,24 @@ $(document).ready(
* Redirects users to index.php * Redirects users to index.php
* *
* @author José Luis Gutiérrez <jlgutierrez@ugr.es> * @author José Luis Gutiérrez <jlgutierrez@ugr.es>
* @author Benoit Rat <benoit@sevensols.com>
* *
* 50 seconds after the execution of the reboot cmd, the web browser * tout seconds after the execution of the reboot cmd, the web browser
* reloads automatically the web interface. * reloads automatically the web interface.
* *
*/ */
$(document).ready( $(document).ready(
function() { function() {
var pageid=$('body').attr('id');
if (pageid=="reboot")
{
//Obtain timeout from the hidden input (#reboot_to) or set it by default to 40s
tout=$('#reboot_to').val()
if($.isNumeric(tout)==false || tout < 30) tout=40
//Main timeout to refresh the webpage
setTimeout(function() { setTimeout(function() {
var path = window.location.pathname; window.location.href = "index.php";
var page = path.split("/").pop(); }, tout*1000);
if (page == "reboot.php"){ }
window.location.href = "index.php";
}
}, 50000);
}); });
<?php include 'functions.php'; include 'head.php'; ?> <?php include 'functions.php'; include 'head.php'; ?>
<body id="management"> <body id="reboot">
<div class="main"> <div class="main">
<div class="page"> <div class="page">
<div class="header" > <div class="header" >
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<div id="rebootingtext" align=center>...Saving changes...</div> <div id="rebootingtext" align=center>...Saving changes...</div>
</div> </div>
<form><input hidden id="reboot_to" value="<?php echo $_GET['timeout']?>"></form>
<div id="rebooting"></div> <div id="rebooting"></div>
<div id="rebootwrlogo"> <div id="rebootwrlogo">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment