Commit cca7eda6 authored by Franco Fichtner's avatar Franco Fichtner

config: clean up more code paths, whew; #5

Always unload LAN if previously set.  Otherwise no code changes.
parent daa5462f
......@@ -149,11 +149,11 @@ EOD;
}
} while (!$lanif);
while ($lanif != '') {
/* optional interfaces */
$optif = array();
$i = 0;
if ($lanif != '') {
while (1) {
if ($optif[$i])
$i++;
......@@ -188,6 +188,8 @@ EOD;
/* check for double assignments */
$ifarr = array_merge(array($lanif, $wanif), $optif);
$again = false;
for ($i = 0; $i < (count($ifarr)-1); $i++) {
for ($j = ($i+1); $j < count($ifarr); $j++) {
if ($ifarr[$i] == $ifarr[$j]) {
......@@ -196,12 +198,16 @@ EOD;
Error: you cannot assign the same interface name twice!
EOD;
fclose($fp);
return false;
$again = true;
}
}
}
if ($again) {
continue;
}
echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n";
echo "WAN -> " . $wanif . "\n";
......@@ -221,54 +227,18 @@ EOD;
$key = 'y';
echo $key . PHP_EOL;
}
}
if (!$interactive) {
$key = 'y';
if (in_array($key, array('y', 'Y'))) {
break;
}
}
if (in_array($key, array('y', 'Y'))) {
if ($lanif) {
if (!is_array($config['interfaces']['lan'])) {
$config['interfaces']['lan'] = array();
}
$config['interfaces']['lan']['if'] = $lanif;
$config['interfaces']['lan']['enable'] = true;
} elseif (!file_exists('/var/run/booting') &&
isset($config['interfaces']['lan'])) {
echo <<<EODD
You have chosen to remove the LAN interface.
Would you like to remove the LAN IP address and
unload the interface now ${yes_no_prompt}
EODD;
if ($interactive) {
$key = chop(fgets($fp));
} else {
$key = 'y';
echo $key . PHP_EOL;
}
if (strcasecmp($key, 'y') == 0) {
if(isset($config['interfaces']['lan']) && $config['interfaces']['lan']['if'])
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
}
if(isset($config['interfaces']['lan']))
unset($config['interfaces']['lan']);
if(isset($config['dhcpd']['lan']))
unset($config['dhcpd']['lan']);
if(isset($config['interfaces']['lan']['if']))
unset($config['interfaces']['lan']['if']);
if(isset($config['interfaces']['wan']['blockpriv']))
unset($config['interfaces']['wan']['blockpriv']);
if(isset($config['shaper']))
unset($config['shaper']);
if(isset($config['ezshaper']))
unset($config['ezshaper']);
if(isset($config['nat']))
unset($config['nat']);
} else {
if(isset($config['interfaces']['lan']['if']))
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
......@@ -280,10 +250,6 @@ EODD;
unset($config['interfaces']['lan']['if']);
if(isset($config['interfaces']['wan']['blockpriv']))
unset($config['interfaces']['wan']['blockpriv']);
if(isset($config['shaper']))
unset($config['shaper']);
if(isset($config['ezshaper']))
unset($config['ezshaper']);
if(isset($config['nat']))
unset($config['nat']);
}
......@@ -345,11 +311,6 @@ EODD;
printf(gettext("done.%s"), "\n");
fclose($fp);
return true;
}
return false;
}
function autodetect_interface($ifname, $fp)
......
......@@ -149,12 +149,9 @@ if (is_interface_mismatch()) {
}
}
$done = false;
do {
led_assigninterfaces();
$done = set_networking_interfaces_ports();
set_networking_interfaces_ports();
led_kitt();
} while (!$done);
}
/* convert config and clean backups */
......
......@@ -37,7 +37,8 @@ require_once("vpn.inc");
require_once("captiveportal.inc");
require_once("rrd.inc");
/* configure until valid */
while (!set_networking_interfaces_ports());
set_networking_interfaces_ports();
echo "Reloading interfaces...";
reload_interfaces_sync();
echo "done.\n";
enable_rrd_graphing();
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