
#
# shell script to install diskhog
#
DQUOTAS="/usr/lib/disk"
BIN="/usr/bin"

echo "Hi there, just a few questions about your system ..."
cat << EOF
I need a place to hold all the information about disk usage and allowances.

I would suggest using the directory $DQUOTAS.

EOF
echo "If you want a different one, enter it here: \c"
read ANS
if [ "$ANS" != "" ]
then
	DQUOTAS=$ANS
	echo "OK, using $DQUOTAS"
fi
if [ -f $DQUOTAS ]
then
	echo "Oh dear, that seems to be a file"
	echo "That won't do at all ..."
	exit 0
else
	if [ -d $DQUOTAS ]
	then
		echo "That directory already exists - I hope it's empty\n"
	else
		echo "Making a new directory"
		mkdir $DQUOTAS $DQUOTAS/hogs
		chmod 755 $DQUOTAS/hogs
		chown root $DQUOTAS/hogs
	fi
fi
cat << EOF
Where do you intend to install the programs?

I would suggest $BIN, but you might use another directory.

EOF
echo "If you want a different directory, enter it here: \c"
read ANS
if [ "$ANS" != "" ]
then
	BIN=$ANS
	echo "OK - using $BIN"
fi
echo "OK - reconfiguring the system ... \c"
cat << EOF > diskhog.h
#define DQUOTAS "$DQUOTAS"
#define BIN "$BIN"
EOF
ed - dcheck << EOF > /dev/null
/^DQUOTAS=/c
DQUOTAS=$DQUOTAS			# directory containing all the info
.
w
q
EOF
ed - diskhog << EOF > /dev/null
/^DQUOTAS=/c
DQUOTAS=$DQUOTAS			# directory containing all the info
.
w
q
EOF
ed Makefile << EOF > /dev/null
/^BIN=/c
BIN=$BIN				# directory for binaries
.
/^DQUOTAS=/c
DQUOTAS=$DQUOTAS
.
w
q
EOF
echo "OK - your system has been configured"
