source: MondoRescue/branches/2.2.9/mindi/rootfs/sbin/start-nfs@ 2191

Last change on this file since 2191 was 2191, checked in by Bruno Cornec, 15 years ago
  • Should fix #310. Adrien, please test ;-)
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/sh
2#
3# $Id$
4#
5# This script sets up the network + NFS environment if needed.
6#
7
8
9# number of ping
10ipcount=3
11
12# Get info from config file
13ipdev=`grep nfs-dev /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
14ipaddress=`grep nfs-client-ipaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
15ipnetmask=`grep nfs-client-netmask /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
16ipbroadcast=`grep nfs-client-broadcast /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
17ipgateway=`grep nfs-client-defgw /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
18ipconf=""
19export nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
20export imgname=`grep iso-prefix /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
21if [ "$imgname" = "" ]; then
22 export imgname="mondorescue"
23fi
24export dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
25if [ "$dirimg" = "" ]; then
26 export dirimg="/"
27fi
28
29# info from cmdline are predominent
30for 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`
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`
35 echo $i | grep -qi nfspath= && export dirimg=`echo $i | cut -d= -f2`
36done
37
38if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
39 # Network configuration stored during archive
40 # or on cmdline so network wanted => starting it
41 LogIt "Starting Network..."
42
43 # Activate loobback
44 ifconfig lo 127.0.0.1
45
46 echo "$ipconf" | grep -q "dhcp"
47 if [ $? -eq 0 ]; then
48 ipdev=`echo $ipconf | cut -d: -f1`
49 LogIt "Making DHCP request on $ipdev"
50 udhcpc -i $ipdev
51 else
52 if [ "$ipconf" != "" ]; then
53 ipdev=`echo $ipconf | cut -d: -f1`
54 ipaddress=`echo $ipconf | cut -d: -f2`
55 ipnetmask=`echo $ipconf | cut -d: -f3`
56 ipbroadcast=`echo $ipconf | cut -d: -f4`
57 ipgateway=`echo $ipconf | cut -d: -f5`
58 fi
59 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
60 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
61 route add default gw $ipgateway
62 fi
63
64 # ping server helps waking interface up
65 LogIt "Pinging NFS server..."
66 nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
67 ping -c $ipcount $nfs_server_ipaddr
68
69 # Finally mounts the NFS share
70 LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
71 touch /etc/mtab
72 mount -t nfs -o nolock,ro $nfsmount /tmp/isodir
73
74 LogIt "Mounting NFS image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
75 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
76fi
Note: See TracBrowser for help on using the repository browser.