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