1 |
47b051eb
|
sbeaver
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
1af5edbf
|
Stephen Beaver
|
diag_reboot.php
|
4 |
5b237745
|
Scott Ullrich
|
*/
|
5 |
d90a0e2d
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
191cb31d
|
Stephen Beaver
|
*
|
8 |
cb41dd63
|
Renato Botelho
|
* Some or all of this file is based on the m0n0wall project which is
|
9 |
|
|
* Copyright (c) 2004 Manuel Kasper (BSD 2 clause)
|
10 |
d90a0e2d
|
Stephen Beaver
|
*
|
11 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
|
|
* are permitted provided that the following conditions are met:
|
13 |
|
|
*
|
14 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
* this list of conditions and the following disclaimer.
|
16 |
|
|
*
|
17 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
* notice, this list of conditions and the following disclaimer in
|
19 |
|
|
* the documentation and/or other materials provided with the
|
20 |
|
|
* distribution.
|
21 |
|
|
*
|
22 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
23 |
|
|
* must display the following acknowledgment:
|
24 |
|
|
* "This product includes software developed by the pfSense Project
|
25 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
26 |
|
|
*
|
27 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
28 |
|
|
* endorse or promote products derived from this software without
|
29 |
|
|
* prior written permission. For written permission, please contact
|
30 |
|
|
* coreteam@pfsense.org.
|
31 |
|
|
*
|
32 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
33 |
|
|
* nor may "pfSense" appear in their names without prior written
|
34 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
35 |
|
|
*
|
36 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
37 |
|
|
* acknowledgment:
|
38 |
|
|
*
|
39 |
|
|
* "This product includes software developed by the pfSense Project
|
40 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
41 |
|
|
*
|
42 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
43 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
45 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
46 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
47 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
48 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
50 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
51 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
52 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
53 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
54 |
|
|
*
|
55 |
|
|
* ====================================================================
|
56 |
|
|
*
|
57 |
|
|
*/
|
58 |
5b237745
|
Scott Ullrich
|
|
59 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
60 |
|
|
##|*IDENT=page-diagnostics-rebootsystem
|
61 |
5230f468
|
jim-p
|
##|*NAME=Diagnostics: Reboot System
|
62 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page.
|
63 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=diag_reboot.php*
|
64 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
65 |
|
|
|
66 |
47b051eb
|
sbeaver
|
// Set DEBUG to true to prevent the system_reboot() function from being called
|
67 |
b191b7b1
|
Stephen Beaver
|
define("DEBUG", false);
|
68 |
47b051eb
|
sbeaver
|
|
69 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
70 |
c44417f8
|
Scott Ullrich
|
require("functions.inc");
|
71 |
|
|
require("captiveportal.inc");
|
72 |
5b237745
|
Scott Ullrich
|
|
73 |
e226c360
|
Stephen Beaver
|
$guitimeout = 90; // Seconds to wait before reloading the page after reboot
|
74 |
|
|
$guiretry = 20; // Seconds to try again if $guitimeout was not long enough
|
75 |
59236c21
|
Stephen Beaver
|
|
76 |
947141fd
|
Phil Davis
|
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot System"));
|
77 |
5860dad1
|
Scott Ullrich
|
include("head.inc");
|
78 |
|
|
|
79 |
6ea2ea99
|
sbeaver
|
|
80 |
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
81 |
947141fd
|
Phil Davis
|
if (DEBUG) {
|
82 |
89932a3d
|
Stephen Beaver
|
print_info_box("Not actually rebooting (DEBUG is set true)", success);
|
83 |
947141fd
|
Phil Davis
|
} else {
|
84 |
89932a3d
|
Stephen Beaver
|
print('<div><pre>');
|
85 |
47b051eb
|
sbeaver
|
system_reboot();
|
86 |
89932a3d
|
Stephen Beaver
|
print('</pre></div>');
|
87 |
d90a0e2d
|
Stephen Beaver
|
}
|
88 |
99e2a6ce
|
Stephen Beaver
|
|
89 |
|
|
?>
|
90 |
f9cc072d
|
Stephen Beaver
|
|
91 |
99e2a6ce
|
Stephen Beaver
|
<div id="countdown" style="text-align: center;"></div>
|
92 |
|
|
|
93 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
94 |
99e2a6ce
|
Stephen Beaver
|
//<![CDATA[
|
95 |
947141fd
|
Phil Davis
|
events.push(function() {
|
96 |
e226c360
|
Stephen Beaver
|
|
97 |
|
|
var timeoutmsg = '<h4>Rebooting<br />Page will automatically reload in ';
|
98 |
|
|
var time = 0;
|
99 |
|
|
|
100 |
|
|
function checkonline() {
|
101 |
|
|
$.ajax({
|
102 |
|
|
url : "/index.php", // or other resource
|
103 |
|
|
type : "HEAD"
|
104 |
|
|
})
|
105 |
|
|
.done(function() {
|
106 |
|
|
window.location="/index.php";
|
107 |
|
|
});
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
function startCountdown() {
|
111 |
947141fd
|
Phil Davis
|
setInterval(function() {
|
112 |
|
|
if (time > 0) {
|
113 |
e226c360
|
Stephen Beaver
|
$('#countdown').html(timeoutmsg + time + ' seconds.</h4>');
|
114 |
|
|
time--;
|
115 |
|
|
} else {
|
116 |
|
|
time = "<?=$guiretry?>";
|
117 |
|
|
timeoutmsg = '<h4>Not yet ready<br />Retrying in another ';
|
118 |
|
|
checkonline();
|
119 |
|
|
}
|
120 |
|
|
}, 1000);
|
121 |
89932a3d
|
Stephen Beaver
|
}
|
122 |
|
|
|
123 |
e226c360
|
Stephen Beaver
|
time = "<?=$guitimeout?>";
|
124 |
|
|
startCountdown();
|
125 |
|
|
|
126 |
99e2a6ce
|
Stephen Beaver
|
});
|
127 |
|
|
//]]>
|
128 |
|
|
</script>
|
129 |
|
|
<?php
|
130 |
47b051eb
|
sbeaver
|
} else {
|
131 |
|
|
|
132 |
ad0bbc8b
|
sbeaver
|
?>
|
133 |
|
|
|
134 |
|
|
<div class="panel panel-default">
|
135 |
f17594c7
|
Sjon Hortensius
|
<div class="panel-heading"><h2 class="panel-title">Are you sure you want to reboot the system?</h2></div>
|
136 |
9239f765
|
Jared Dillard
|
<div class="panel-body">
|
137 |
|
|
<div class="content">
|
138 |
|
|
<p>Click "Reboot" to reboot the system immediately, or "No" to go to the system dashboard without rebooting. (There will be a brief delay before the dashboard appears.)</p>
|
139 |
1af5edbf
|
Stephen Beaver
|
<form action="diag_reboot.php" method="post">
|
140 |
9239f765
|
Jared Dillard
|
<input type="submit" class="btn btn-danger pull-center" name="Submit" value="Reboot">
|
141 |
|
|
<a href="/" class="btn btn-default">No</a>
|
142 |
|
|
</form>
|
143 |
|
|
</div>
|
144 |
6ea2ea99
|
sbeaver
|
</div>
|
145 |
ad0bbc8b
|
sbeaver
|
</div>
|
146 |
|
|
|
147 |
|
|
<?php
|
148 |
|
|
|
149 |
47b051eb
|
sbeaver
|
}
|
150 |
99e2a6ce
|
Stephen Beaver
|
|
151 |
89932a3d
|
Stephen Beaver
|
include("foot.inc");
|
152 |
47b051eb
|
sbeaver
|
|