#!/bin/sh
# This script is run as part of the %post in the fermitest-2 rpm.
# The goal is to detect which partitions are available
# and record them in /etc/bonnie.conf
cat /dev/null > /etc/bonnie.conf
# We presume that any directory /local/stage? should have bonnie
# test done to it *except* if it is on the same physical disk
# as another /local/stage partition.
# First make the /local/stage0 directory:
# Check for a /inst partition, if so, put it there ]
if [ ! -e /local/stage0 ] 
then 
	if [ ! "$(grep inst /etc/fstab)" = "" ] 
	then
    		ln -s /inst /local/stage0
	elif [ ! "$(grep '/local/ups' /etc/fstab)" = "" ]
        then
		ln -s /local/ups /local/stage0
        else
# put it on the / partition
    	mkdir /local/stage0
	fi
fi

START=0
END=9
STAGE=$START
USEDDISK=""
while [ $STAGE -le $END ]
do
	if [ $STAGE -eq 0 ]
	then
		TYPE="sys"
	else
		TYPE="data"
	fi
        if [ -e /local/stage${STAGE} ] 
        then
	DISKLINE="`df /local/stage${STAGE} | grep dev`" 
#        echo $DISKLINE
#        echo $STAGE	
        if [ ! "$DISKLINE" = "" ]
        	then 
#  Pick out the device it's mounted on  (not sure if this will work 
#  during install)
        	DISK="${DISKLINE:5:3}"
        	USED="N"
        	for disklet in $USEDDISK
		do
			if [ "$DISK" = "$disklet" ]
			then
				USED="Y"
			fi
		done
		if [ !  "$USED" = "Y" ]
		then
			USEDDISK="$USEDDISK $DISK"
			echo "${TYPE}:/local/stage${STAGE}:1024:${DISK}" >> /etc/bonnie.conf
       		fi
                fi
        fi	
STAGE=`expr $STAGE + 1`
done

