Changeset 3443


Ignore:
Timestamp:
Aug 29, 2015, 1:53:47 AM (3 years ago)
Author:
bruno
Message:
  • Adds an ipmode configuration parameter at boot time to typically force start-netfs to make a DHCP request, despite the conf file doesn't precise it (parm can be DHCP or STATIC)
  • Review again the strategy when the simple case of NIC unchanged and IP conf either is not verified. Trust ipconf first, and then use mondorestore.cfg content, trying to find the right NIC withthe corresponding MAC address in the file, if the stored NIC isn't named identically anymore.
Location:
branches/3.2/mindi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/README.pxe

    r3173 r3443  
    11MondoRescue supports image deployment using Pre eXecution Environment (PXE)
    2 Linux deployments with PXE is documented at http://syslinux.zytor.com/pxe.php
    32Multiple parameters are available at restore time for PXE support:
    43
     
    109ipaddr      IP Address to setup on the device (e.g. 192.168.1.1)
    1110ipdev       Device name (e.g. eth2)
     11ipmode      Force the mode to use (DHCP|STATIC) - Useful to force DHCP w/o PXE
    1212iproute     Additional static route (uses "route add" syntax with : separator)
    1313            (e.g. iproute="-net:192.168.8.0:netmask:255.255.255.0:dev:eth3)
     
    5252NOTE: If you don't have selinux=0 on the boot line, you may have issues restoring extended attributes on your filesystem and thus be unable to log on at next reboot after restore.
    5353
     54Linux deployments with PXE is documented at http://syslinux.zytor.com/pxe.php
     55
    5456Please report any problem around that tool to bruno_at_mondorescue.org
    5557
    5658$Id$
    5759
     602015-08-29 adds support for ipmode
    58612013-07-25 adds support for iproute
    59622011-10-09 adds support for hwaddr
  • branches/3.2/mindi/rootfs/usr/sbin/start-netfs

    r3440 r3443  
    2121iproute=`grep netfs-route /tmp/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
    2222ipconf=""
     23ipmode="STATIC"
    2324pre=""
    2425post=""
     
    4647    echo $i | grep -qi proto= && proto=`echo $i | cut -d= -f2`
    4748    echo $i | grep -qi iproute= && iproute=`echo $i | cut -d= -f2`
     49    echo $i | grep -qi ipmode= && ipmode=`echo $i | cut -d= -f2`
    4850done
    4951
     
    5658    ifconfig lo 127.0.0.1
    5759
    58     echo "$ipconf" | grep -q "dhcp"
    59     if [ $? -eq 0 ]; then
    60         ipdev=`echo $ipconf | cut -d: -f1`
    61         LogIt "Making DHCP request on $ipdev"
    62         udhcpc -i $ipdev
    63     else
    64         if [ "$ipconf" != "" ]; then
     60    # ipconf has priority
     61    if [ "$ipconf" != "" ]; then
     62        echo "$ipconf" | grep -q "dhcp"
     63        if [ $? -eq 0 ]; then
     64            ipdev=`echo $ipconf | cut -d: -f1`
     65            ipmode="DHCP"
     66        else
    6567            ipdev=`echo $ipconf | cut -d: -f1`
    6668            ipaddress=`echo $ipconf | cut -d: -f2`
     
    6971            ipgateway=`echo $ipconf | cut -d: -f5`
    7072        fi
     73    else
     74        # Now relying on ipdev which isn't empty
     75        # ipmode is either STATIC by default or DHCP if a parameter was passed
     76        # If same system, map to the right MAC address
    7177
    72         # If same system, map to the right MAC address
    73         if [ "$hwaddr" != "" ]; then
    74             hwaddr_found=`ifconfig $ipdev | grep HWaddr | awk '{print $NF}' | tr '[a-z]' '[A-Z]'`
    75             if [ "$hwaddr" != "$hwaddr_found" ]; then
    76                 ipdev_new=`ifconfig -a | grep -i $hwaddr | awk '{print $1}'`
    77                 if [ "$ipdev_new" != "" ]; then
    78                     LogIt "Interface with MAC address $hwaddr changed from $ipdev to $ipdev_new"
    79                     LogIt "Using $ipdev_new for network configuration from now on"
    80                     ipdev=$ipdev_new
    81                 else
    82                     LogIt "NOTE: Interface $ipdev kept despite it doesn't match the $hwaddr MAC address"
     78        # Look at our previous device
     79        hwaddr_found=`ifconfig $ipdev 2> /dev/null | grep HWaddr | awk '{print $NF}' | tr '[a-z]' '[A-Z]'`
     80        if [ "$hwaddr_found" != "" ]; then
     81            # That device always exists
     82            if [ "$hwaddr" = "$hwaddr_found" ]; then
     83                # No renaming took place use it
     84            fi
     85        else
     86            # maybe there was a change of NIC numbering e.g.
     87            # and the one used at backup doesn't exist anymore
     88            # ipdev is not good anymore probably
     89            oldipdev=$ipdev
     90
     91            for hwdev in `ifconfig -a | grep HWaddr | awk '{print $1}'` ; do
     92                mac=`ifconfig $hwdev | grep HWaddr | awk '{print $NF}' | tr '[a-z]' '[A-Z]'`
     93                if [ "$hwaddr" = "$mac" ]; then
     94                    # This is the new device for the MAC address of our card at backup time
     95                    LogIt "Interface with MAC address $hwaddr changed from $ipdev to $hwdev"
     96                    LogIt "Using $hwdev for network configuration from now on"
     97                    ipdev=$hwdev
     98                    break
    8399                fi
     100            done
     101
     102            if [ "$oldipdev" = "$ipdev" ]; then
     103                # We didn't find a new device for this MAC
     104                LogIt "NOTE: Interface $ipdev kept despite it doesn't match the $hwaddr MAC address"
     105                ipdev=$oldipdev
     106            fi
     107
     108            # TODO: Should we do that ?
     109            if [ "$hwaddr" = "" ]; then
     110                # No hwaddr stored at backup
     111                # take the first interface and hope it's good
     112                ipdev=`ifconfig -a | grep HWaddr | awk '{print $1}' | head -1`
    84113            fi
    85114        fi
     115    fi
    86116
    87         LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
     117    if [ "$ipmode" = "DHCP" ]; then
     118        LogIt "Making DHCP request on $ipdev"
     119        udhcpc -i $ipdev
     120    else
     121        LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask/$ipgateway)"
    88122        ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
    89123        route add default gw $ipgateway
    90 
    91124    fi
    92 
    93125    # Leave time to the stack to wake up (reported by some users)
    94126    sleep 5
Note: See TracChangeset for help on using the changeset viewer.