tput clear
Dirori=`pwd`
Dirdest=`pwd`
if [ ! -z "$1" ]
then
    Dirori="$1"
fi
if [ ! -z "$2" ]
then
    Dirdest="$2"
fi

# Server 
nomsys=`uname -s`
case ${nomsys} in
    Linux ) abrmach='lux' ; cpioc="" ;;
    AIX )  abrmach='aix'  ; cpioc="c" ;;
 ## HP-UX ) abrmach='hpx' ; cpioc="c" ;;
    * ) echo "`uname -a`  : unknown server !!! "
        exit
	;;
esac

echo "Copy in progress ..."

if [ ! -d $Dirdest ]
then
      echo "Directory not found : ${Dirdest}"
      exit 1
fi

if [ "${Dirori}" = "${Dirdest}" ]
then

   if [ ! -f "$Dirdest/adweb${abrmach}".tar.gz ]
   then
      echo " File not found : $Dirdest/adweb${abrmach}.tar.gz "
      exit 1
   else
     # zcat  $Dirdest/adweb${abrmach}.Z | cpio -iB${cpioc}vdum
     tar -xvzf $Dirori/adweb${abrmach}.tar.gz
      echo "$Dirdest"   >  $Dirdest/adsrcobj
      chmod 666 $Dirdest/adsrcobj
      echo "$Dirdest"   >  $Dirdest/adsrcdemo
      chmod 666 $Dirdest/adsrcdemo
      echo "$Dirdest"   >  $Dirdest/adsrchlp 
      chmod 666 $Dirdest/adsrchlp
   fi

else

  if [ -f "$Dirori/adweb${abrmach}".tar.gz ]
  then
    cd  "$Dirdest"
    #zcat $Dirori/adweb${abrmach}.Z | cpio -iB${cpioc}vdum
    tar -xvzf $Dirori/adweb${abrmarch}.tar.gz
  else
    echo " File not found : $Dirori/adweb${abrmach}.tar.gz "
    exit 1                                                  
  fi

fi

## Product (X3/ABELX3/GX/PAIE)
wproduct=""
## IG le 01/08/06: On force le contenu de product.id
wproduct="X3" 
##
while [ -z "${wproduct}" ]
do
 /usr/bin/clear
 echo ""
 echo "SELECT THE PRODUCT"
 echo "=================="
 echo ""
 echo "        X3          : 1  (RET)"
 echo "        ABELX3      : 2  (RET)"
 echo "        GX          : 3  (RET)"
 echo "        PAIE        : 4  (RET)"
 echo " "
 echo "        QUIT        : 99 (RET)"
 echo " "
 read rep
 case $rep in
  1) wproduct="X3" ;;
  2) wproduct="ABELX3" ;;
  3) wproduct="GX" ;;
  4) wproduct="PAIE" ;;
 99) break;;
  *) continue;;
 esac
done

if [ ! -z "${wproduct}" ]
then
  echo "${wproduct}"  > $Dirdest/product.id
  chmod 644             $Dirdest/product.id
else
## IG le 01/08/06: On force le contenu de product.id
   wproduct="X3" 
   echo "${wproduct}"  > $Dirdest/product.id
   chmod 644             $Dirdest/product.id
fi

##
## Divers
##
echo "$Dirdest"    >  $Dirdest/adsrcdemo
chmod 666 $Dirdest/adsrcdemo
echo "$Dirdest"    >  $Dirdest/adsrchlp 
chmod 666 $Dirdest/adsrchlp
if [ ! -f $Dirdest/adshmess ]
then
   echo " File not found : $Dirdest/adshmess"
   exit 1                                                  
fi
if [ ! -f $Dirdest/adinstal.sh ]
then
   echo " File not found : $Dirdest/adinstal.sh"
   exit 1                                                  
fi

if [ ! -f $Dirdest/product.id ]
then
   echo " File not found : $Dirdest/product.id"
   exit 1                                                  
fi

chmod 755 $Dirdest/adinstal.sh

echo "Normal end of copy procedure

- Now run procedure 'adinstal.sh' as below

   ./adinstal.sh  xxx

    xxx : Language to use for messages in the script [ FRA | ENG ] (default=FRA)


- choose option 6 to install SAFE X3 WEB SERVER

"
