Whamcloud - gitweb
Fixes to get things running on 2.4.3.
[fs/lustre-release.git] / lustre / demos / basesetup.sh
1 #! /bin/sh
2 # Get the locations for the files from a single place to avoid confusion
3 #
4 # Copyright (C) 2001  Cluster File Systems, Inc.
5 #
6 # This code is issued under the GNU General Public License.
7 # See the file COPYING in this distribution
8 OBDDIR="`dirname $0`/.."
9
10 # source config info
11 . $OBDDIR/demos/config.sh
12
13 # module configuration
14 if [ "$MODCONF" -a -f $MODCONF ]; then
15     if [ -z "`grep -i "alias  *char-major-$OBDMAJ  *obdclass" $MODCONF`" ]; then
16         if [ -d /etc/modutils ]; then
17             # Debian-style modules configuration.
18             echo "alias char-major-${OBDMAJ} obdclass" > /etc/modutils/obd
19             update-modules
20         else
21             echo "alias char-major-${OBDMAJ} obdclass" >>$MODCONF
22         fi
23     fi
24 fi
25
26
27 # temp file
28 if [ "$LOOPDEV" -a "$TMPFILE" -a -f $TMPFILE ]; then 
29     echo "$TMPFILE exists; I'm unwilling to overwrite it.  Remove [N/y]?" 1>&2
30     rm -i $TMPFILE
31     [ -f $TMPFILE ] && exit 1
32 fi
33 [ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=$TMPSIZE
34
35
36 # loop device
37 if [ "$LOOPDEV" ]; then
38     insmod loop > /dev/null 2>&1
39     if [ -a "`losetup $LOOPDEV 2> /dev/null`" ]; then
40         echo "It appears that $LOOPDEV is in use.  Unable to continue" 1>&2
41         echo "You need to clean up $LOOPDEV (via cleanup.sh),"
42         echo "or you can change which device is used in demos/config.sh" 1>&2
43         # undo previous
44         [ "$TMPFILE" ] && rm $TMPFILE
45         exit 2
46     fi
47     losetup $LOOPDEV $TMPFILE
48 fi
49
50 # Ensure that we have the correct devices for OBD to work
51 [ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0
52 [ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1
53 [ ! -c /dev/obd2 ] && mknod /dev/obd2 c $OBDMAJ 2
54
55
56 if [ "$BASEDEV" ]; then
57     mke2fs -r 0 -b 4096 $BASEDEV
58 else
59     echo "\$BASEDEV not defined in demos/config.sh.  Please fix!"
60     [ "$LOOPDEV" ] && losetup -d $LOOPDEV 
61     [ "$TMPFILE" ] && rm $TMPFILE
62     exit 3
63 fi