source: MondoRescue/branches/2.2.10/mindi/rootfs/sbin/start-nfs@ 2329

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

r3340@localhost: bruno | 2009-08-12 00:17:29 +0200
Improve portability by defining all cmdline usage in 1 include (/tmp for FreeBSD and /proc fior LInux). Also doing tht for scripts.

  • Property svn:executable set to *
File size: 3.0 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=""
[2255]19pre=""
20post=""
[1983]21export nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
22export imgname=`grep iso-prefix /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]23if [ "$imgname" = "" ]; then
[801]24 export imgname="mondorescue"
[740]25fi
[1983]26export dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]27if [ "$dirimg" = "" ]; then
[801]28 export dirimg="/"
[740]29fi
30
31# info from cmdline are predominent
[2329]32for i in `cat $CMDLINE` ; do
[740]33 echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
34 echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
[801]35 echo $i | grep -qi nfsmount= && export nfsmount=`echo $i | cut -d= -f2`
36 echo $i | grep -qi prefix= && export imgname=`echo $i | cut -d= -f2`
[2191]37 echo $i | grep -qi nfspath= && export dirimg=`echo $i | cut -d= -f2`
[2255]38 echo $i | grep -qi pre= && pre=`echo $i | cut -d= -f2`
39 echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
[740]40done
41
[1830]42if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
43 # Network configuration stored during archive
44 # or on cmdline so network wanted => starting it
[740]45 LogIt "Starting Network..."
46
[1830]47 # Activate loobback
48 ifconfig lo 127.0.0.1
[740]49
[1830]50 echo "$ipconf" | grep -q "dhcp"
51 if [ $? -eq 0 ]; then
[740]52 ipdev=`echo $ipconf | cut -d: -f1`
[1830]53 LogIt "Making DHCP request on $ipdev"
54 udhcpc -i $ipdev
55 else
56 if [ "$ipconf" != "" ]; then
57 ipdev=`echo $ipconf | cut -d: -f1`
58 ipaddress=`echo $ipconf | cut -d: -f2`
59 ipnetmask=`echo $ipconf | cut -d: -f3`
60 ipbroadcast=`echo $ipconf | cut -d: -f4`
61 ipgateway=`echo $ipconf | cut -d: -f5`
62 fi
63 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
64 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
65 route add default gw $ipgateway
[740]66 fi
67
[1830]68 # ping server helps waking interface up
69 LogIt "Pinging NFS server..."
70 nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
71 ping -c $ipcount $nfs_server_ipaddr
[740]72
[1830]73 # Finally mounts the NFS share
74 LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
[1927]75 touch /etc/mtab
[2002]76 mount -t nfs -o nolock,ro $nfsmount /tmp/isodir
[1830]77
78 LogIt "Mounting NFS image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
[1927]79 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
[2253]80
[2255]81 # Save the scripts on the NFS share locally
82 if [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
83 cp $pre /tmp
84 LogIt "Copying $pre under /tmp"
[2253]85 fi
[2255]86 if [ "`echo $post | grep -E '^/tmp/isodir'`" ]; then
87 cp $post /tmp
88 LogIt "Copying $post under /tmp"
89 fi
[1830]90fi
Note: See TracBrowser for help on using the repository browser.