source: MondoRescue/branches/2.2.6/mindi/rootfs/sbin/start-nfs@ 2899

Last change on this file since 2899 was 2001, checked in by Bruno Cornec, 16 years ago
  • Fix for #270 by mounting NFS share ro, to avoid removal of mondo images. More fixes are done in 2.2.7. This is to create an intermediate 2.0.3 mindi version fixing only that issue.
  • Property svn:executable set to *
File size: 2.4 KB
RevLine 
[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
10ipcount=3
11
12# Get info from config file
13ipdev=`grep nfs-dev /tmp/mondo-restore.cfg | cut -d' ' -f2-`
14ipaddress=`grep nfs-client-ipaddr /tmp/mondo-restore.cfg | cut -d' ' -f2-`
15ipnetmask=`grep nfs-client-netmask /tmp/mondo-restore.cfg | cut -d' ' -f2-`
16ipbroadcast=`grep nfs-client-broadcast /tmp/mondo-restore.cfg | cut -d' ' -f2-`
17ipgateway=`grep nfs-client-defgw /tmp/mondo-restore.cfg | cut -d' ' -f2-`
18ipconf=""
[801]19export nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg | cut -d' ' -f2-`
20export imgname=`grep iso-prefix /tmp/mondo-restore.cfg | cut -d' ' -f2-`
[740]21if [ "$imgname" = "" ]; then
[801]22 export imgname="mondorescue"
[740]23fi
[801]24export dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg | cut -d' ' -f2-`
[740]25if [ "$dirimg" = "" ]; then
[801]26 export dirimg="/"
[740]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`
[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]35done
36
[1830]37if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
38 # Network configuration stored during archive
39 # or on cmdline so network wanted => starting it
[740]40 LogIt "Starting Network..."
41
[1830]42 # Activate loobback
43 ifconfig lo 127.0.0.1
[740]44
[1830]45 echo "$ipconf" | grep -q "dhcp"
46 if [ $? -eq 0 ]; then
[740]47 ipdev=`echo $ipconf | cut -d: -f1`
[1830]48 LogIt "Making DHCP request on $ipdev"
49 udhcpc -i $ipdev
50 else
51 if [ "$ipconf" != "" ]; then
52 ipdev=`echo $ipconf | cut -d: -f1`
53 ipaddress=`echo $ipconf | cut -d: -f2`
54 ipnetmask=`echo $ipconf | cut -d: -f3`
55 ipbroadcast=`echo $ipconf | cut -d: -f4`
56 ipgateway=`echo $ipconf | cut -d: -f5`
57 fi
58 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
59 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
60 route add default gw $ipgateway
[740]61 fi
62
[1830]63 # ping server helps waking interface up
64 LogIt "Pinging NFS server..."
65 nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
66 ping -c $ipcount $nfs_server_ipaddr
[740]67
[1830]68 # Finally mounts the NFS share
69 LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
[1927]70 touch /etc/mtab
[2001]71 mount -t nfs -o nolock,ro $nfsmount /tmp/isodir
[1830]72
73 LogIt "Mounting NFS image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
[1927]74 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
[1830]75fi
Note: See TracBrowser for help on using the repository browser.