source: MondoRescue/branches/2.2.9/mindi/rootfs/sbin/start-netfs@ 2707

Last change on this file since 2707 was 2707, checked in by Bruno Cornec, 13 years ago

r4183@localhost: bruno | 2011-01-27 10:49:32 +0100

  • Fix a syntax bug for start-netfs on proto detection
  • Property svn:executable set to *
File size: 3.7 KB
RevLine 
[742]1#!/bin/sh
[740]2#
[741]3# $Id$
4#
[2380]5# This script sets up the network + Network FS environment if needed.
[741]6#
7
8
[740]9# number of ping
10ipcount=3
11
12# Get info from config file
[2380]13ipdev=`grep netfs-dev /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
14ipaddress=`grep netfs-client-ipaddr /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
15ipnetmask=`grep netfs-client-netmask /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
16ipbroadcast=`grep netfs-client-broadcast /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
17ipgateway=`grep netfs-client-defgw /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
18proto=`grep netfs-proto /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]19ipconf=""
[2255]20pre=""
21post=""
[2380]22export netfsmount=`grep netfs-server-mount /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[1983]23export imgname=`grep iso-prefix /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]24if [ "$imgname" = "" ]; then
[801]25 export imgname="mondorescue"
[740]26fi
[2380]27export dirimg=`grep netfs-server-path /tmp/mondo-restore.cfg 2> /dev/null | cut -d' ' -f2-`
[740]28if [ "$dirimg" = "" ]; then
[801]29 export dirimg="/"
[740]30fi
31
32# info from cmdline are predominent
33for i in `cat /proc/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`
[2380]36 echo $i | grep -qi netfsmount= && export netfsmount=`echo $i | cut -d= -f2`
[2498]37 echo $i | grep -qi netfsopt= && export netfsopt=`echo $i | cut -d= -f2`
[801]38 echo $i | grep -qi prefix= && export imgname=`echo $i | cut -d= -f2`
[2380]39 echo $i | grep -qi netfspath= && export dirimg=`echo $i | cut -d= -f2`
[2255]40 echo $i | grep -qi pre= && pre=`echo $i | cut -d= -f2`
41 echo $i | grep -qi post= && post=`echo $i | cut -d= -f2`
[2380]42 echo $i | grep -qi proto= && proto=`echo $i | cut -d= -f2`
[740]43done
44
[1830]45if [ "$ipdev" != "" ] || [ "$ipconf" != "" ]; then
46 # Network configuration stored during archive
47 # or on cmdline so network wanted => starting it
[740]48 LogIt "Starting Network..."
49
[1830]50 # Activate loobback
51 ifconfig lo 127.0.0.1
[740]52
[1830]53 echo "$ipconf" | grep -q "dhcp"
54 if [ $? -eq 0 ]; then
[740]55 ipdev=`echo $ipconf | cut -d: -f1`
[1830]56 LogIt "Making DHCP request on $ipdev"
57 udhcpc -i $ipdev
58 else
59 if [ "$ipconf" != "" ]; then
60 ipdev=`echo $ipconf | cut -d: -f1`
61 ipaddress=`echo $ipconf | cut -d: -f2`
62 ipnetmask=`echo $ipconf | cut -d: -f3`
63 ipbroadcast=`echo $ipconf | cut -d: -f4`
64 ipgateway=`echo $ipconf | cut -d: -f5`
65 fi
66 LogIt "Configuring $ipdev statically ($ipaddress/$ipnetmask)"
67 ifconfig $ipdev $ipaddress netmask $ipnetmask broadcast $ipbroadcast
68 route add default gw $ipgateway
[740]69 fi
70
[1830]71 # ping server helps waking interface up
[2380]72 LogIt "Pinging Remote server..."
73 netfs_server_ipaddr=`echo $netfsmount | cut -d: -f1 | cut -d@ -f2`
74 ping -c $ipcount $netfs_server_ipaddr
[740]75
[2380]76 # Which is our protocol for file sharing
77 if [ "$proto" = "" ]; then
78 LogIt "No protocol specified, defaulting to NFS"
[2707]79 proto = "nfs"
[2380]80 fi
81
82 if [ "$proto" = "sshfs" ]; then
83 LogIt "Mounting SSHFS share ($netfsmount) on /tmp/isodir..."
[2438]84 # We need a correct console for ssh
85 ln -sf /dev/console /dev/tty
[2498]86 sshfs -o ro,StrictHostKeyChecking=no $netfsopt $netfsmount /tmp/isodir
[2380]87 elif [ "$proto" != "" ]; then
88 LogIt "Mounting Network share ($netfsmount) on /tmp/isodir..."
89 touch /etc/mtab
[2498]90 mount -t $proto -o nolock,ro $netfsopt $netfsmount /tmp/isodir
[2380]91 else
92 LogIt "Unknown protocol $proto"
93 fi
[1830]94
[2380]95 LogIt "Mounting Remote image ${imgname}-1.iso in $dirimg on /mnt/cdrom in loopback"
[1927]96 mount -o ro,loop -t iso9660 /tmp/isodir/$dirimg/${imgname}-1.iso /mnt/cdrom
[2253]97
[2380]98 # Save the scripts on the Network share locally
[2255]99 if [ "`echo $pre | grep -E '^/tmp/isodir'`" ]; then
100 cp $pre /tmp
101 LogIt "Copying $pre under /tmp"
[2253]102 fi
[2255]103 if [ "`echo $post | grep -E '^/tmp/isodir'`" ]; then
104 cp $post /tmp
105 LogIt "Copying $post under /tmp"
106 fi
[1830]107fi
Note: See TracBrowser for help on using the repository browser.