#!/bin/sh
if [ "`echo -n`" = "-n" ]; then
   C='\c'
   N=
else
   N='-n'
   C=
fi
directory="/usr/local/cwlm"
echo $N "Input the License Manager Directory (default = $directory:) $C"
read tmp
if [ -n "$tmp" ]; then
   directory=$tmp
fi

if [ -d $directory ] ; then
   if [ -f "$directory/lmgrd" ] ; then
      echo "WARNING - lmgrd CURRENTLY EXISTS IN SPECIFIED DIRECTORY"
      echo "          INSTALL WILL OVERWRITE lmgrd IF YOU CONTINUE"
   fi
fi

echo "The license server will be installed in directory: $directory"
con="Z"
while : 
do
   if [ $con = "Y" ] || [ $con = "y" ] || [ $con = "N" ] || [ $con = "n" ]
   then
      break
   fi
   echo $N "Do you want to continue y/n? $C"
   read con
done
if [ $con = "Y" ] || [ $con = "y" ]; then
      if [ ! -d $directory ] ; then
         mkdir $directory
         if [ $? != 0 ] ; then
            err=$?
            echo "install has failed"
            exit $err
         fi
      fi
      cp readme.txt $directory/readme.txt
      if [ $? != 0 ] ; then
         err=$?
         echo "install has failed"
         exit $err
      fi
      cp lmgrd $directory/lmgrd
      if [ $? != 0 ] ; then
         err=$?
         echo "install has failed"
         exit $err
      fi
      cp compuwar $directory/compuwar
      if [ $? != 0 ] ; then
         err=$?
         echo "install has failed"
         exit $err
      fi
      cp lmutil $directory/lmutil
      if [ $? != 0 ] ; then
         err=$?
         echo "install has failed"
         exit $err
      fi
      echo "The License Manager has been installed"
fi
