Changeset 1165

Show
Ignore:
Timestamp:
06/30/08 12:28:18 (2 months ago)
Author:
mstauber
Message:

constructor/40_addGateway.pl updated again, my previous fix didn't work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 5106R/trunk/ui/base-network.mod/constructor/40_addGateway.pl

    r1164 r1165  
    3232 
    3333if (-f $conf) { 
     34    # 1st try (with quotes): 
    3435    open(CONF, $conf) || die "Can't read configfile: $conf\n"; 
    3536    while (<CONF>) { 
    36         if (! -f "/proc/user_beancounters") {  
    37                 next unless /^GATEWAY=\s*(\S+)/; 
    38         } 
    39         else { 
    40                 next unless /^GATEWAY=\"(.*)\"/; 
    41         } 
     37        next unless /^GATEWAY=\"(.*)\"/; 
    4238        $gateway = $1; 
    4339    } 
     40    close(CONF); 
     41 
     42    # 2nd try (without quotes): 
     43    if (!$gateway) { 
     44        open(CONF, $conf) || die "Can't read configfile: $conf\n"; 
     45        while (<CONF>) { 
     46            next unless /^GATEWAY=\s*(\S+)/; 
     47            $gateway = $1; 
     48        } 
     49        close(CONF); 
     50    } 
    4451} 
    45 close(CONF); 
    4652 
    4753if (!$gateway) { 
    4854    $DEBUG && print STDERR "Gateway setting isn't found\n"; 
     55    # Attempt to determine Gateway through other means: 
    4956    if ( ! -f "/proc/user_beancounters" ) { 
     57        # Not running on OpenVZ, so check the route to find the Gateway: 
    5058        my $data = `$Network::ROUTE -n|grep '^0\.0\.0\.0'`; 
    5159        if ($data =~ /0\.0\.0\.0\s+((\d+).(\d+).(\d+).(\d+))/) { 
     
    5462    } 
    5563    else { 
    56         # Set default OpenVZ gateway: 
     64        # We're on OpenVZ, so set the default OpenVZ gateway: 
    5765        $gateway = "192.0.2.1"; 
    5866        system("/bin/cat /etc/sysconfig/network |/bin/grep -v ^GATEWAY > /etc/sysconfig/network.bak"); 
    5967        system("/bin/mv /etc/sysconfig/network.bak /etc/sysconfig/network"); 
    60         system("/bin/echo GATEWAY=\"192.0.2.1\" >> /etc/sysconfig/network"); 
     68        system("/bin/echo 'GATEWAY=\"192.0.2.1\"' >> /etc/sysconfig/network"); 
    6169        system("/etc/init.d/network restart > /dev/null"); 
    6270    }