source: MondoRescue/branches/2.2.10/mindi/rootfs/sbin/start-netfs@ 2462

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

r3548@localhost: bruno | 2009-10-16 19:18:27 +0200

  • mindi now boots in a QEMU VM without busybox
  • mindi is now noarch as a consequence
  • MINDI_LIB becomes MINDI_DATA for coherency and as a consequence
  • CACHEDIR becomes MINDI_CACHE for coherency and it's a build parameter and not hardcoded anymore in mindi
  • THat variable is also used at restore time for mondorestore.cfg e.g.
  • FAILSAFE kernel is gone. Just use another kernel of your choice. Most std kernels work anyway
  • TurnTgzIntoRdz rewritten and now really computes data disk size and not suppose its size
  • Interface mondo/mindi changed again => incompatible
  • Non-bootable media not supported anymore.
  • Mondorescue adapted to these changes but not tested yet
  • Doc updated as well
  • Property svn:executable set to *
File size: 3.6 KB
Line 
1#!/bin/sh
2#
3# $Id$
4#
5# This script sets up the network + Network FS environment if needed.
6#
7
8
9# number of ping
10ipcount=3
11
12# Get info from config file
13ipdev=`grep netfs-dev $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
14ipaddress=`grep netfs-client-ipaddr $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
15ipnetmask=`grep netfs-client-netmask $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
16ipbroadcast=`grep netfs-client-broadcast $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
17ipgateway=`grep netfs-client-defgw $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
18proto=`grep netfs-proto $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
19ipconf=""
20pre=""
21post=""
22export netfsmount=`grep netfs-server-mount $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
23export imgname=`grep iso-prefix $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
24if [ "$imgname" = "" ]; then
25 export imgname="mondorescue"
26fi
27export dirimg=`grep netfs-server-path $MINDI_CACHE/mondorestore.cfg 2> /dev/null | cut -d' ' -f2-`
28if [ "$dirimg" = "" ]; then
29 export dirimg="/"
30fi
31
32# info from cmdline are predominent
33for i in `cat $CMDLINE` ; do
34 echo $i | grep -qi ping= && ipcount=`echo $i | cut -d= -f2`
35 echo $i | grep -qi ipconf= && ipconf=`echo $i | cut -d= -f2`
36 echo $i | grep -qi netfsmount= && export netfsmount=`echo $i | cut -d= -f2`
37 echo $i | grep -qi prefix= && export imgname=`echo $i | cut -d= -f2`
38 echo $i | grep -qi netfspath= && export dirimg=`echo $i | cut -d= -f2`
39 echo $i | grep -qi pre= && pre=`echo $i | cut -d= -f2`
40 echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
41 echo $i | grep -qi proto= && proto=`echo $i | cut -d= -f2`
42done
43
44if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
45 # Network configuration stored during archive
46 # or on cmdline so network wanted => starting it
47 LogIt "Starting Network..."
48
49 # Activate loobback
50 ifconfig lo 127.0.0.1
51
52 echo "$ipconf" | grep -q "dhcp"
53 if [ $? -eq 0 ]; then
54 ipdev=`echo $ipconf | cut -d: -f1`
55 LogIt "Making DHCP request on $ipdev"
56 udhcpc -i $ipdev
57 else
58 if [ "$ipconf" != "" ]; then
59 ipdev=`echo $ipconf | cut -d: -f1`
60 ipaddress=`echo $ipconf | cut -d: -f2`
61 ipnetmask=`echo $ipconf | cut -d: -f3`
62 ipbroadcast=`echo $ipconf | cut -d: -f4`
63 ipgateway=`echo $ipconf | cut -d: -f5`
64 fi
65 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
66 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
67 route add default gw $ipgateway
68 fi
69
70 # ping server helps waking interface up
71 LogIt "Pinging Remote server..."
72 netfs_server_ipaddr=`echo $netfsmount | cut -d: -f1 | cut -d@ -f2`
73 ping -c $ipcount $netfs_server_ipaddr
74
75 # Which is our protocol for file sharing
76 if [ "$proto" = "" ]; then
77 LogIt "No protocol specified, defaulting to NFS"
78 $proto = "nfs"
79 fi
80
81 if [ "$proto" = "sshfs" ]; then
82 LogIt "Mounting SSHFS share ($netfsmount) on /tmp/isodir..."
83 # We need a correct console for ssh
84 ln -sf /dev/console /dev/tty
85 sshfs -o ro,StrictHostKeyChecking=no $netfsmount /tmp/isodir
86 elif [ "$proto" != "" ]; then
87 LogIt "Mounting Network share ($netfsmount) on /tmp/isodir..."
88 touch /etc/mtab
89 mount -t $proto -o nolock,ro $netfsmount /tmp/isodir
90 else
91 LogIt "Unknown protocol $proto"
92 fi
93
94 LogIt "Mounting Remote image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
95 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
96
97 # Save the scripts on the Network share locally
98 if [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
99 cp $pre /tmp
100 LogIt "Copying $pre under /tmp"
101 fi
102 if [ "`echo $post | grep -E '^/tmp/isodir'`" ]; then
103 cp $post /tmp
104 LogIt "Copying $post under /tmp"
105 fi
106fi
Note: See TracBrowser for help on using the repository browser.