
echo "[2J[1;1H[1;33m"

if [ ! -x "qtc" ] ; then
  echo "[1;33mCompiling the Teleconference"
	make
fi

echo "[1;33mEnter the name of the directory you wish to install the"
echo "the teleconference into.  This MUST be the full path (~'s are ok)"
echo -n "[[1;37m~bbs/doors/qtc[1;33m]: [0m"
read INSTALLDIR
if [ -z $INSTALLDIR ] ; then
	INSTALLDIR=~bbs/doors/qtc
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 ./qtc $INSTALLDIR
cp -i ./qtcload $INSTALLDIR
cp -i ./INSTALL $INSTALLDIR
cp -i ./privuser.txt $INSTALLDIR
cp -i ./actions.dat $INSTALLDIR
cp -i ./welcome.ans $INSTALLDIR
cp -i ./qtc.cfg $INSTALLDIR
> $INSTALLDIR/tcuser.dat
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/qtc
chown $BBSUID:$BBSGID $INSTALLDIR/qtcload
chown $BBSUID:$BBSGID $INSTALLDIR/privuser.txt
chown $BBSUID:$BBSGID $INSTALLDIR/INSTALL
chown $BBSUID:$BBSGID $INSTALLDIR/actions.dat
chown $BBSUID:$BBSGID $INSTALLDIR/welcome.ans
chown $BBSUID:$BBSGID $INSTALLDIR/qtc.cfg
chown $BBSUID:$BBSGID $INSTALLDIR/tcuser.dat
echo "Done...  "
cd $INSTALLDIR
echo "[0m"
less INSTALL
