#!/bin/sh
echo ""
echo "     /*****************************************************************/"
echo "     /**                       I N S T A L L                         **/"
echo "     /**                                                             **/"
echo "     /** This program installs the graphics software DISGCL.  The    **/"
echo "     /** variable  DISLIN must be set to the directory where DIS-    **/"
echo "     /** GCL should be installed:                                    **/"
echo "     /** For example:  DISLIN=/usr/local/dislin                      **/"
echo "     /**               export DISLIN                                 **/"
echo "     /**                                                             **/"
echo "     /** Date   : 15.11.2005                                         **/"
echo "     /** Version: 5.0 / LINUX                                        **/"
echo "     /*****************************************************************/"
echo ""

if test $DISLIN ; then
  echo "Installation of DISGCL in directory "${DISLIN}
  echo ""
else
  echo "The environment DISLIN is not defined!"
  exit 0
fi 

if test ! -d $DISLIN; then 
  mkdir $DISLIN 
  echo "The directory  "${DISLIN}"         is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}

if test ! -d $DISLIN/map; then 
  mkdir $DISLIN/map 
  echo "The directory  "${DISLIN}"/map     is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/map

if test ! -d $DISLIN/man; then 
  mkdir $DISLIN/man 
  echo "The directory  "${DISLIN}"/man     is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/man

if test ! -d $DISLIN/hlp; then 
  mkdir $DISLIN/hlp 
  echo "The directory  "${DISLIN}"/hlp     is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/hlp

if test ! -d $DISLIN/gcldir; then 
  mkdir $DISLIN/gcldir 
  echo "The directory  "${DISLIN}"/gcldir  is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/gcldir

if test ! -d $DISLIN/bin; then 
  mkdir $DISLIN/bin 
  echo "The directory  "${DISLIN}"/bin     is created!"
fi
chmod u=rwx,g=rx,o=rx ${DISLIN}/bin

cp -p gcldir/man/* ${DISLIN}/man
chmod u=rw,g=r,o=r ${DISLIN}/man/*
echo "gcldir/man/*     is copied to  "${DISLIN}"/man"

cp -p gcldir/hlp/* ${DISLIN}/hlp
chmod u=rw,g=r,o=r ${DISLIN}/hlp/*
echo "gcldir/hlp/*     is copied to  "${DISLIN}"/hlp"

cp -p gcldir/*.gcl ${DISLIN}/gcldir
cp -p gcldir/*.ini ${DISLIN}/gcldir
chmod u=rw,g=r,o=r ${DISLIN}/gcldir/*
echo "gcldir/*.gcl     is copied to  "${DISLIN}"/gcldir"
echo "gcldir/*.ini     is copied to  "${DISLIN}"/gcldir"

cp -p linux_gcl/bin/*   ${DISLIN}/bin
echo "linux_gcl/bin/*  is copied to  "${DISLIN}

chmod u=rwx,g=x,o=x ${DISLIN}/bin/gclhlp
chmod u=rwx,g=x,o=x ${DISLIN}/bin/gclhelp
chmod u=rwx,g=x,o=x ${DISLIN}/bin/gclman
chmod u=rwx,g=x,o=x ${DISLIN}/bin/disgcl

if test ! -f $DISLIN/device.dat ; then  
  cp -p device.dat ${DISLIN}
  chmod u=rw,g=r,o=r ${DISLIN}/device.dat
  echo "device.dat       is copied to  "${DISLIN}
fi

if test ! -f $DISLIN/dislin.log ; then  
  cp -p dislin.log ${DISLIN}
  chmod u=rw,g=rw,o=rw ${DISLIN}/dislin.log
  echo "dislin.log       is copied to  "${DISLIN}
fi

cp -p map/* ${DISLIN}/map
chmod u=rw,g=r,o=r ${DISLIN}/map/*
echo "map/*            is copied to  "${DISLIN}"/map"

cp -p README.GCL ${DISLIN}/README.GCL
chmod u=rw ${DISLIN}/README.GCL
echo "README.GCL       is copied to  "${DISLIN}

cp -p DISLIN ${DISLIN}
chmod u=rw,g=r,o=r ${DISLIN}/DISLIN
echo "DISLIN           is copied to  "${DISLIN}
