#!/bin/bash
#
# Licensed Program Product:
#   VisualAge Smalltalk Enterprise V6.0.3
#
# (C) COPYRIGHT International Business Machines Corp. 1995, 2005
# All Rights Reserved
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with
# IBM Corp. and its licensors.
#
# Generated   InstallScriptsEtc  (01/28/2002 05:01:46 PM)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# script:  vasetup
# purpose: Sets up a client Smalltalk image for a user.
# parms:   None. User is prompted for input.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#
# Change the value of $vastroot if VisualAge Smalltalk is moved to a different location.
#
vastroot=/opt/IBMvast/6.0

fullVersion=603
imageDir=$vastroot/newimage
icspkgSourceDir=$vastroot/icspk$fullVersion/icspkg


# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set up an appropriate invocation of the cp command.
# For non-HP systems we need to add in the -p option.
# We cannot, however, use the -p option on HP because
# it preserves the original owner... which means the
# receiving user could not, in many cases, modify or
# otherwise make reasonable use the copied files.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
installcmd="cp -ip"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Prompt for target directory and copy the image files.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

cat << EOF



  This command will setup your VisualAge Smalltalk developer's
  work area, copying a starter set of image files into
  a directory of your choosing.

EOF


echo -e "\nHit ENTER to continue..."
read

echo -e "Enter the path of the target directory: "
read targetDir
if [ ! -d $targetDir ] ; then
		mkdir $targetDir
		if [ $? -ne 0 ]; then
				echo -e "\n  ERROR: Unable to create \"$targetDir\"."
				echo -e "  Check filesystem permissions."
				exit 1
		fi
elif [ ! -w $targetDir ] ; then
		echo -e "\n  ERROR: \"$targetDir\" is not writable."
		exit 1
fi

echo -e "\n  copying image files...   \c"
$installcmd $imageDir/* $targetDir
echo -e "done."

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy icspkg tree if user wishes to modify the shipped ICs.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Capture the full target path.
cd $targetDir
fullTargetPath=$PWD
cd - >/dev/null

cat <<EOF

  If you plan on re-packaging any of the shipped VisualAge 
  Smalltalk ICs, then you will need to make a local copy 
  of the icspkg directory.

  You will also need to modify the packagingRootDirectory
  entry in the [Packaging] section of your abt.ini file 
  as follows:

  packagingRootDirectory=$fullTargetPath

EOF

echo -e "Do you wish to copy the IC files locally? y/n"
read answer
if [ $answer = "y" ]; then
	   echo -e "\n  copying icspkg directory...   \c"
	   $installcmd -R $icspkgSourceDir $targetDir/icspkg
	   echo -e "done.\n"
else
	   echo -e "\n  The icspkg directory was not copied locally."
	   echo -e "\n  Please run vasetup again if you wish to modify"
	   echo -e "  the shipped VisualAge Smalltalk ICs.\n"
fi


cat <<EOF

  To start VisualAge, double-click on the "abt" icon in your CDE File
  Manager. Alternatively:

		1. cd $fullTargetPath
		2. xterm -sb -e abt&

EOF

exit 0
