On Sun, Jul 5, 2009 at 10:23 PM, Tim A.<[email protected]> wrote: > Attached a patch against 1.2.3-rc2 adding support for auto configuring > interfaces. > By enabling sshd in the default config.xml on the Live CD installer, this > eliminates many headaches for installs: > No monitor / keyboard / mouse required. > No console cable required. > Install to headless boxes that don't even have console ports! > No more crackin open your box to screw with CF cards and /etc/fstab > nightmares (for being installed to a /dev/device that no longer exists!). > > Just plug-in, turn it on and ssh to the default IP. > > This is a link to an ISO built with this patch and my previously submitted > DHCP Server patch. > http://techneck.goldenpath.org/pfsense/pfSense_1.2.3-R2_RELENG_7_2_techneck_patches.iso > > > The new code will pause to allow interruption for manual assignment. Any > keyboard input will interrupt the procedure. > But if left unattended the code will timeout to begin the automated process. > The code assigns interfaces in the order they were discovered, LAN, WAN, > OPT1, OPT2, etc... > If only one interface exists and is vlan capable, the code with create vlan0 > tagged VLAN1. > But this will invariably be assigned to WAN as LAN is assigned first and > obviously the parent NIC is discovered before the vlan0. > This is appropriate behavior though given the undesirable situation of > having only 1 NIC, and installation priorities. > It is appropriate because it is more likely that the typical user is not > actually prepared to connect to VLANs and his priority is to connect to the > LAN interface to install and configure his box > > ~Tim > > --- config.inc.old 2009-07-05 10:18:55.000000000 -0400 > +++ config.inc 2009-07-05 11:39:34.000000000 -0400 > @@ -1285,6 +1285,95 @@ > > echo <<<EOD > > +Press any key to configure interfaces manually, > +otherwise we're proceeding with autoconfiguring in: > + > +EOD; > + $anykey = Array(); > + for ( $i = 7 ; $i < 14 ; $i++ ) { $anykey[] = chr($i); } > + for ( $i = 32 ; $i < 128 ; $i++ ) { $anykey[] = chr($i); } > + $anykey[] = chr(27); > + $timeout=9; // How long do you want the script to wait > before moving on (in seconds) > + $key = null; > + exec("/bin/stty erase " . chr(8)); > + while(!in_array($key, $anykey)) { > + 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) > + break; > + } > + > + if(!in_array($key, $anykey)) { // Auto Assign Interfaces > + if(count($iflist) < 2) { // If less than two NICs, > auto assign a vlan. > + echo <<<EOD > + > +Less than two interfaces detected. > +Proceeding with VLAN autoconfig... > + > +EOD; > + $vflist = Array(); > + $vlan = Array(); > + > + echo "VLAN Capable interfaces:\n\n"; > + if(!is_array($iflist)) { > + echo "No interfaces found! EXITING \n"; > + return; > + } else { > + foreach ($iflist as $iface => $ifa) { > + if (is_jumbo_capable($iface)) { > + echo sprintf("% -8s%s%s\n", > $iface, $ifa['mac'], > + $ifa['up'] ? " > (up)" : ""); > + $vflist[] = $iface; > + } > + } > + } > + > + if(count($vflist) < 1) { > + echo "No VLAN capable interfaces detected. > EXITING \n"; > + return; > + } > + // Create > VLANs > + echo "\n\n"; > + foreach ($vflist as $v => $vface) { > + $vlan['if'] = $vface; > + $vlan['tag'] = 1; > + $config['vlans']['vlan'][] = $vlan; > + $iflist['vlan' . $v] = array(); > + echo "Created VLAN interface vlan" . $v . " > with VLAN tag: 1\n"; > + } > + } > + // > Assignment > + $optif = Array(); > + $x = $y = 0; > + echo "\n\n"; > + foreach ($iflist as $iface => $ifa) { > + if ($x > 1) { > + $optif[$y] = $iface; > + echo "Assigned OPT" . ($y+1) . " to : > $optif[$y] \n"; > + $x++; > + $y++; > + } > + elseif ($x == 1) { > + $wanif = $iface; > + echo "Assigned WAN to : $wanif \n"; > + $x++; > + } > + elseif ($x == 0) { > + $lanif = $iface; > + echo "Assigned LAN to : $lanif \n"; > + $x++; > + } > + } > + > + $proceed = 'y'; > + } else { //Manually assign > interfaces > + echo <<<EOD > + > Valid interfaces are: > > > @@ -1441,12 +1530,16 @@ > echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n"; > } > > -echo <<<EOD > + echo <<<EOD > > Do you want to proceed [y|n]? > EOD; > > - if (strcasecmp(chop(fgets($fp)), "y") == 0) { > + $proceed = chop(fgets($fp)); > + > + } > + > + if (strcasecmp($proceed, "y") == 0) { > > $config['interfaces']['lan']['if'] = $lanif; > if (preg_match($g['wireless_regex'], $lanif)) { > >
To me this is a hack and not a feature. There is a better way to do this things than kludge things here and there in the code. The right fix was proposed once and not everybody liked the POLA breaking. Either way I would not like to see this in pfSense rather than the other solution which would allow installing pfSense from the gui after auto-magically booting the livecd. Just my 2cents, -- Ermal --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] Commercial support available - https://portal.pfsense.org
