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

Last change on this file since 2253 was 2253, checked in by Bruno Cornec, 15 years ago

r3165@localhost: bruno | 2009-07-03 17:08:03 +0200

  • Only mount /mnt/RESTORING if needed for script execution
  • Copy the NFS script under /tmp as it's unmounted before we can use it
  • Property svn:executable set to *
File size: 2.8 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
[1983]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-`
[740]18ipconf=""
[2253]19script=""
[1983]20export nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
21export imgname=`grep iso-prefix /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]22if [ "$imgname" = "" ]; then
[801]23 export imgname="mondorescue"
[740]24fi
[1983]25export dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]26if [ "$dirimg" = "" ]; then
[801]27 export dirimg="/"
[740]28fi
29
30# info from cmdline are predominent
31for i in `cat /proc/cmdline` ; do
32 echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
33 echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
[801]34 echo $i | grep -qi nfsmount= && export nfsmount=`echo $i | cut -d= -f2`
35 echo $i | grep -qi prefix= && export imgname=`echo $i | cut -d= -f2`
[2191]36 echo $i | grep -qi nfspath= && export dirimg=`echo $i | cut -d= -f2`
[2253]37 echo $i | grep -qi script= && script=`echo $i | cut -d= -f2`
[740]38done
39
[1830]40if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
41 # Network configuration stored during archive
42 # or on cmdline so network wanted => starting it
[740]43 LogIt "Starting Network..."
44
[1830]45 # Activate loobback
46 ifconfig lo 127.0.0.1
[740]47
[1830]48 echo "$ipconf" | grep -q "dhcp"
49 if [ $? -eq 0 ]; then
[740]50 ipdev=`echo $ipconf | cut -d: -f1`
[1830]51 LogIt "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 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
62 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
63 route add default gw $ipgateway
[740]64 fi
65
[1830]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
[740]70
[1830]71 # Finally mounts the NFS share
72 LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
[1927]73 touch /etc/mtab
[2002]74 mount -t nfs -o nolock,ro $nfsmount /tmp/isodir
[1830]75
76 LogIt "Mounting NFS image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
[1927]77 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
[2253]78
79 # Save the script on the NFS share locally
80 if [ echo "$script" | grep -E "^/tmp/isodir" ]; then
81 cp $script /tmp
82 LogIt "Copying $script under /tmp"
83 fi
[1830]84fi
Note: See TracBrowser for help on using the repository browser.