1
|
<?php
|
2
|
/*
|
3
|
* diag_reboot.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* Redistribution and use in source and binary forms, with or without
|
14
|
* modification, are permitted provided that the following conditions are met:
|
15
|
*
|
16
|
* 1. Redistributions of source code must retain the above copyright notice,
|
17
|
* this list of conditions and the following disclaimer.
|
18
|
*
|
19
|
* 2. Redistributions in binary form must reproduce the above copyright
|
20
|
* notice, this list of conditions and the following disclaimer in
|
21
|
* the documentation and/or other materials provided with the
|
22
|
* distribution.
|
23
|
*
|
24
|
* 3. All advertising materials mentioning features or use of this software
|
25
|
* must display the following acknowledgment:
|
26
|
* "This product includes software developed by the pfSense Project
|
27
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
28
|
*
|
29
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
30
|
* endorse or promote products derived from this software without
|
31
|
* prior written permission. For written permission, please contact
|
32
|
* coreteam@pfsense.org.
|
33
|
*
|
34
|
* 5. Products derived from this software may not be called "pfSense"
|
35
|
* nor may "pfSense" appear in their names without prior written
|
36
|
* permission of the Electric Sheep Fencing, LLC.
|
37
|
*
|
38
|
* 6. Redistributions of any form whatsoever must retain the following
|
39
|
* acknowledgment:
|
40
|
*
|
41
|
* "This product includes software developed by the pfSense Project
|
42
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
43
|
*
|
44
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
45
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
46
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
47
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
48
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
50
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
51
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
53
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
55
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
56
|
*/
|
57
|
|
58
|
##|+PRIV
|
59
|
##|*IDENT=page-diagnostics-rebootsystem
|
60
|
##|*NAME=Diagnostics: Reboot System
|
61
|
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page.
|
62
|
##|*MATCH=diag_reboot.php*
|
63
|
##|-PRIV
|
64
|
|
65
|
// Set DEBUG to true to prevent the system_reboot() function from being called
|
66
|
define("DEBUG", false);
|
67
|
|
68
|
require_once("guiconfig.inc");
|
69
|
require_once("functions.inc");
|
70
|
require_once("captiveportal.inc");
|
71
|
|
72
|
$guitimeout = 90; // Seconds to wait before reloading the page after reboot
|
73
|
$guiretry = 20; // Seconds to try again if $guitimeout was not long enough
|
74
|
|
75
|
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot"));
|
76
|
include("head.inc");
|
77
|
|
78
|
|
79
|
if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['override'] != "yes")) {
|
80
|
if (DEBUG) {
|
81
|
print_info_box(gettext("Not actually rebooting (DEBUG is set true)."), 'success');
|
82
|
} else {
|
83
|
print('<div><pre>');
|
84
|
system_reboot();
|
85
|
print('</pre></div>');
|
86
|
}
|
87
|
|
88
|
?>
|
89
|
|
90
|
<div id="countdown" class="text-center"></div>
|
91
|
|
92
|
<script type="text/javascript">
|
93
|
//<![CDATA[
|
94
|
events.push(function() {
|
95
|
|
96
|
var time = 0;
|
97
|
|
98
|
function checkonline() {
|
99
|
$.ajax({
|
100
|
url : "/index.php", // or other resource
|
101
|
type : "HEAD"
|
102
|
})
|
103
|
.done(function() {
|
104
|
window.location="/index.php";
|
105
|
});
|
106
|
}
|
107
|
|
108
|
function startCountdown() {
|
109
|
setInterval(function() {
|
110
|
if (time == "<?=$guitimeout?>") {
|
111
|
$('#countdown').html('<h4><?=sprintf(gettext("Rebooting%sPage will automatically reload in %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
112
|
}
|
113
|
|
114
|
if (time > 0) {
|
115
|
$('#secs').html(time);
|
116
|
time--;
|
117
|
} else {
|
118
|
time = "<?=$guiretry?>";
|
119
|
$('#countdown').html('<h4><?=sprintf(gettext("Not yet ready%s Retrying in another %s seconds"), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
120
|
$('#secs').html(time);
|
121
|
checkonline();
|
122
|
}
|
123
|
}, 1000);
|
124
|
}
|
125
|
|
126
|
time = "<?=$guitimeout?>";
|
127
|
startCountdown();
|
128
|
|
129
|
});
|
130
|
//]]>
|
131
|
</script>
|
132
|
<?php
|
133
|
} else {
|
134
|
|
135
|
?>
|
136
|
|
137
|
<div class="panel panel-default">
|
138
|
<div class="panel-heading">
|
139
|
<h2 class="panel-title"><?=gettext('System Reboot Confirmation')?></h2>
|
140
|
</div>
|
141
|
<div class="panel-body">
|
142
|
<div class="content">
|
143
|
<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>
|
144
|
<form action="diag_reboot.php" method="post">
|
145
|
<button type="submit" class="btn btn-danger pull-center" name="Submit" value="<?=gettext("Reboot")?>" title="<?=gettext("Reboot the system")?>">
|
146
|
<i class="fa fa-refresh"></i>
|
147
|
<?=gettext("Reboot")?>
|
148
|
</button>
|
149
|
<a href="/" class="btn btn-info">
|
150
|
<i class="fa fa-undo"></i>
|
151
|
<?=gettext("Cancel")?>
|
152
|
</a>
|
153
|
</form>
|
154
|
</div>
|
155
|
</div>
|
156
|
</div>
|
157
|
|
158
|
<script type="text/javascript">
|
159
|
//<![CDATA[
|
160
|
events.push(function() {
|
161
|
//If we have been called with $_POST['override'] == "yes", then just reload the page to simulate the user clicking "Reboot"
|
162
|
if ( "<?=$_POST['override']?>" == "yes") {
|
163
|
$('form').submit();
|
164
|
}
|
165
|
});
|
166
|
//]]>
|
167
|
</script>
|
168
|
<?php
|
169
|
|
170
|
}
|
171
|
|
172
|
include("foot.inc");
|