From 17f656da4132834afea9a9fe378506b152b197de Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 6 Jun 2016 07:35:52 +0200 Subject: [PATCH] rc: adjust install mode selection --- src/etc/inc/config.console.inc | 4 ++-- src/etc/inc/services.inc | 2 +- src/etc/rc.bootup | 39 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/etc/inc/config.console.inc b/src/etc/inc/config.console.inc index 547d42f53..859b2c4b5 100644 --- a/src/etc/inc/config.console.inc +++ b/src/etc/inc/config.console.inc @@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -function timeout($timer = 9) +function timeout($timer = 7) { while (!isset($key)) { 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) if ($probe) { echo PHP_EOL . gettext('Press any key to start the manual interface assignment: '); - $key = timeout(7); + $key = timeout(); if (!isset($key)) { $interactive = false; } diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 1edadf160..0b3c556a0 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -2383,7 +2383,7 @@ function configure_cron() $autocron[] = generate_cron_job('/usr/local/etc/rc.dyndns.update', '11', '1'); /* every now and then */ - $autocron[] = generate_cron_job('/usr/local/sbin/ping_hosts.sh', '*/4'); + $autocron[] = generate_cron_job('/usr/local/sbin/ping_hosts.sh', '*/4'); if (!empty($config['system']['rrdbackup'])) { $autocron[] = generate_cron_job('/usr/local/etc/rc.backup_rrd', '0', '*/' . $config['system']['rrdbackup']); diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 350ffb941..6f1e41479 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -71,46 +71,45 @@ function is_interface_mismatch() return $do_assign; } - - function rescue_detect_keypress() { - $timeout = 9; + $timer = 7; echo "\n"; echo "(I)nstaller will be invoked by default.\n\n"; echo "(C)ontinue with LiveCD bootup instead.\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; - exec("/bin/stty erase " . chr(8)); - while (!in_array($key, array("c", "C", "r","R", "i", "I"))) { - echo chr(8) . "{$timeout}"; - `/bin/stty -icanon min 0 time 25`; - $key = trim(`KEY=\`dd count=1 2>/dev/null\`; echo \$KEY`); - `/bin/stty icanon`; - // Decrement our timeout value - $timeout--; - // If we have reached 0 exit and continue on - if ($timeout == 0) { + 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"))) { + if (in_array($key, array('r', 'R'))) { echo "Recovery shell selected...\n\n"; - touch("/tmp/donotbootup"); + touch('/tmp/donotbootup'); exit; - } elseif (in_array($key, array("c", "C"))) { + } elseif (in_array($key, array('c', 'C'))) { /* nothing */ } else { echo "Installer mode selected...\n"; - passthru("/usr/local/etc/rc.installer"); - if (file_exists("/tmp/install_complete")) { - passthru("/usr/local/etc/rc.reboot"); + passthru('/usr/local/etc/rc.installer'); + if (file_exists('/tmp/install_complete')) { + passthru('/usr/local/etc/rc.reboot'); exit; } }