source: trunk/mindi/rootfs/sbin/start-nfs @ 764

Last change on this file since 764 was 764, checked in by bruno, 13 years ago

merge -r728:763 $SVN_M/branches/stable

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/sh
2#
3# $Id$
4#
5# This script set up the network + NFS environement 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 | 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=""
19nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg | cut -d' ' -f2-`
20imgname=`grep iso-prefix /tmp/mondo-restore.cfg | cut -d' ' -f2-`
21if [ "$imgname" = "" ]; then
22    imgname="mondorescue"
23fi
24dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg | cut -d' ' -f2-`
25if [ "$dirimg" = "" ]; then
26    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= && nfsmount=`echo $i | cut -d= -f2`
34    echo $i | grep -qi prefix= && imgname=`echo $i | cut -d= -f2`
35done
36
37if [ $ipdev = "" ] && [ $ipconf = "" ]; then
38    # No network configuration neither stored during archive
39    # nor on cmdline so no network wanted => exiting
40    exit 0
41else
42    LogIt "Starting Network..."
43fi
44
45# Activate loobback
46ifconfig lo 127.0.0.1
47
48echo "$ipconf" | grep -q "dhcp"
49if [ $? -eq 0 ]; then
50    ipdev=`echo $ipconf | cut -d: -f1`
51    echo "Making DHCP request on $ipdev"
52    udhcpc -i $ipdev
53else
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
64fi
65
66# ping server helps waking interface up
67LogIt "Pinging NFS server..."
68nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
69ping -c $ipcount $nfs_server_ipaddr 
70
71# Finally mounts the NFS share
72LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
73mount -t nfs -o nolock $nfsmount /tmp/isodir
74
75LogIt "Mounting NFS image $imgname-1.iso in $dirimg on /mnt/cdrom in loopback"
76losetup /dev/loop7 /tmp/isodir/$dirimg/$imgname-1.iso
77mount -o ro -t iso9660 /dev/loop7 /mnt/cdrom
Note: See TracBrowser for help on using the repository browser.