Chris Buechler wrote:
On Sun, Jul 5, 2009 at 4:23 PM, Tim A.<pfse...@lists.goldenpath.org> wrote:
Attached a patch against 1.2.3-rc2 adding support for auto configuring
interfaces.

That's definitely a nice feature, though only suitable for addition to
2.0, so we'll need a patch for 2.0.  The only thing from your
description that needs to change is the auto-assignment with one
interface, 2.0 will let you assign only WAN and treat it basically
like LAN with a default gateway for appliance purposes, so if there is
only one interface it needs to only assign WAN.

Thanks!

Attached a patch against 2.0 adding support for auto configuring interfaces.
This patch is done with -rub. So, you wont see the white space but note that there's a significant block of the original code that should be indented with this.

I reworked it to be less clunky and more POLS. Also, I'm learning more about pfsense internals and the auto interface feature automatically turns on sshd if it kicks in.
So, no need to worry about the config file.

I'll update the 1.2 patch later with these improvements as well.

By the way. I've started using git, and its very cool. I created an account and added my key to rcs.pfsense.org.
I tried to push this to the repo but it keeps saying not allowed.
Are you guys only using that internally?
--- a/etc/inc/config.inc        2009-07-14 16:39:50.000000000 -0400
+++ b/etc/inc/config.inc        2009-07-14 14:30:35.000000000 -0400
@@ -790,6 +790,12 @@
 
        $iflist = get_interface_list();
 
+/* Function flow is based on $key and $auto_assign or the lack thereof */      
+       $key = null;
+                       
+       if ((ereg("cdrom", $g['platform'])) || is_interface_mismatch())
+               $auto_assign = true;
+
        echo <<<EOD
 
 Valid interfaces are:
@@ -799,7 +805,7 @@
 
        if(!is_array($iflist)) {
                echo "No interfaces found!\n";
-               $iflist = array();
+               return;
        } else {
                foreach ($iflist as $iface => $ifa) {
                        echo sprintf("% -16s%s%s\t%s\n", $iface, $ifa['mac'],
@@ -807,6 +813,14 @@
                }
        }
 
+       if ($auto_assign) {
+               echo <<<EOD
+
+BEGIN MANUAL CONFIGURATION OR WE WILL PROCEED WITH AUTO CONFIGURATION.
+
+EOD;
+       }       
+       
        echo <<<EOD
 
 Do you want to set up VLANs first?
@@ -816,7 +830,54 @@
 Do you want to set up VLANs now [y|n]?
 EOD;
 
-       if (strcasecmp(chop(fgets($fp)), "y") == 0)
+       if ($auto_assign) {
+               $timeout=9;             // How long do you want the script to 
wait before moving on (in seconds)
+               exec("/bin/stty erase " . chr(8));
+               while(!isset($key)) {
+                       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`;
+                       if ($key == '')
+                               unset($key);
+                       // Decrement our timeout value
+                       $timeout--;
+                       // If we have reached 0 exit and continue on
+                       if ($timeout == 0) 
+                               break;
+               }
+       } else
+               $key = chop(fgets($fp));
+
+
+       if (!isset($key)) {     // Auto Assign Interfaces
+               $optif = array();
+               $i = $j = 0;
+               echo "\n\n";
+               foreach ($iflist as $iface => $ifa) {
+                       if ($i > 1) {
+                               $optif[$j] = $iface; 
+                               echo "Assigned OPT" . ($j+1) . " to : 
$optif[$j] \n";
+                               $i++;
+                               $j++;
+                       }
+                       elseif ($i == 1) {
+                               $lanif = $iface;
+                               echo "Assigned LAN to : $lanif \n";
+                               $i++;
+                       }
+                       elseif ($i == 0) {
+                               $wanif = $iface;
+                               echo "Assigned WAN to : $wanif \n";
+                               $i++;
+                       }
+               }
+
+               $config['system']['enablesshd'] = 'enabled';    
+               $key = 'y';
+
+       } else {                //Manually assign interfaces    
+       if (in_array($key, array('y', 'Y')))
                vlan_setup();
 
        if (is_array($config['vlans']['vlan']) && 
count($config['vlans']['vlan'])) {
@@ -953,15 +1014,17 @@
                echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n";
        }
 
-echo <<<EOD
+       echo <<<EOD
 
 Do you want to proceed [y|n]?
 EOD;
+               $key = chop(fgets($fp));                
+       }
 
-       if (strcasecmp(chop(fgets($fp)), "y") == 0) {
+       if (in_array($key, array('y', 'Y'))) {
                if($lanif) {
                        $config['interfaces']['lan']['if'] = $lanif;
-               } elseif (!$g['booting']) {
+               } elseif (!$g['booting'] && !$auto_assign) {
 
 echo <<<EODD
 

---------------------------------------------------------------------
To unsubscribe, e-mail: support-unsubscr...@pfsense.com
For additional commands, e-mail: support-h...@pfsense.com

Commercial support available - https://portal.pfsense.org

Reply via email to