source: MondoRescue/branches/stable/mindi/rootfs/sbin/start-nfs@ 740

Last change on this file since 740 was 740, checked in by Bruno Cornec, 18 years ago

start-nfs is now an external script under /sbin
No more generation in init (variable substitution errors thus avoided)

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/sh
2#
3# number of ping
4#
5ipcount=3
6
7# Get info from config file
8ipdev=`grep nfs-dev /tmp/mondo-restore.cfg | cut -d' ' -f2-`
9ipaddress=`grep nfs-client-ipaddr /tmp/mondo-restore.cfg | cut -d' ' -f2-`
10ipnetmask=`grep nfs-client-netmask /tmp/mondo-restore.cfg | cut -d' ' -f2-`
11ipbroadcast=`grep nfs-client-broadcast /tmp/mondo-restore.cfg | cut -d' ' -f2-`
12ipgateway=`grep nfs-client-defgw /tmp/mondo-restore.cfg | cut -d' ' -f2-`
13ipconf=""
14nfsmount=`grep nfs-server-mount /tmp/mondo-restore.cfg | cut -d' ' -f2-`
15imgname=`grep iso-prefix /tmp/mondo-restore.cfg | cut -d' ' -f2-`
16if [ "$imgname" = "" ]; then
17 imgname="mondorescue"
18fi
19dirimg=`grep nfs-server-path /tmp/mondo-restore.cfg | cut -d' ' -f2-`
20if [ "$dirimg" = "" ]; then
21 dirimg="/"
22fi
23
24# info from cmdline are predominent
25for i in `cat /proc/cmdline` ; do
26 echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
27 echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
28 echo $i | grep -qi nfsmount= && nfsmount=`echo $i | cut -d= -f2`
29 echo $i | grep -qi prefix= && imgname=`echo $i | cut -d= -f2`
30done
31
32if [ $ipdev = "" ] && [ $ipconf = "" ]; then
33 # No network configuration neither stored during archive
34 # nor on cmdline so no network wanted => exiting
35 exit 0
36else
37 LogIt "Starting Network..."
38fi
39
40# Activate loobback
41ifconfig lo 127.0.0.1
42
43echo "$ipconf" | grep -q "dhcp"
44if [ $? -eq 0 ]; then
45 ipdev=`echo $ipconf | cut -d: -f1`
46 echo "Making DHCP request on $ipdev"
47 udhcpc -i $ipdev
48else
49 if [ "$ipconf" != "" ]; then
50 ipdev=`echo $ipconf | cut -d: -f1`
51 ipaddress=`echo $ipconf | cut -d: -f2`
52 ipnetmask=`echo $ipconf | cut -d: -f3`
53 ipbroadcast=`echo $ipconf | cut -d: -f4`
54 ipgateway=`echo $ipconf | cut -d: -f5`
55 fi
56 echo "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
57 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
58 route add default gw $ipgateway
59fi
60
61# ping server helps waking interface up
62LogIt "Pinging NFS server..."
63nfs_server_ipaddr=`echo $nfsmount | cut -d: -f1`
64ping -c $ipcount $nfs_server_ipaddr
65
66# Finally mounts the NFS share
67LogIt "Mounting NFS share ($nfsmount) on /tmp/isodir..."
68mount -t nfs -o nolock $nfsmount /tmp/isodir
69
70LogIt "Mounting NFS image $imgname-1.iso in $dirimg on /mnt/cdrom in loopback"
71losetup /dev/loop7 /tmp/isodir/$dirimg/$imgname-1.iso
72mount -o ro -t iso9660 /dev/loop7 /mnt/cdrom
Note: See TracBrowser for help on using the repository browser.