#!/bin/sh
# yacca installer
# Joe Estock

# simple method to see if yacca is compiled
if test -f "yacca" ; then
	echo " "
	echo "hmm, it looks like yacca is already compiled. i'll skip that for now (i guess)"
	echo " "
else
	echo " "
	echo "compiling yacca this may take a few minutes..." `make all`
	echo " "
fi

# see if the yacca directory aleady exists
if test ! -d "${HOME}/.yacca" ; then
	mkdir ~/.yacca
fi

# display installation status and install data files
echo "installing data/dictionary to ${HOME}/.yacca/dictionary"
	`cp data/dictionary $HOME/.yacca`
echo "installing data/ignorefile to ${HOME}/.yacca/ignorefile"
	`cp data/ignorefile $HOME/.yacca`
echo "installing data/preferences.dat to ${HOME}/.yacca/preferences.dat"
	`cp data/preferences.dat $HOME/.yacca`
echo "installing data/profile to ${HOME}/.yacca/profile"
	`cp data/profile $HOME/.yacca`
echo "installing data/random to ${HOME}/.yacca/random"
	`cp data/random $HOME/.yacca`
echo "installing data/trustlist to ${HOME}/.yacca/trustlist"
	`cp data/trustlist $HOME/.yacca`

# find out who we are running as
YACCAINSTALLUSER=`whoami`

if [ "$YACCAINSTALLUSER" = "root" ] ; then
	# if user is root, install to /usr/local/bin
	echo "installing yacca to /usr/local/bin/yacca" `cp yacca /usr/local/bin/yacca`
	echo "chmod 755 /usr/local/bin/yacca" `chmod 755 /usr/local/bin/yacca`
else
	# install to $HOME/.yacca
	echo "installing yacca to ${HOME}/.yacca/yacca" `cp yacca $HOME/.yacca/yacca`
	echo "chmod 755 ${HOME}/.yacca/yacca" `chmod 755 ${HOME}/.yacca/yacca`
fi
echo " "

# finished
echo "install completed. don't forget to read the README file."