Whamcloud - gitweb
demos/*: update demos to handle module autoloading (Steve Bruggeman)
[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 OBDDIR="`dirname $0`/.."
4
5 # source config info
6 . $OBDDIR/demos/config.sh
7
8 # module configuration
9 if [ "$MODCONF" -a -f $MODCONF ]; then
10     if [ -z "`grep -i "alias  *char-major-$OBDMAJ  *obdclass" $MODCONF`" ]; then
11          echo "alias char-major-${OBDMAJ} obdclass" >>$MODCONF
12     fi
13 fi
14
15
16 # temp file
17 if [ "$TMPFILE" -a -f $TMPFILE ]; then 
18     echo "$TMPFILE exists; I'm unwilling to overwrite it.  Remove [N/y]?" 1>&2
19     rm -i $TMPFILE
20     [ -f $TMPFILE ] && exit 1
21 fi
22 [ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=$TMPSIZE
23
24
25 # loop device
26 insmod loop > /dev/null 2>&1
27 if [ "$LOOPDEV" -a "`losetup $LOOPDEV 2> /dev/null`" ]; then
28     echo "It appears that $LOOPDEV is in use.  Unable to continue" 1>&2
29     echo "You need to clean up $LOOPDEV (via cleanup.sh),"
30     echo "or you can change which device is used in demos/config.sh" 1>&2
31     # undo previous
32     [ "$TMPFILE" ] && rm $TMPFILE
33     exit 2
34 fi
35
36 [ "$LOOPDEV" ] && losetup $LOOPDEV $TMPFILE
37 # Ensure that we have the correct devices for OBD to work
38 [ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0
39 [ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1
40 [ ! -c /dev/obd2 ] && mknod /dev/obd2 c $OBDMAJ 2
41
42
43 if [ "$BASEDEV" ]; then
44     mke2fs -b 4096 $BASEDEV
45 else
46     echo "\$BASEDEV not defined in demos/config.sh.  Please fix!"
47     [ "$LOOPDEV" ] && losetup -d $LOOPDEV 
48     [ "$TMPFILE" ] && rm $TMPFILE
49     exit 3
50 fi