Commit f210d17a authored by José Luis  Gutiérrez's avatar José Luis Gutiérrez Committed by Benoit Rat

www: wrs reboot sequency improved. No crashes.

New reboot system. It shows now a loading gif image without crashing
because of not accessing the WRS anymore.

- Reboot javascript function: displays image, message & reboots without
web crash
- Redirect javascript function: When rebooting, it redirects to index.hp
after 50s.
- All shell_exec("reboot") calls have been replaced by wrs_reboot() in
all files.
- loader.gif added
- new entry to style.css, one for the gif animation and other for the
text.
- reboot.php & rebooter.php carry out the new reboot.

Conflicts:
	userspace/rootfs_override/var/www/endpointcalibration.php
	userspace/rootfs_override/var/www/functions.php
	userspace/rootfs_override/var/www/sfpcalibration.php
parent 089d4fa0
...@@ -400,6 +400,15 @@ margin: 10px 0px; ...@@ -400,6 +400,15 @@ margin: 10px 0px;
margin-top:300px margin-top:300px
} }
#rebootmsg{
margin-top:100px
}
#rebootmsg img{
width: 100px;
height: 100px;
}
.center { .center {
margin-left:auto; margin-left:auto;
margin-right:auto; margin-right:auto;
......
...@@ -145,8 +145,7 @@ ...@@ -145,8 +145,7 @@
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>'; echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
wrs_change_wrfs("ro"); wrs_reboot();
shell_exec("reboot");
}else if(!empty($_POST['newconf']) && $error){ }else if(!empty($_POST['newconf']) && $error){
echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>'; echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>';
......
...@@ -478,7 +478,7 @@ function wrs_php_filesize(){ ...@@ -478,7 +478,7 @@ function wrs_php_filesize(){
* *
* It runs: * It runs:
* load-virtex for loading .bin to the FPGA * load-virtex for loading .bin to the FPGA
* load-lm32 for loading .bin to the lm32 professor * load-lm32 for loading .bin to the lm32 processor
* *
* *
* *
...@@ -499,8 +499,8 @@ function wrs_load_files(){ ...@@ -499,8 +499,8 @@ function wrs_load_files(){
echo '<center>Loading FPGA binary '.$_FILES['fpgafile']['name'].', please wait for the system to reboot</center>'; echo '<center>Loading FPGA binary '.$_FILES['fpgafile']['name'].', please wait for the system to reboot</center>';
$str = shell_exec("/wr/bin/load-virtex ".$uploadfile); $str = shell_exec("/wr/bin/load-virtex ".$uploadfile);
echo $str; echo $str;
echo '<br>System is rebooting, please wait for 30 seconds';
$str = shell_exec("reboot"); wrs_reboot();
} else { } else {
echo "<center>File is not valid, please upload a .bin file.</center>\n"; echo "<center>File is not valid, please upload a .bin file.</center>\n";
...@@ -521,8 +521,8 @@ function wrs_load_files(){ ...@@ -521,8 +521,8 @@ function wrs_load_files(){
echo '<center>Loading lm32 binary '.$_FILES['lm32file']['name'].',, please wait for the system to reboot</center>'; echo '<center>Loading lm32 binary '.$_FILES['lm32file']['name'].',, please wait for the system to reboot</center>';
$str = shell_exec("/wr/bin/load-lm32 ".$uploadfile); $str = shell_exec("/wr/bin/load-lm32 ".$uploadfile);
echo $str; echo $str;
echo '<br>System is rebooting, please wait for 30 seconds';
$str = shell_exec("reboot"); wrs_reboot();
} else { } else {
echo "<center>File is not valid, please upload a .bin file</center>\n"; echo "<center>File is not valid, please upload a .bin file</center>\n";
...@@ -572,13 +572,7 @@ function wrs_management(){ ...@@ -572,13 +572,7 @@ function wrs_management(){
$output = shell_exec($cmd); $output = shell_exec($cmd);
}else if (!strcmp($cmd, "reboot")){ }else if (!strcmp($cmd, "reboot")){
echo '<br><br><br>System is rebooting. Please wait 30 seconds.'; echo '<br><br><br>System is rebooting. Please wait 30 seconds.';
$output = shell_exec($cmd); wrs_reboot();
}else if (!strcmp($cmd, "rw")){
$output = shell_exec("/wr/bin/wrfs_mnt.sh rw");
echo '<br><br><br>Partition is now writable';
}else if (!strcmp($cmd, "ro")){
$output = shell_exec("/wr/bin/wrfs_mnt.sh ro");
echo '<br><br><br>Partition is now READ-ONLY';
}else if (!strcmp($cmd, "size")){ }else if (!strcmp($cmd, "size")){
php_file_transfer_size(htmlspecialchars($_POST["size"])); php_file_transfer_size(htmlspecialchars($_POST["size"]));
header('Location: firmware.php'); header('Location: firmware.php');
...@@ -600,14 +594,14 @@ function wrs_management(){ ...@@ -600,14 +594,14 @@ function wrs_management(){
rename($uploadfile, "/update/".($_FILES['file']['name'])); rename($uploadfile, "/update/".($_FILES['file']['name']));
unlink($uploadfile); unlink($uploadfile);
//Reboot switch //Reboot switch
shell_exec("$(sleep 10; reboot) &"); wrs_reboot();
} }
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")
{ {
rename($uploadfile, "/update/wrs-firmware.tar"); rename($uploadfile, "/update/wrs-firmware.tar");
unlink($uploadfile); unlink($uploadfile);
//Reboot switch //Reboot switch
shell_exec("$(sleep 10; reboot) &"); wrs_reboot();
} }
else else
{ {
...@@ -630,7 +624,8 @@ function wrs_management(){ ...@@ -630,7 +624,8 @@ function wrs_management(){
file_put_contents($filename, file_get_contents($ohwrlink)); file_put_contents($filename, file_get_contents($ohwrlink));
rename($filename, $firmware); rename($filename, $firmware);
echo '<p align=center>File successfully downloaded. Rebooting.</p>'; echo '<p align=center>File successfully downloaded. Rebooting.</p>';
shell_exec("reboot");
wrs_reboot();
} else if (!empty($_FILES['ppsi_conf']['name'])){ } else if (!empty($_FILES['ppsi_conf']['name'])){
...@@ -694,7 +689,9 @@ function wrs_management(){ ...@@ -694,7 +689,9 @@ function wrs_management(){
shell_exec("tar -xvf ".$uploadfile. " -C ". $GLOBALS['etcdir'] ); //untar the file shell_exec("tar -xvf ".$uploadfile. " -C ". $GLOBALS['etcdir'] ); //untar the file
echo "<center>Configuration restored sucessfully. Rebooting system.\n"; echo "<center>Configuration restored sucessfully. Rebooting system.\n";
shell_exec("reboot");
wrs_reboot();
} else { } else {
echo "<center>File is not valid, please upload a .tar.gz file</center>\n"; echo "<center>File is not valid, please upload a .tar.gz file</center>\n";
} }
...@@ -764,7 +761,7 @@ function wrs_management(){ ...@@ -764,7 +761,7 @@ function wrs_management(){
//Reboot the switch after 1s //Reboot the switch after 1s
usleep(1000000); usleep(1000000);
shell_exec("reboot"); wrs_reboot();
...@@ -1394,4 +1391,9 @@ function echoSelectedClassIfRequestMatches($requestUri) ...@@ -1394,4 +1391,9 @@ function echoSelectedClassIfRequestMatches($requestUri)
return 'class="selected"'; return 'class="selected"';
} }
function wrs_reboot(){
sleep(1);
header ('Location: reboot.php');
}
?> ?>
...@@ -51,3 +51,44 @@ function showPopup(url) { ...@@ -51,3 +51,44 @@ function showPopup(url) {
} }
} }
/*
* Reboots the switch
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* Reboots the switch using the rebooter.php file.
* This has been done to display the "rebooting" message after any
* configuration.
*
*/
$(document).ready(
function() {
setTimeout(function() {
var path = window.location.pathname;
var page = path.split("/").pop();
if (page == "reboot.php"){
$('#rebootingtext').text("Rebooting WRS. The web interface will refresh automatically after 50s.");
$('#rebooting').load('rebooter.php');
}
}, 1500);
});
/*
* Redirects users to index.php
*
* @author José Luis Gutiérrez <jlgutierrez@ugr.es>
*
* 50 seconds after the execution of the reboot cmd, the web browser
* reloads automatically the web interface.
*
*/
$(document).ready(
function() {
setTimeout(function() {
var path = window.location.pathname;
var page = path.split("/").pop();
if (page == "reboot.php"){
window.location.href = "index.php";
}
}, 50000);
});
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
echo '<center>DHCP is now set for eth0<br>Rebooting switch</center>'; echo '<center>DHCP is now set for eth0<br>Rebooting switch</center>';
//Let's reboot //Let's reboot
shell_exec('reboot'); wrs_reboot();
} }
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
echo '<center>New static configuration saved for eth0<br>Changes will take place after reboot.</center>'; echo '<center>New static configuration saved for eth0<br>Changes will take place after reboot.</center>';
//Let's reboot //Let's reboot
shell_exec('reboot'); wrs_reboot();
} }
......
<?php include 'functions.php'; include 'head.php'; ?>
<body id="management">
<div class="main">
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
</div>
<div class="content">
<div class="leftpanel">
<h2>Main Menu</h2>
<?php include 'menu.php' ?>
</div>
<div class="rightpanel">
<div class="rightbody">
<?php session_is_started() ?>
<div id="rebootmsg">
<p align=center>
<img src="./img/loader.gif">
</p>
<br>
<div id="rebootingtext" align=center>...Saving changes...</div>
</div>
<div id="rebooting"></div>
</div>
</div>
</div>
<div class="footer">
<?php include 'footer.php' ?>
</div>
</div>
</div>
</body>
</html>
<?php
include 'functions.php';
session_start();
ob_start();
session_is_started();
// This php file must be only called from reboot.php
if(!empty($_SERVER['HTTP_REFERER'])){
shell_exec("reboot");
}else{
header('Location: index.php');
}
?>
...@@ -123,8 +123,7 @@ ...@@ -123,8 +123,7 @@
echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>'; echo '<center><font color="green">File successfully created. Rebooting switch. </font></center>';
wrs_change_wrfs("ro"); wrs_reboot();
shell_exec("reboot");
}else if(!empty($_POST['newconf']) && $error){ }else if(!empty($_POST['newconf']) && $error){
echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>'; echo '<center><font color="red">WARNING: Conf. file not created. Please fill in all fields</font></center>';
......
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