mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 18:14:42 +00:00
rc: clean up a bit after #1072
o Recovery console is weird, just use CTRL-C from anywhere o Simplify the early installer invoke by probing for keypress o Display a brief message when installer+SSH is active
This commit is contained in:
parent
d4ecff6f9c
commit
557e72712b
@ -250,16 +250,9 @@ echo "done."
|
||||
# let the PHP-based configuration subsystem set up the system now
|
||||
echo -n "Launching the init system..."
|
||||
touch /var/run/booting
|
||||
/usr/local/etc/rc.bootup
|
||||
/usr/local/etc/rc.bootup || exit 1
|
||||
rm /var/run/booting
|
||||
|
||||
# If a shell was selected from recovery
|
||||
# console then just drop to the shell now.
|
||||
if [ -f "/tmp/donotbootup" ]; then
|
||||
echo "Dropping to recovery shell."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Execute the normal syshook / plugin commands
|
||||
/usr/local/etc/rc.syshook start
|
||||
|
||||
|
||||
@ -62,54 +62,6 @@ function is_interface_mismatch()
|
||||
return false;
|
||||
}
|
||||
|
||||
function rescue_detect_keypress()
|
||||
{
|
||||
$timer = 7;
|
||||
|
||||
echo "\n";
|
||||
echo "Please choose your preferred boot sequence.\n\n";
|
||||
echo "(C)ontinue with system bootup (default).\n";
|
||||
echo "(I)nvoke the early installer instead.\n";
|
||||
echo "(R)ecovery mode escapes to a root shell.\n\n";
|
||||
echo "Timeout before boot continues: ";
|
||||
|
||||
$key = null;
|
||||
while (!isset($key) || !in_array($key, array('c', 'C', 'r', 'R', 'i', 'I'))) {
|
||||
if ($timer >= 9) {
|
||||
echo chr(8) . chr(8) . ($timer==9 ? chr(32) : null) . "{$timer}";
|
||||
} else {
|
||||
echo chr(8). "{$timer}";
|
||||
}
|
||||
shell_exec('/bin/stty -icanon min 0 time 25');
|
||||
$key = shell_exec('/bin/dd count=1 status=none');
|
||||
shell_exec('/bin/stty icanon');
|
||||
if ($key == '') {
|
||||
unset($key);
|
||||
}
|
||||
$timer--;
|
||||
if ($timer == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n\n";
|
||||
|
||||
if (in_array($key, array('r', 'R'))) {
|
||||
echo "Recovery shell selected...\n\n";
|
||||
touch('/tmp/donotbootup');
|
||||
exit;
|
||||
} elseif (in_array($key, array('i', 'I'))) {
|
||||
echo "Installer mode selected...\n";
|
||||
passthru('/usr/local/etc/rc.installer');
|
||||
if (file_exists('/tmp/install_complete')) {
|
||||
passthru('/usr/local/etc/rc.reboot');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* normal bootup continues... */
|
||||
}
|
||||
|
||||
echo " done.\n";
|
||||
|
||||
echo "Initializing...";
|
||||
@ -140,7 +92,6 @@ echo ".";
|
||||
require_once("openvpn.inc");
|
||||
echo ".";
|
||||
require_once("rrd.inc");
|
||||
echo ".";
|
||||
echo " done.\n";
|
||||
|
||||
/* start devd (dhclient now uses it) */
|
||||
@ -157,8 +108,21 @@ system_console_configure();
|
||||
|
||||
$setup_installer = is_install_media();
|
||||
if ($setup_installer) {
|
||||
/* display live system's early boot options */
|
||||
rescue_detect_keypress();
|
||||
echo 'Press any key to start the early installer: ';
|
||||
|
||||
$key = timeout();
|
||||
if ($key != "\n") {
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
if (isset($key)) {
|
||||
passthru('/usr/local/etc/rc.installer');
|
||||
if (file_exists('/tmp/install_complete')) {
|
||||
passthru('/usr/local/etc/rc.reboot');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* config may have changed via installer import */
|
||||
OPNsense\Core\Config::getInstance()->forceReload();
|
||||
}
|
||||
@ -175,7 +139,7 @@ echo "done.\n";
|
||||
* avoid a reboot and thats a good thing.
|
||||
*/
|
||||
if (is_interface_mismatch()) {
|
||||
echo PHP_EOL . gettext('Default interfaces not found -- Running interface assignment option.') . PHP_EOL;
|
||||
echo "\nDefault interfaces not found -- Running interface assignment option.\n";
|
||||
while (!set_networking_interfaces_ports(true));
|
||||
}
|
||||
|
||||
@ -249,7 +213,7 @@ local_sync_accounts();
|
||||
echo "done.\n";
|
||||
|
||||
/* start web server */
|
||||
echo 'Starting webConfigurator...'. (system_webgui_configure() ? 'done.' : 'failed.') . PHP_EOL;
|
||||
echo 'Starting webConfigurator...'. (system_webgui_configure() ? "done.\n" : "failed.\n");
|
||||
|
||||
/* configure cron service */
|
||||
echo "Configuring CRON...";
|
||||
@ -370,5 +334,12 @@ if ($setup_installer) {
|
||||
local_user_set($root);
|
||||
|
||||
mwexec("/usr/local/etc/rc.sshd installer");
|
||||
|
||||
echo "\n";
|
||||
echo "Welcome! Both `root' and `installer' users are availabe for system\n";
|
||||
echo "setup or invoking the installer, respectively. The predefined root\n";
|
||||
echo "password works for both accounts. Remote login via SSH is possible.\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2014-2015 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2014-2016 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2004-2011 Scott Ullrich <sullrich@gmail.com>
|
||||
# Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>
|
||||
# All rights reserved.
|
||||
@ -9,14 +9,6 @@
|
||||
trap : 2
|
||||
trap : 3
|
||||
|
||||
# If recovery console shell option has been specified
|
||||
if [ -f "/tmp/donotbootup" ]; then
|
||||
rm /tmp/donotbootup
|
||||
/bin/csh
|
||||
/usr/local/etc/rc.reboot
|
||||
# no coming back from here
|
||||
fi
|
||||
|
||||
# shell started with parameters, passthrough to real shell
|
||||
if [ -n "${*}" ]; then
|
||||
/bin/csh "${@}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user