Commit a89d2ce4 authored by Franco Fichtner's avatar Franco Fichtner

rc: adjust install mode selection

(cherry picked from commit 17f656da)
parent c36010b6
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
function timeout($timer = 9) function timeout($timer = 7)
{ {
while (!isset($key)) { while (!isset($key)) {
if ($timer >= 9) { echo chr(8) . chr(8) . ($timer==9 ? chr(32) : null) . "{$timer}"; } if ($timer >= 9) { echo chr(8) . chr(8) . ($timer==9 ? chr(32) : null) . "{$timer}"; }
...@@ -64,7 +64,7 @@ function set_networking_interfaces_ports($probe = false) ...@@ -64,7 +64,7 @@ function set_networking_interfaces_ports($probe = false)
if ($probe) { if ($probe) {
echo PHP_EOL . gettext('Press any key to start the manual interface assignment: '); echo PHP_EOL . gettext('Press any key to start the manual interface assignment: ');
$key = timeout(7); $key = timeout();
if (!isset($key)) { if (!isset($key)) {
$interactive = false; $interactive = false;
} }
......
...@@ -71,46 +71,45 @@ function is_interface_mismatch() ...@@ -71,46 +71,45 @@ function is_interface_mismatch()
return $do_assign; return $do_assign;
} }
function rescue_detect_keypress() function rescue_detect_keypress()
{ {
$timeout = 9; $timer = 7;
echo "\n"; echo "\n";
echo "(I)nstaller will be invoked by default.\n\n"; echo "(I)nstaller will be invoked by default.\n\n";
echo "(C)ontinue with LiveCD bootup instead.\n\n"; echo "(C)ontinue with LiveCD bootup instead.\n\n";
echo "(R)ecovery mode escapes to a root shell.\n\n"; echo "(R)ecovery mode escapes to a root shell.\n\n";
echo "Timeout before auto boot continues (seconds): {$timeout}"; echo "Timeout before auto boot continues (seconds): ";
$key = null; $key = null;
exec("/bin/stty erase " . chr(8)); while (!isset($key) || !in_array($key, array('c', 'C', 'r', 'R', 'i', 'I'))) {
while (!in_array($key, array("c", "C", "r","R", "i", "I"))) { if ($timer >= 9) { echo chr(8) . chr(8) . ($timer==9 ? chr(32) : null) . "{$timer}"; }
echo chr(8) . "{$timeout}"; else { echo chr(8). "{$timer}"; }
`/bin/stty -icanon min 0 time 25`; shell_exec('/bin/stty -icanon min 0 time 25');
$key = trim(`KEY=\`dd count=1 2>/dev/null\`; echo \$KEY`); $key = shell_exec('/bin/dd count=1 status=none');
`/bin/stty icanon`; shell_exec('/bin/stty icanon');
// Decrement our timeout value if ($key == '') {
$timeout--; unset($key);
// If we have reached 0 exit and continue on }
if ($timeout == 0) { $timer--;
if ($timer == 0) {
break; break;
} }
} }
echo "\n\n"; echo "\n\n";
if (in_array($key, array("r", "R"))) { if (in_array($key, array('r', 'R'))) {
echo "Recovery shell selected...\n\n"; echo "Recovery shell selected...\n\n";
touch("/tmp/donotbootup"); touch('/tmp/donotbootup');
exit; exit;
} elseif (in_array($key, array("c", "C"))) { } elseif (in_array($key, array('c', 'C'))) {
/* nothing */ /* nothing */
} else { } else {
echo "Installer mode selected...\n"; echo "Installer mode selected...\n";
passthru("/usr/local/etc/rc.installer"); passthru('/usr/local/etc/rc.installer');
if (file_exists("/tmp/install_complete")) { if (file_exists('/tmp/install_complete')) {
passthru("/usr/local/etc/rc.reboot"); passthru('/usr/local/etc/rc.reboot');
exit; exit;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment