Changeset 3443 in MondoRescue for branches/3.2/mindi/rootfs
- Timestamp:
- Aug 29, 2015, 1:53:47 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi/rootfs/usr/sbin/start-netfs
r3440 r3443 21 21 iproute=`grep netfs-route /tmp/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-` 22 22 ipconf="" 23 ipmode="STATIC" 23 24 pre="" 24 25 post="" … … 46 47 echo $i | grep -qi proto= && proto=`echo $i | cut -d= -f2` 47 48 echo $i | grep -qi iproute= && iproute=`echo $i | cut -d= -f2` 49 echo $i | grep -qi ipmode= && ipmode=`echo $i | cut -d= -f2` 48 50 done 49 51 … … 56 58 ifconfig lo 127.0.0.1 57 59 58 echo "$ipconf" | grep -q "dhcp"59 if [ $? -eq 0]; then60 ipdev=`echo $ipconf | cut -d: -f1`61 LogIt "Making DHCP request on $ipdev"62 udhcpc -i $ipdev63 else64 if [ "$ipconf" != "" ]; then60 # 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 65 67 ipdev=`echo $ipconf | cut -d: -f1` 66 68 ipaddress=`echo $ipconf | cut -d: -f2` … … 69 71 ipgateway=`echo $ipconf | cut -d: -f5` 70 72 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 71 77 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 83 99 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` 84 113 fi 85 114 fi 115 fi 86 116 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)" 88 122 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast 89 123 route add default gw $ipgateway 90 91 124 fi 92 93 125 # Leave time to the stack to wake up (reported by some users) 94 126 sleep 5
Note:
See TracChangeset
for help on using the changeset viewer.