Whamcloud - gitweb
7d1beb3ec8907e0cc1353b4db3d47635e32b4519
[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 insmod obdclass
14 insmod obdext2
15 insmod obdfs
16
17 # module configuration
18 if [ "$MODCONF" -a -f $MODCONF ]; then
19     if [ -z "`grep -i "alias  *char-major-$OBDMAJ  *obdclass" $MODCONF`" ]; then
20         if [ -d /etc/modutils ]; then
21             # Debian-style modules configuration.
22             echo "alias char-major-${OBDMAJ} obdclass" > /etc/modutils/obd
23             update-modules
24         else
25             echo "alias char-major-${OBDMAJ} obdclass" >>$MODCONF
26         fi
27     fi
28 fi
29
30
31 # temp file
32 if [ "$LOOPDEV" -a "$TMPFILE" -a -f $TMPFILE ]; then 
33     echo "$TMPFILE exists; I'm unwilling to overwrite it.  Remove [N/y]?" 1>&2
34     rm -i $TMPFILE
35     [ -f $TMPFILE ] && exit 1
36 fi
37 [ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=$TMPSIZE
38
39
40 # loop device
41 if [ "$LOOPDEV" ]; then
42     insmod loop > /dev/null 2>&1
43     if [ -a "`losetup $LOOPDEV 2> /dev/null`" ]; then
44         echo "It appears that $LOOPDEV is in use.  Unable to continue" 1>&2
45         echo "You need to clean up $LOOPDEV (via cleanup.sh),"
46         echo "or you can change which device is used in demos/config.sh" 1>&2
47         # undo previous
48         [ "$TMPFILE" ] && rm $TMPFILE
49         exit 2
50     fi
51     losetup $LOOPDEV $TMPFILE
52 fi
53
54 # Ensure that we have the correct devices for OBD to work
55 [ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0
56 [ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1
57 [ ! -c /dev/obd2 ] && mknod /dev/obd2 c $OBDMAJ 2
58
59
60 if [ "$BASEDEV" ]; then
61     mke2fs -r 0 -b 4096 $BASEDEV
62 else
63     echo "\$BASEDEV not defined in demos/config.sh.  Please fix!"
64     [ "$LOOPDEV" ] && losetup -d $LOOPDEV 
65     [ "$TMPFILE" ] && rm $TMPFILE
66     exit 3
67 fi