[742] | 1 | #!/bin/sh
|
---|
[740] | 2 | #
|
---|
[741] | 3 | # $Id$
|
---|
| 4 | #
|
---|
[802] | 5 | # This script sets up the network + NFS environment if needed.
|
---|
[741] | 6 | #
|
---|
| 7 |
|
---|
| 8 |
|
---|
[740] | 9 | # number of ping
|
---|
| 10 | ipcount=3
|
---|
| 11 |
|
---|
| 12 | # Get info from config file
|
---|
| 13 | ipdev=`grep nfs-dev /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 14 | ipaddress=`grep nfs-client-ipaddr /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 15 | ipnetmask=`grep nfs-client-netmask /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 16 | ipbroadcast=`grep nfs-client-broadcast /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 17 | ipgateway=`grep nfs-client-defgw /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 18 | ipconf=""
|
---|
[801] | 19 | export nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
| 20 | export imgname=`grep iso-prefix /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
[740] | 21 | if [ "$imgname" = "" ]; then
|
---|
[801] | 22 | export imgname="mondorescue"
|
---|
[740] | 23 | fi
|
---|
[801] | 24 | export dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg | cut -d' ' -f2-`
|
---|
[740] | 25 | if [ "$dirimg" = "" ]; then
|
---|
[801] | 26 | export dirimg="/"
|
---|
[740] | 27 | fi
|
---|
| 28 |
|
---|
| 29 | # info from cmdline are predominent
|
---|
| 30 | for i in `cat /proc/cmdline` ; do
|
---|
| 31 | echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
|
---|
| 32 | echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
|
---|
[801] | 33 | echo $i | grep -qi nfsmount= && export nfsmount=`echo $i | cut -d= -f2`
|
---|
| 34 | echo $i | grep -qi prefix= && export imgname=`echo $i | cut -d= -f2`
|
---|
[740] | 35 | done
|
---|
| 36 |
|
---|
| 37 | if [ $ipdev = "" ] && [ $ipconf = "" ]; then
|
---|
| 38 | # No network configuration neither stored during archive
|
---|
| 39 | # nor on cmdline so no network wanted => exiting
|
---|
| 40 | exit 0
|
---|
| 41 | else
|
---|
| 42 | LogIt "Starting Network..."
|
---|
| 43 | fi
|
---|
| 44 |
|
---|
| 45 | # Activate loobback
|
---|
| 46 | ifconfig lo 127.0.0.1
|
---|
| 47 |
|
---|
| 48 | echo "$ipconf" | grep -q "dhcp"
|
---|
| 49 | if [ $? -eq 0 ]; then
|
---|
| 50 | ipdev=`echo $ipconf | cut -d: -f1`
|
---|
| 51 | echo "Making DHCP request on $ipdev"
|
---|
| 52 | udhcpc -i $ipdev
|
---|
| 53 | else
|
---|
| 54 | if [ "$ipconf" != "" ]; then
|
---|
| 55 | ipdev=`echo $ipconf | cut -d: -f1`
|
---|
| 56 | ipaddress=`echo $ipconf | cut -d: -f2`
|
---|
| 57 | ipnetmask=`echo $ipconf | cut -d: -f3`
|
---|
| 58 | ipbroadcast=`echo $ipconf | cut -d: -f4`
|
---|
| 59 | ipgateway=`echo $ipconf | cut -d: -f5`
|
---|
| 60 | fi
|
---|
| 61 | echo "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
|
---|
| 62 | ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
|
---|
| 63 | route add default gw $ipgateway
|
---|
| 64 | fi
|
---|
| 65 |
|
---|
| 66 | # ping server helps waking interface up
|
---|
| 67 | LogIt "Pinging NFS server..."
|
---|
| 68 | nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
|
---|
| 69 | ping -c $ipcount $nfs_server_ipaddr
|
---|
| 70 |
|
---|
| 71 | # Finally mounts the NFS share
|
---|
| 72 | LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
|
---|
| 73 | mount -t nfs -o nolock $nfsmount /tmp/isodir
|
---|
| 74 |
|
---|
[801] | 75 | LogIt "Mounting NFS image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
|
---|
[1311] | 76 | mount -o ro -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
|
---|