#!/bin/sh

# Configure parameters for lmbench.
# $Id: config-run,v 1.1 1994/11/26 00:40:59 lm Exp $

cat<<EOF;

You need to configure some parameters to lmbench.  Once you have configured
these parameters, you may do multiple runs by saying

	make rerun

in the src subdirectory.

EOF

# Figure out echo.
if [ `echo -n "foo" | wc -l` -eq 0 ]
then	ECHON="-n"; ECHOC=
else	ECHON= ; ECHOC='\c'
fi

AGAIN=Y
while [ $AGAIN = Y ]
do
	cat<<EOF;

If you are running as root and you want to get disk latency results,
please specify the disk device to use, such as /dev/rsd0a.

EOF
	echo $ECHON "DISK [default none] $ECHOC"
	read DISK
	if [ -c "$DISK" -o X$DISK = X ]
	then	AGAIN=N
	else	echo $DISK is not a raw disk device
	fi
done

AGAIN=Y
while [ $AGAIN = Y ]
do
	cat<<EOF;

For the memory latency benchmark, we use an 8 Mbyte file.  If you think
that your external cache is 8 Mbyte or larger (unlikely), then specify
a size 4 Mbyte larger than your external cache, in Mbytes.  For example,
if your external cache was 12 Mbyte, use 16.

EOF
	echo $ECHON "MB [default 8] $ECHOC"
	read MB
	if [ X$MB = X ]
	then	MB=8
	fi
	if [ $MB -ge 8 ]
	then	AGAIN=N
	else	echo MB must be at least 8
	fi
done

AGAIN=Y
while [ $AGAIN = Y ]
do
	cat<<EOF;

We need a place to store a $MB Mbyte file as well as create and delete
a large number of small files.  You can use /tmp if there is enough
space but /tmp is sometimes a memory resident file system (which is 
a unfair for the lat_fs benchmark).  Please specify a directory that
has enough space and is a local file system.

EOF
	echo $ECHON "FSDIR [default /tmp] $ECHOC"
	read FSDIR
	if [ X$FSDIR = X ]
	then	FSDIR=/tmp
	else	mkdir -p $FSDIR 2>/dev/null
	fi
	if [ -d $FSDIR -a -w $FSDIR ]
	then	AGAIN=N
		FILE=$FSDIR/XXX
	else	echo $FSDIR is not a directory or is not writable
	fi
done

cat<<EOF;

If you are running on an idle network and there are other, identically
configured systems, on the same wire (no gateway between you and them),
and you have rsh access to them, then you should run the network part
of the benchmarks to them.  Please specify any such systems as a space
separated list such as: ether-host fddi-host hippi-host.

EOF
echo $ECHON "REMOTE [default none] $ECHOC"
read REMOTE

if [ "X$REMOTE" != X ]
then	cat<<EOF;

Thanks for doing remote testing, that is a hard thing to get.  Could you
do me one more favor and tell me the networking you think will be used
to get to each of the remote hosts.  By networking I mean one of the
following (or whatever you use if you use something else):

ethernet		aka 10baseT, thinnet, thicknet, etc
ethernet-100		aka 100baseT, 100VG
fddi			aka cddi
hippi
others?

Please type it just like the above if you can, it makes parsing easier.

EOF

	for r in $REMOTE
	do	echo $ECHON "Network type for $r: $ECHOC"
		read n
		NETWORKS="${NETWORKS}$r:$n "
	done
fi

if [ X$1 != X ]
then	OUTPUT=$1
else	OUTPUT=/dev/tty
fi

echo "Confguration done, thanks."
echo ""

cat<<EOF > $OUTPUT
DISK=$DISK
FILE=$FILE
FSDIR=$FSDIR
MB=$MB
REMOTE=$REMOTE
NETWORKS=$NETWORKS
EOF

exit 0
