1 |
47b051eb
|
sbeaver
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* diag_reboot.php
|
4 |
191cb31d
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
d90a0e2d
|
Stephen Beaver
|
*
|
9 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* All rights reserved.
|
12 |
d90a0e2d
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14 |
|
|
* you may not use this file except in compliance with the License.
|
15 |
|
|
* You may obtain a copy of the License at
|
16 |
d90a0e2d
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18 |
d90a0e2d
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
20 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22 |
|
|
* See the License for the specific language governing permissions and
|
23 |
|
|
* limitations under the License.
|
24 |
d90a0e2d
|
Stephen Beaver
|
*/
|
25 |
5b237745
|
Scott Ullrich
|
|
26 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
27 |
|
|
##|*IDENT=page-diagnostics-rebootsystem
|
28 |
5230f468
|
jim-p
|
##|*NAME=Diagnostics: Reboot System
|
29 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page.
|
30 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=diag_reboot.php*
|
31 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
32 |
|
|
|
33 |
47b051eb
|
sbeaver
|
// Set DEBUG to true to prevent the system_reboot() function from being called
|
34 |
b191b7b1
|
Stephen Beaver
|
define("DEBUG", false);
|
35 |
47b051eb
|
sbeaver
|
|
36 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
37 |
|
|
require_once("functions.inc");
|
38 |
|
|
require_once("captiveportal.inc");
|
39 |
5b237745
|
Scott Ullrich
|
|
40 |
e226c360
|
Stephen Beaver
|
$guitimeout = 90; // Seconds to wait before reloading the page after reboot
|
41 |
|
|
$guiretry = 20; // Seconds to try again if $guitimeout was not long enough
|
42 |
59236c21
|
Stephen Beaver
|
|
43 |
a6a6ee00
|
k-paulius
|
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot"));
|
44 |
5860dad1
|
Scott Ullrich
|
include("head.inc");
|
45 |
|
|
|
46 |
dc6d4775
|
Renato Botelho
|
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (empty($_POST['override']) ||
|
47 |
|
|
($_POST['override'] != "yes"))):
|
48 |
947141fd
|
Phil Davis
|
if (DEBUG) {
|
49 |
8545adde
|
k-paulius
|
print_info_box(gettext("Not actually rebooting (DEBUG is set true)."), 'success');
|
50 |
947141fd
|
Phil Davis
|
} else {
|
51 |
89932a3d
|
Stephen Beaver
|
print('<div><pre>');
|
52 |
47b051eb
|
sbeaver
|
system_reboot();
|
53 |
89932a3d
|
Stephen Beaver
|
print('</pre></div>');
|
54 |
d90a0e2d
|
Stephen Beaver
|
}
|
55 |
99e2a6ce
|
Stephen Beaver
|
|
56 |
|
|
?>
|
57 |
f9cc072d
|
Stephen Beaver
|
|
58 |
b77cef66
|
Colin Fleming
|
<div id="countdown" class="text-center"></div>
|
59 |
99e2a6ce
|
Stephen Beaver
|
|
60 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
61 |
99e2a6ce
|
Stephen Beaver
|
//<![CDATA[
|
62 |
947141fd
|
Phil Davis
|
events.push(function() {
|
63 |
e226c360
|
Stephen Beaver
|
|
64 |
|
|
var time = 0;
|
65 |
|
|
|
66 |
|
|
function checkonline() {
|
67 |
|
|
$.ajax({
|
68 |
|
|
url : "/index.php", // or other resource
|
69 |
|
|
type : "HEAD"
|
70 |
|
|
})
|
71 |
|
|
.done(function() {
|
72 |
|
|
window.location="/index.php";
|
73 |
|
|
});
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
function startCountdown() {
|
77 |
947141fd
|
Phil Davis
|
setInterval(function() {
|
78 |
be17381d
|
Stephen Beaver
|
if (time == "<?=$guitimeout?>") {
|
79 |
c818edc9
|
Stephen Beaver
|
$('#countdown').html('<h4><?=sprintf(gettext("Rebooting%sPage will automatically reload in %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
80 |
be17381d
|
Stephen Beaver
|
}
|
81 |
|
|
|
82 |
947141fd
|
Phil Davis
|
if (time > 0) {
|
83 |
be17381d
|
Stephen Beaver
|
$('#secs').html(time);
|
84 |
e226c360
|
Stephen Beaver
|
time--;
|
85 |
|
|
} else {
|
86 |
|
|
time = "<?=$guiretry?>";
|
87 |
be17381d
|
Stephen Beaver
|
$('#countdown').html('<h4><?=sprintf(gettext("Not yet ready%s Retrying in another %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
88 |
|
|
$('#secs').html(time);
|
89 |
e226c360
|
Stephen Beaver
|
checkonline();
|
90 |
|
|
}
|
91 |
|
|
}, 1000);
|
92 |
89932a3d
|
Stephen Beaver
|
}
|
93 |
|
|
|
94 |
e226c360
|
Stephen Beaver
|
time = "<?=$guitimeout?>";
|
95 |
|
|
startCountdown();
|
96 |
|
|
|
97 |
99e2a6ce
|
Stephen Beaver
|
});
|
98 |
|
|
//]]>
|
99 |
|
|
</script>
|
100 |
|
|
<?php
|
101 |
dc6d4775
|
Renato Botelho
|
else:
|
102 |
47b051eb
|
sbeaver
|
|
103 |
ad0bbc8b
|
sbeaver
|
?>
|
104 |
|
|
|
105 |
|
|
<div class="panel panel-default">
|
106 |
162d86d1
|
Phil Davis
|
<div class="panel-heading">
|
107 |
34ee6639
|
NOYB
|
<h2 class="panel-title"><?=gettext('System Reboot Confirmation')?></h2>
|
108 |
162d86d1
|
Phil Davis
|
</div>
|
109 |
9239f765
|
Jared Dillard
|
<div class="panel-body">
|
110 |
|
|
<div class="content">
|
111 |
a11064ea
|
Jared Dillard
|
<p><?=gettext('Click "Reboot" to reboot the system immediately, or "Cancel" to go to the system dashboard without rebooting. (There will be a brief delay before the dashboard appears.)')?></p>
|
112 |
1af5edbf
|
Stephen Beaver
|
<form action="diag_reboot.php" method="post">
|
113 |
37676f4e
|
jim-p
|
<button type="submit" class="btn btn-danger pull-center" name="Submit" value="<?=gettext("Reboot")?>" title="<?=gettext("Reboot the system")?>">
|
114 |
|
|
<i class="fa fa-refresh"></i>
|
115 |
|
|
<?=gettext("Reboot")?>
|
116 |
|
|
</button>
|
117 |
6400975d
|
jim-p
|
<a href="/" class="btn btn-info">
|
118 |
|
|
<i class="fa fa-undo"></i>
|
119 |
|
|
<?=gettext("Cancel")?>
|
120 |
37676f4e
|
jim-p
|
</a>
|
121 |
9239f765
|
Jared Dillard
|
</form>
|
122 |
|
|
</div>
|
123 |
6ea2ea99
|
sbeaver
|
</div>
|
124 |
ad0bbc8b
|
sbeaver
|
</div>
|
125 |
|
|
|
126 |
669343a2
|
Stephen Beaver
|
<script type="text/javascript">
|
127 |
|
|
//<![CDATA[
|
128 |
|
|
events.push(function() {
|
129 |
|
|
//If we have been called with $_POST['override'] == "yes", then just reload the page to simulate the user clicking "Reboot"
|
130 |
|
|
if ( "<?=$_POST['override']?>" == "yes") {
|
131 |
|
|
$('form').submit();
|
132 |
|
|
}
|
133 |
|
|
});
|
134 |
|
|
//]]>
|
135 |
|
|
</script>
|
136 |
ad0bbc8b
|
sbeaver
|
<?php
|
137 |
|
|
|
138 |
dc6d4775
|
Renato Botelho
|
endif;
|
139 |
99e2a6ce
|
Stephen Beaver
|
|
140 |
89932a3d
|
Stephen Beaver
|
include("foot.inc");
|