#!/bin/bash
#
# install script for KPC (version 2)
#

M_VERSION="2"
BINDEST="/usr/local/bin"

clear
echo "KPC DISCLAIMER:
---------------

No warranties, either express or implied, are hereby given. All software
is supplied as is, without guarantee.  The user assumes all responsibility
for damages resulting from the use of these features, including, but not
limited to, frustration, disgust, system abends, disk head-crashes, general
malfeasance, floods, fires, shark attack, nerve gas, locust infestation,
cyclones, hurricanes, tsunamis, local electromagnetic disruptions, hydraulic
brake system failure, invasion, hashing collisions, normal wear and tear
of friction surfaces, comic radiation, inadvertent destruction of sensitive
electronic components, windstorms, the Riders of Nazgul, infuriated chickens,
malfunctioning mechanical or electrical sexual devices, premature activation
of the distant early warning system, peasant uprisings, halitosis, artillery
bombardment, explosions, cave-ins, and/or frogs falling from the sky.

"
echo -n "By pressing [ENTER] you agree to these terms..."
read terms
echo
echo
clear

echo >/tempfile_aj"$LOGNAME"
if [ ! -f /tempfile_aj"$LOGNAME" ] ; then
	echo
	echo "You must have root access to install KPC (version $M_VERSION)"
	echo
	echo "Or you will have to install this manually! Please read the documentation!"
	echo
	exit
else
	echo
	echo
	echo "Please read the documentation before installing KPC!!"
	echo
	echo
	echo -n "Do you wish to install KPC (version $M_VERSION) into $BINDEST (Y/n)?"
	read ajanswer

	if [ "$ajanswer" = "n" -o "$ajanswer" = "no" -o "$ajanswer" = "N" -o "$ajanswer" = "No" -o "$ajanswer" = "NO" ] ; then

		echo
		echo
		echo "You have chosen not to install KPC (version $M_VERSION)"
		echo
		echo "To install manually, look in the program/ directory for the files!"
		echo
		rm -f /tempfile_aj"$LOGNAME"
		exit

	else

		echo
		echo -n "Installing binary into $BINDEST and creating link..."

		rm -f $BINDEST/kpc.sh >/dev/null
		rm -f $BINDEST/kpc >/dev/null

		cp ./program/kpc.sh $BINDEST/
		echo -n "."
		ln -s $BINDEST/kpc.sh $BINDEST/kpc
		echo -n "."
		chmod 0755 $BINDEST/kpc.sh
		echo ".   Done!"


		echo
		echo "If you need any of the following utilities, please install them"
		echo "manually onto your system for KPC (version $M_VERSION) to work!" 
		echo
		echo "      * Bash (Bourne Again Shell)"
		echo "      * Grep"
		echo "      * Sed (Stream Editor)"
		echo "      * SetTerm"
		echo
		echo

	fi

fi

if [ -f /tempfile_aj"$LOGNAME" ] ; then

	rm -f /tempfile_aj"$LOGNAME"

fi
