Revision 916b6353
Added by Viktor Gurov almost 6 years ago
src/usr/local/www/diag_reboot.php | ||
---|---|---|
1 |
<?php |
|
2 |
/* |
|
3 |
* diag_reboot.php |
|
4 |
* |
|
5 |
* part of pfSense (https://www.pfsense.org) |
|
6 |
* Copyright (c) 2004-2013 BSD Perimeter |
|
7 |
* Copyright (c) 2013-2016 Electric Sheep Fencing |
|
8 |
* Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate) |
|
9 |
* All rights reserved. |
|
10 |
* |
|
11 |
* originally based on m0n0wall (http://m0n0.ch/wall) |
|
12 |
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>. |
|
13 |
* All rights reserved. |
|
14 |
* |
|
15 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
16 |
* you may not use this file except in compliance with the License. |
|
17 |
* You may obtain a copy of the License at |
|
18 |
* |
|
19 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
20 |
* |
|
21 |
* Unless required by applicable law or agreed to in writing, software |
|
22 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
23 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
24 |
* See the License for the specific language governing permissions and |
|
25 |
* limitations under the License. |
|
26 |
*/ |
|
27 |
|
|
28 |
##|+PRIV |
|
29 |
##|*IDENT=page-diagnostics-rebootsystem |
|
30 |
##|*NAME=Diagnostics: Reboot System |
|
31 |
##|*DESCR=Allow access to the 'Diagnostics: Reboot System' page. |
|
32 |
##|*MATCH=diag_reboot.php* |
|
33 |
##|-PRIV |
|
34 |
|
|
35 |
// Set DEBUG to true to prevent the system_reboot() function from being called |
|
36 |
define("DEBUG", false); |
|
37 |
|
|
38 |
require_once("guiconfig.inc"); |
|
39 |
require_once("functions.inc"); |
|
40 |
require_once("captiveportal.inc"); |
|
41 |
|
|
42 |
$guitimeout = 90; // Seconds to wait before reloading the page after reboot |
|
43 |
$guiretry = 20; // Seconds to try again if $guitimeout was not long enough |
|
44 |
|
|
45 |
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot")); |
|
46 |
$platform = system_identify_specific_platform(); |
|
47 |
$no_options = array('SG-1100', 'ROGUE-1', 'uFW'); |
|
48 |
include("head.inc"); |
|
49 |
|
|
50 |
if (($_SERVER['REQUEST_METHOD'] == 'POST') && (empty($_POST['override']) || |
|
51 |
($_POST['override'] != "yes"))): |
|
52 |
if (DEBUG) { |
|
53 |
print_info_box(gettext("Not actually rebooting (DEBUG is set true)."), 'success'); |
|
54 |
} else { |
|
55 |
print('<div><pre>'); |
|
56 |
switch ($_POST['rebootmode']) { |
|
57 |
case 'FSCKReboot': |
|
58 |
<<<<<<< HEAD |
|
59 |
if (!in_array($platform['name'], $no_options)) { |
|
60 |
mwexec('/sbin/nextboot -e "pfsense.fsck.force=5"'); |
|
61 |
system_reboot(); |
|
62 |
} |
|
63 |
======= |
|
64 |
mwexec('/sbin/nextboot -e "pfsense.fsck.force=5"'); |
|
65 |
system_reboot(); |
|
66 |
>>>>>>> master |
|
67 |
break; |
|
68 |
case 'Reroot': |
|
69 |
if (!is_module_loaded("zfs.ko")) { |
|
70 |
system_reboot_sync(true); |
|
71 |
} |
|
72 |
break; |
|
73 |
case 'Reboot': |
|
74 |
system_reboot(); |
|
75 |
break; |
|
76 |
default: |
|
77 |
} |
|
78 |
print('</pre></div>'); |
|
79 |
} |
|
80 |
?> |
|
81 |
|
|
82 |
<div id="countdown" class="text-center"></div> |
|
83 |
|
|
84 |
<script type="text/javascript"> |
|
85 |
//<![CDATA[ |
|
86 |
events.push(function() { |
|
87 |
|
|
88 |
var time = 0; |
|
89 |
|
|
90 |
function checkonline() { |
|
91 |
$.ajax({ |
|
92 |
url : "/index.php", // or other resource |
|
93 |
type : "HEAD" |
|
94 |
}) |
|
95 |
.done(function() { |
|
96 |
window.location="/index.php"; |
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
function startCountdown() { |
|
101 |
setInterval(function() { |
|
102 |
if (time == "<?=$guitimeout?>") { |
|
103 |
$('#countdown').html('<h4><?=sprintf(gettext('Rebooting%1$sPage will automatically reload in %2$s seconds'), "<br />", "<span id=\"secs\"></span>");?></h4>'); |
|
104 |
} |
|
105 |
|
|
106 |
if (time > 0) { |
|
107 |
$('#secs').html(time); |
|
108 |
time--; |
|
109 |
} else { |
|
110 |
time = "<?=$guiretry?>"; |
|
111 |
$('#countdown').html('<h4><?=sprintf(gettext('Not yet ready%1$s Retrying in another %2$s seconds'), "<br />", "<span id=\"secs\"></span>");?></h4>'); |
|
112 |
$('#secs').html(time); |
|
113 |
checkonline(); |
|
114 |
} |
|
115 |
}, 1000); |
|
116 |
} |
|
117 |
|
|
118 |
time = "<?=$guitimeout?>"; |
|
119 |
startCountdown(); |
|
120 |
|
|
121 |
}); |
|
122 |
//]]> |
|
123 |
</script> |
|
124 |
<?php |
|
125 |
else: |
|
126 |
|
|
127 |
$form = new Form(false); |
|
128 |
|
|
129 |
<<<<<<< HEAD |
|
130 |
$help = 'Click "Normal reboot" to reboot the system immediately'; |
|
131 |
$modeslist = ['Reboot' => 'Normal reboot']; |
|
132 |
if (!in_array($platform['name'], $no_options)) { |
|
133 |
$help .= ', "Reboot with Filesystem Check" to reboot and run filesystem check'; |
|
134 |
$modeslist += ['FSCKReboot' => 'Reboot with Filesystem Check']; |
|
135 |
} |
|
136 |
======= |
|
137 |
$help = 'Click "Normal reboot" to reboot the system immediately, "Reboot with Filessystem Check" to reboot and run filesystem check'; |
|
138 |
$modeslist = ['Reboot' => 'Normal reboot', 'FSCKReboot' => 'Reboot with Filesystem Check']; |
|
139 |
>>>>>>> master |
|
140 |
if (!is_module_loaded("zfs.ko")) { |
|
141 |
$help .= ' or "Reroot" to stop processes, remount disks and re-run startup sequence'; |
|
142 |
$modeslist += ['Reroot' => 'Reroot']; |
|
143 |
} |
|
144 |
$help .= '.'; |
|
145 |
|
|
146 |
$section = new Form_Section('Select reboot method'); |
|
147 |
<<<<<<< HEAD |
|
148 |
|
|
149 |
$section->addInput(new Form_Select( |
|
150 |
'rebootmode', |
|
151 |
'*Reboot method', |
|
152 |
$rebootmode, |
|
153 |
$modeslist |
|
154 |
))->setHelp($help); |
|
155 |
|
|
156 |
$form->add($section); |
|
157 |
|
|
158 |
$form->addGlobal(new Form_Button( |
|
159 |
'Submit', |
|
160 |
'Submit', |
|
161 |
null, |
|
162 |
'fa-wrench' |
|
163 |
))->addClass('btn-primary'); |
|
164 |
|
|
165 |
print $form; |
|
166 |
?> |
|
167 |
|
|
168 |
======= |
|
169 |
|
|
170 |
$section->addInput(new Form_Select( |
|
171 |
'rebootmode', |
|
172 |
'*Reboot method', |
|
173 |
$rebootmode, |
|
174 |
$modeslist |
|
175 |
))->setHelp($help); |
|
176 |
|
|
177 |
$form->add($section); |
|
178 |
|
|
179 |
$form->addGlobal(new Form_Button( |
|
180 |
'Submit', |
|
181 |
'Submit', |
|
182 |
null, |
|
183 |
'fa-wrench' |
|
184 |
))->addClass('btn-primary'); |
|
185 |
|
|
186 |
print $form; |
|
187 |
?> |
|
188 |
|
|
189 |
>>>>>>> master |
|
190 |
<script type="text/javascript"> |
|
191 |
//<![CDATA[ |
|
192 |
events.push(function() { |
|
193 |
//If we have been called with $_POST['override'] == "yes", then just reload the page to simulate the user clicking "Reboot" |
|
194 |
if ( "<?=$_POST['override']?>" == "yes") { |
|
195 |
$('form').submit(); |
|
196 |
} |
|
197 |
}); |
|
198 |
//]]> |
|
199 |
</script> |
|
200 |
<?php |
|
201 |
|
|
202 |
endif; |
|
203 |
|
|
204 |
include("foot.inc"); |
Also available in: Unified diff
fix