Changeset 2887 in MondoRescue for branches/2.2.9/mindi/rootfs/sbin/start-netfs


Ignore:
Timestamp:
Oct 9, 2011, 1:03:19 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Adds support for hwaddr (MAC addresses) at restore time, and map to the correct NIC if it's found at restore time (based on code from Stefan Heijmans)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi/rootfs/sbin/start-netfs

    r2709 r2887  
    1212# Get info from config file
    1313ipdev=`grep netfs-dev /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
     14hwaddr=`grep netfs-client-hwaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
    1415ipaddress=`grep netfs-client-ipaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
    1516ipnetmask=`grep netfs-client-netmask /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
     
    3334for i in `cat /proc/cmdline` ; do
    3435    echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
     36    echo $i | grep -qi hwaddr= && hwaddr=`echo $i | cut -d= -f2`
    3537    echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
    3638    echo $i | grep -qi netfsmount= && export netfsmount=`echo $i | cut -d= -f2`
     
    6466            ipgateway=`echo $ipconf | cut -d: -f5`
    6567        fi
     68
     69        # If same system, map to the right MAC address
     70        hwaddr_found=`ifconfig $ipdev | /bin/grep HWaddr | awk '{print $NF}'`
     71        if [ "$hwaddr" != "$hwaddr_found" ]; then
     72            ipdev_new=`ifconfig -a | /bin/grep $hwaddr | awk '{print $1}'`
     73            if [ "$ipdev_new" != "" ]; then
     74                LogIt "Interface $ipdev changed to $ipdev_new (MAC: $hwaddr)"
     75                ipdev=$ipdev_new
     76            else
     77                LogIt "NOTE: Interface $ipdev kept despite it doesn't match the $hwaddr MAC address"
     78            fi
     79        fi
     80
    6681        LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
    6782        ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
    6883        route add default gw $ipgateway
     84
    6985    fi
     86
     87    # Leave time to the satck to wake up (reported by some users)
     88    sleep 5
    7089
    7190    # ping server helps waking interface up
Note: See TracChangeset for help on using the changeset viewer.