Commit aaa15968 authored by Franco Fichtner's avatar Franco Fichtner

rc: some defaults for the questions...

parent e9dbd8fd
...@@ -2,30 +2,31 @@ ...@@ -2,30 +2,31 @@
<?php <?php
/* /*
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. * Copyright (C) 2017 Franco Fichtner <franco@opnsense.org>
All rights reserved. * Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* All rights reserved.
Redistribution and use in source and binary forms, with or without *
modification, are permitted provided that the following conditions are met: * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, *
this list of conditions and the following disclaimer. * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright *
notice, this list of conditions and the following disclaimer in the * 2. Redistributions in binary form must reproduce the above copyright
documentation and/or other materials provided with the distribution. * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, *
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*/ * POSSIBILITY OF SUCH DAMAGE.
*/
require_once("config.inc"); require_once("config.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
...@@ -43,7 +44,7 @@ function console_prompt_for_yn($prompt_text, $default = '') ...@@ -43,7 +44,7 @@ function console_prompt_for_yn($prompt_text, $default = '')
$prompt_yn = sprintf('[%s/%s] ', $default == 'y' ? 'Y' : 'y', $default == 'n' ? 'N' : 'n'); $prompt_yn = sprintf('[%s/%s] ', $default == 'y' ? 'Y' : 'y', $default == 'n' ? 'N' : 'n');
while (true) { while (true) {
echo "\n{$prompt_text} {$prompt_yn}"; echo "{$prompt_text} {$prompt_yn}";
switch (strtolower(chop(fgets($fp)))) { switch (strtolower(chop(fgets($fp)))) {
case 'y': case 'y':
return true; return true;
...@@ -93,9 +94,9 @@ function prompt_for_enable_dhcp_server($version = 4) ...@@ -93,9 +94,9 @@ function prompt_for_enable_dhcp_server($version = 4)
return false; return false;
} }
$label_DHCP = ($version === 6) ? "DHCP6" : "DHCP"; $label_DHCP = ($version === 6) ? 'DHCP6' : 'DHCP';
$upperifname = strtoupper($interface); $upperifname = strtoupper($interface);
return console_prompt_for_yn(sprintf('Do you want to enable the %s server on %s?', $label_DHCP, $upperifname)); return console_prompt_for_yn(sprintf('Do you want to enable the %s server on %s?', $label_DHCP, $upperifname), 'y');
} }
function get_interface_config_description($iface) function get_interface_config_description($iface)
...@@ -245,14 +246,14 @@ function console_configure_ip_address($version) ...@@ -245,14 +246,14 @@ function console_configure_ip_address($version)
$upperifname = strtoupper($interface); $upperifname = strtoupper($interface);
if ($interface == "wan") { if ($interface == 'wan') {
if (console_prompt_for_yn(sprintf('Configure %s address %s interface via %s?', $label_IPvX, $upperifname, $label_DHCP))) { if (console_prompt_for_yn(sprintf('Configure %s address %s interface via %s?', $label_IPvX, $upperifname, $label_DHCP), 'y')) {
$ifppp = console_get_interface_from_ppp(get_real_interface("wan")); $ifppp = console_get_interface_from_ppp(get_real_interface('wan'));
if (!empty($ifppp)) { if (!empty($ifppp)) {
$ifaceassigned = $ifppp; $ifaceassigned = $ifppp;
} }
$intip = ($version === 6) ? "dhcp6" : "dhcp"; $intip = ($version === 6) ? 'dhcp6' : 'dhcp';
$intbits = ""; $intbits = '';
$isintdhcp = true; $isintdhcp = true;
$restart_dhcpd = true; $restart_dhcpd = true;
} }
...@@ -424,15 +425,15 @@ console_configure_dhcpd(6); ...@@ -424,15 +425,15 @@ console_configure_dhcpd(6);
//***************************************************************************** //*****************************************************************************
if ($config['system']['webgui']['protocol'] == "https") { if ($config['system']['webgui']['protocol'] == 'https') {
if (console_prompt_for_yn('Do you want to revert to HTTP as the web GUI protocol?')) { if (console_prompt_for_yn('Do you want to revert to HTTP as the web GUI protocol?', 'n')) {
$config['system']['webgui']['protocol'] = "http"; $config['system']['webgui']['protocol'] = 'http';
$restart_webgui = true; $restart_webgui = true;
} }
} }
if (isset($config['system']['webgui']['noantilockout'])) { if (isset($config['system']['webgui']['noantilockout'])) {
echo "\n" . sprintf('Note: the anti-lockout rule on %s has been re-enabled.', $interface) . "\n"; echo sprintf("Note: the anti-lockout rule on %s has been re-enabled.\n", $interface);
unset($config['system']['webgui']['noantilockout']); unset($config['system']['webgui']['noantilockout']);
} }
...@@ -538,7 +539,5 @@ if ($intip != '' || $intip6 != '') { ...@@ -538,7 +539,5 @@ if ($intip != '' || $intip6 != '') {
} }
} }
echo "\nPress <ENTER> to continue."; /* rest now or hit CTRL-C */
sleep(3);
fgets($fp);
fclose($fp);
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