
echo "[2J[1;1H[1;33mEnter the name of the directory you wish to install the"
echo "the game into.  This MUST be the full path (~'s are ok)"
echo -n "[[1;37m~bbs/doors/wofalken[1;33m]: [0m"
read INSTALLDIR
if [ -z $INSTALLDIR ] ; then
	INSTALLDIR=~bbs/doors/wofalken
fi

echo -n "[1;37m$INSTALLDIR [1;33mis the correct directory? ([1;37my[1;33m/[1;37mN[1;33m): [0m"
read YN
if [ $YN != "y" -a $YN != "Y" ] ; then
	echo "Exiting error 2"
  exit 1
fi
if [ ! -d $INSTALLDIR ] ; then
	echo -en "[1;37m$INSTALLDIR [1;33mdoesn't exist. \nDo you want to create it ([1;37my[1;33m/[1;37mN[1;33m): [0m"
	read YN
	if [ $YN != "y" -a $YN != "Y" ] ; then
		exit 1
	fi
	mkdir -p $INSTALLDIR
fi
echo "[1;33mCopying files..."
cp -i ./wofalken $INSTALLDIR
cp -i ./wofload $INSTALLDIR
cp -i ./woflog $INSTALLDIR
cp -i ./INSTALL $INSTALLDIR
cp -i ./puzzles.dat $INSTALLDIR
echo "Copy complete"
echo "[1;34m-----------------------------------------------------"
echo "[1;33mWhat is the name of the bbs user:"
echo -n "[[1;37mbbs[1;33m]: [0m"
read BBSUID
BBSGID=`id -gn bbs`
echo "[1;33mWhat is the group id of the bbs user"
echo -n "[[1;37m$BBSGID[1;33m]: [0m"
read BBSGID
if [ -z $BBSUID ] ; then
	BBSUID="bbs"
fi
if [ -z $BBSGID ] ; then
	BBSGID=`id -gn bbs`
fi
echo "[1;33mSetting Ownership..."
chown $BBSUID:$BBSGID $INSTALLDIR
chown $BBSUID:$BBSGID $INSTALLDIR/wofalken
chown $BBSUID:$BBSGID $INSTALLDIR/wofload
chown $BBSUID:$BBSGID $INSTALLDIR/woflog
chown $BBSUID:$BBSGID $INSTALLDIR/INSTALL
chown $BBSUID:$BBSGID $INSTALLDIR/puzzles.dat
echo "Done...  "
echo "Initializing the Wheel of Falken data files"
cd $INSTALLDIR
./wofalken init
echo "Setting Ownership on WoF data files"
chown $BBSUID:$BBSGID $INSTALLDIR/wofgames.dat
chown $BBSUID:$BBSGID $INSTALLDIR/highscore.dat
chown $BBSUID:$BBSGID $INSTALLDIR/games.dat
echo "[0m"
less INSTALL
