Project

General

Profile

Download (2.7 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php-cgi -f
2
<?php
3
/*
4
 * rc.initial.reboot
5
 *
6
 * part of pfSense (https://www.pfsense.org)
7
 * Copyright (c) 2004-2013 BSD Perimeter
8
 * Copyright (c) 2013-2016 Electric Sheep Fencing
9
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
10
 * All rights reserved.
11
 *
12
 * originally part of m0n0wall (http://m0n0.ch/wall)
13
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
14
 * All rights reserved.
15
 *
16
 * 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
 *
20
 * http://www.apache.org/licenses/LICENSE-2.0
21
 *
22
 * 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
 */
28

    
29
/* 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

    
35
$fp = fopen('php://stdin', 'r');
36

    
37
echo "\n" . sprintf(gettext("%s will reboot. This may take a few minutes, depending on your hardware."), $g['product_label']) . "\n";
38
echo gettext("Do you want to proceed?") . "\n\n";
39
echo "    " . gettext("Y/y: Reboot normally") . "\n";
40
echo "    " . gettext("R/r: Reroot (Stop processes, remount disks, re-run startup sequence)") . "\n";
41
echo "    " . gettext("S: Reboot into Single User Mode (requires console access!)") . "\n";
42
if (!is_module_loaded("zfs.ko")) {
43
	echo "    " . gettext("F: Reboot and run a filesystem check") . "\n\n";
44
}
45

    
46
echo gettext("Enter an option:") . " ";
47

    
48
switch (chop(fgets($fp))) {
49
	case "S":
50
		mwexec('/sbin/nextboot -o "-s" -k kernel');
51
		$msg = sprintf(gettext("%s is rebooting into single user mode now."), $g['product_label']);
52
		echo "\n" . $msg . "\n";
53
		notify_all_remote($msg);
54
		system_reboot_sync();
55
		break;
56
	case "F":
57
		if (!is_module_loaded("zfs.ko")) {
58
			mwexec('/sbin/nextboot -e "pfsense.fsck.force=5"');
59
			$msg = sprintf(gettext("%s is rebooting for a filesystem check now."), $g['product_label']);
60
			echo "\n" . $msg . "\n";
61
			notify_all_remote($msg);
62
			system_reboot_sync();
63
		}
64
		break;
65
	case "R":
66
	case "r":
67
		$msg = sprintf(gettext("%s is rerooting now."), $g['product_label']);
68
		echo "\n" . $msg . "\n";
69
		notify_all_remote($msg);
70
		system_reboot_sync(true);
71
		break;
72
	case "Y":
73
	case "y":
74
		$msg = sprintf(gettext("%s is rebooting now."), $g['product_label']);
75
		echo "\n" . $msg . "\n";
76
		notify_all_remote($msg);
77
		system_reboot_sync();
78
		break;
79
	default:
80
		break;
81
}
82

    
83
fclose($fp);
84
echo "\n";
85
?>
(44-44/85)