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-2023 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
|
global $g;
|
39
|
|
40
|
require_once("guiconfig.inc");
|
41
|
require_once("functions.inc");
|
42
|
require_once("captiveportal.inc");
|
43
|
|
44
|
$guitimeout = 90; // Seconds to wait before reloading the page after reboot
|
45
|
$guiretry = 20; // Seconds to try again if $guitimeout was not long enough
|
46
|
|
47
|
$pgtitle = array(gettext("Diagnostics"), gettext("Reboot"));
|
48
|
$platform = system_identify_specific_platform();
|
49
|
include("head.inc");
|
50
|
|
51
|
if ($_SERVER['REQUEST_METHOD'] == 'POST'):
|
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
|
if ((php_uname('m') != 'arm') && !is_module_loaded("zfs.ko")) {
|
59
|
mwexec('/sbin/nextboot -e "pfsense.fsck.force=5"');
|
60
|
notify_all_remote(sprintf(gettext("%s is rebooting for a filesystem check now."), g_get('product_label')));
|
61
|
system_reboot();
|
62
|
}
|
63
|
break;
|
64
|
case 'Reroot':
|
65
|
notify_all_remote(sprintf(gettext("%s is rerooting now."), g_get('product_label')));
|
66
|
system_reboot_sync(true);
|
67
|
break;
|
68
|
case 'Reboot':
|
69
|
notify_all_remote(sprintf(gettext("%s is rebooting now."), g_get('product_label')));
|
70
|
system_reboot();
|
71
|
break;
|
72
|
default:
|
73
|
}
|
74
|
print('</pre></div>');
|
75
|
}
|
76
|
?>
|
77
|
|
78
|
<div id="countdown" class="text-center"></div>
|
79
|
|
80
|
<script type="text/javascript">
|
81
|
//<![CDATA[
|
82
|
events.push(function() {
|
83
|
|
84
|
var time = 0;
|
85
|
|
86
|
function checkonline() {
|
87
|
$.ajax({
|
88
|
url : "/index.php", // or other resource
|
89
|
type : "HEAD"
|
90
|
})
|
91
|
.done(function() {
|
92
|
window.location="/index.php";
|
93
|
});
|
94
|
}
|
95
|
|
96
|
function startCountdown() {
|
97
|
setInterval(function() {
|
98
|
if (time == "<?=$guitimeout?>") {
|
99
|
$('#countdown').html('<h4><?=sprintf(gettext('Rebooting%1$sPage will automatically reload in %2$s seconds'), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
100
|
}
|
101
|
|
102
|
if (time > 0) {
|
103
|
$('#secs').html(time);
|
104
|
time--;
|
105
|
} else {
|
106
|
time = "<?=$guiretry?>";
|
107
|
$('#countdown').html('<h4><?=sprintf(gettext('Not yet ready%1$s Retrying in another %2$s seconds'), "<br />", "<span id=\"secs\"></span>");?></h4>');
|
108
|
$('#secs').html(time);
|
109
|
checkonline();
|
110
|
}
|
111
|
}, 1000);
|
112
|
}
|
113
|
|
114
|
time = "<?=$guitimeout?>";
|
115
|
startCountdown();
|
116
|
|
117
|
});
|
118
|
//]]>
|
119
|
</script>
|
120
|
<?php
|
121
|
else:
|
122
|
|
123
|
$form = new Form(false);
|
124
|
|
125
|
$help = 'Select "Normal reboot" to reboot the system immediately';
|
126
|
$modeslist = ['Reboot' => 'Normal reboot'];
|
127
|
if ((php_uname('m') != 'arm') && !is_module_loaded("zfs.ko")) {
|
128
|
$help .= ', "Reboot with Filesystem Check" to reboot and run filesystem check';
|
129
|
$modeslist += ['FSCKReboot' => 'Reboot with Filesystem Check'];
|
130
|
}
|
131
|
|
132
|
$help .= ', or "Reroot" to stop processes, remount disks and re-run startup sequence';
|
133
|
$modeslist += ['Reroot' => 'Reroot'];
|
134
|
|
135
|
$help .= '.';
|
136
|
|
137
|
$section = new Form_Section('Select reboot method');
|
138
|
|
139
|
$section->addInput(new Form_Select(
|
140
|
'rebootmode',
|
141
|
'*Reboot method',
|
142
|
$rebootmode,
|
143
|
$modeslist
|
144
|
))->setHelp($help);
|
145
|
|
146
|
$form->add($section);
|
147
|
|
148
|
$form->addGlobal(new Form_Button(
|
149
|
'Submit',
|
150
|
'Submit',
|
151
|
null,
|
152
|
'fa-wrench'
|
153
|
))->addClass('btn-primary');
|
154
|
|
155
|
print $form;
|
156
|
|
157
|
endif;
|
158
|
|
159
|
include("foot.inc");
|