Project

General

Profile

Download (2.53 KB) Statistics
| Branch: | Tag: | Revision:
1 cb7d18d5 Renato Botelho
#!/usr/local/bin/php-cgi -f
2 5b237745 Scott Ullrich
<?php
3
/*
4 ac24dc24 Renato Botelho
 * rc.initial.reboot
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9
 * Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
10 ac24dc24 Renato Botelho
 * All rights reserved.
11
 *
12
 * originally part of m0n0wall (http://m0n0.ch/wall)
13 c5d81585 Renato Botelho
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
14 ac24dc24 Renato Botelho
 * All rights reserved.
15
 *
16 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
17
 * you may not use this file except in compliance with the License.
18
 * You may obtain a copy of the License at
19 ac24dc24 Renato Botelho
 *
20 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
21 ac24dc24 Renato Botelho
 *
22 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
23
 * distributed under the License is distributed on an "AS IS" BASIS,
24
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
 * See the License for the specific language governing permissions and
26
 * limitations under the License.
27 ac24dc24 Renato Botelho
 */
28 e3c4b6b7 Scott Ullrich
29 ac24dc24 Renato Botelho
/* parse the configuration and include all functions used below */
30
require_once("config.inc");
31
require_once("functions.inc");
32
require_once("filter.inc");
33
require_once("captiveportal.inc");
34 e3c4b6b7 Scott Ullrich
35 ac24dc24 Renato Botelho
$fp = fopen('php://stdin', 'r');
36 e3c4b6b7 Scott Ullrich
37 ac24dc24 Renato Botelho
echo "\n" . sprintf(gettext("%s will reboot. This may take a few minutes, depending on your hardware."), $g['product_name']) . "\n";
38 92a78939 jim-p
echo gettext("Do you want to proceed?") . "\n\n";
39
echo "    " . gettext("Y/y: Reboot normally") . "\n";
40 ce3a92c0 jim-p
if (!is_module_loaded("zfs.ko")) {
41
	echo "    " . gettext("R/r: Reroot (Stop processes, remount disks, re-run startup sequence)") . "\n";
42
}
43 92a78939 jim-p
echo "    " . gettext("S: Reboot into Single User Mode (requires console access!)") . "\n";
44
echo "    " . gettext("F: Reboot and run a filesystem check") . "\n\n";
45 e3c4b6b7 Scott Ullrich
46 92a78939 jim-p
echo gettext("Enter an option:") . " ";
47
48
switch (chop(fgets($fp))) {
49
	case "S":
50
		mwexec('/sbin/nextboot -o "-s" -k kernel');
51
		echo "\n" . sprintf(gettext("%s is rebooting into single user mode now."), $g['product_name']) . "\n";
52
		system_reboot_sync();
53
		break;
54
	case "F":
55
		mwexec('/sbin/nextboot -e "pfsense.fsck.force=5"');
56
		echo "\n" . sprintf(gettext("%s is rebooting for a filesystem check now."), $g['product_name']) . "\n";
57
		system_reboot_sync();
58
		break;
59 a2c453fd jim-p
	case "R":
60
	case "r":
61 ce3a92c0 jim-p
		if (!is_module_loaded("zfs.ko")) {
62
			echo "\n" . sprintf(gettext("%s is rerooting now."), $g['product_name']) . "\n";
63
			system_reboot_sync(true);
64
		}
65 a2c453fd jim-p
		break;
66 92a78939 jim-p
	case "Y":
67
	case "y":
68
		echo "\n" . sprintf(gettext("%s is rebooting now."), $g['product_name']) . "\n";
69
		system_reboot_sync();
70
		break;
71 a2c453fd jim-p
	default:
72
		break;
73 ac24dc24 Renato Botelho
}
74 e3c4b6b7 Scott Ullrich
75 ac24dc24 Renato Botelho
fclose($fp);
76 92a78939 jim-p
echo "\n";
77 55c61326 Ermal Lu?i
?>