#!/bin/csh -f
#******************************************************************************
#*                                                                            *
#*  Distiller.install - Template for distiller install script                 *
#*                                                                            *
#******************************************************************************
#

set TAR_FILE = Dist-405.tar

set PLATFORMS    = (sparcsolaris pentiumlinux)
set X_LIBS_PATHS = (/usr/openwin/lib /usr/X11R6/lib)

set PLATFORM_NAMES = (Sparc_Solaris_2.6_or_later Pentium_Red_Hat_Linux_6.0_or_later)

set REMOVE_UNFINISHED  = 0
set REMOVE_INSTALL_DIR = 0

set HERE = `pwd`

set TMP_DIR = /tmp/Dist_47_tmp.$$

set NO_CJK = 0

set INSTALL_SPARCSOLARIS = 0
set INSTALL_PENTIUMLINUX = 0
set GOT_PLATFORM_FLAG    = 0

if ( ($#argv >= 3) && ("$1" == "-force") ) then
   #
   # The syntax for the -force option is:
   #
   # Distiller.install -force install_dir serial_num [-nocjk] [-platform all]
   #
   # Distiller.install -force install_dir serial_num [-nocjk] [-platform sparcsolaris]
   #
   # Distiller.install -force install_dir serial_num [-nocjk] [-platform pentiumlinux]
   #
   set INSTALL_DIR   = $2
   set SERIAL_NUMBER = $3

   echo $INSTALL_DIR > /tmp/Distill-install-dir

   if (`wc -c < /tmp/Distill-install-dir` > 201) then
      echo ""
      echo "*** The pathname is too long. The limit is 200 characters."
      echo ""
      exit 1
   endif
   rm -f /tmp/Distill-install-dir

   while ($#argv >= 4)
      if ("$4" == "-nocjk") then
         set NO_CJK = 1
         shift
      else if ("$4" == "-platform") then
         set GOT_PLATFORM_FLAG = 1
         if ($#argv < 5) then
            echo "*** ERROR: Missing value for -platform argument."
            echo ""
            exit 1
         else
            switch ($5)

                  case all:
                       set INSTALL_SPARCSOLARIS = 1
                       set INSTALL_PENTIUMLINUX = 1
                       breaksw

                  case sparcsolaris:
                       set INSTALL_SPARCSOLARIS = 1
                       breaksw

                  case pentiumlinux:
                       set INSTALL_PENTIUMLINUX = 1
                       breaksw

                  default:
                       echo "*** ERROR: Invalid platform: $5"
                       echo ""
                       exit 1

            endsw

            shift
            shift
         endif
      else
         echo "*** ERROR: Invalid argument: $4"
         echo ""
         exit 1
      endif
   end

   if ($GOT_PLATFORM_FLAG == 0) then
      set INSTALL_SPARCSOLARIS = 1
      set INSTALL_PENTIUMLINUX = 1
   endif

   set FORCE = 1
else
   set INSTALL_SPARCSOLARIS = 1
   set INSTALL_PENTIUMLINUX = 1
   set INSTALL_DIR = none
   set FORCE = 0
endif

if ( ! -e $TAR_FILE ) then
   echo ""
   echo "*** ERROR: Could not find the tar file ($TAR_FILE)."
   echo "The installer expects the tar file to be in the current"
   echo 'directory. Please use the "cd" command to go to the'
   echo "directory where $TAR_FILE is located. Then type:"
   echo ""
   echo "./Distiller.install"
   echo ""
   exit 1
endif

alias check_yes 'if ($ANSWER == y || $ANSWER == Y || $ANSWER == yes || $ANSWER == YES) set ANSWER = y'
alias check_no  'if ($ANSWER == n || $ANSWER == N || $ANSWER == no  || $ANSWER == NO ) set ANSWER = n'

alias check_answer 'check_yes ; check_no'

onintr CLEAN_UP

# ----------------------------------------------- #
# First find out which platform we are running on #
# ----------------------------------------------- #

set MY_PLATFORM = "none"

if (-e /bin/uname) then

   # Check for Sparc_Solaris_2.6_or_later

   if (`/bin/uname -s` == "SunOS") then
      if ( (-e /bin/mach) && (-e /bin/arch) ) then
         if ((`/bin/arch` == "sun4") && (`/bin/mach` == "sparc")) then
            if (`/bin/uname -r | cut -c1` == 5) then
               if (`/bin/uname -r | cut -c3` > 5) then
                  set MY_PLATFORM = sparcsolaris
               endif
            endif
         endif
      endif
   endif

   # Check for Pentium_Red_Hat_Linux_6.0_or_later

   if (`/bin/uname -s` == "Linux") then
      if (-e /bin/arch) then
         /bin/arch |& grep 86 >& /dev/null
         if ($status == 0) then
            if (-e /etc/redhat-release) then
               if (`cat /etc/redhat-release | cut -f5  -d ' ' | cut -c1` > 5) then
                  set MY_PLATFORM = pentiumlinux
            endif
         endif
      endif
   endif

endif

if ($MY_PLATFORM == "none") then
   echo ""
   echo '*** WARNING: You are running this installation script'
   echo 'on an unsupported platform. Supported platforms are:'
   echo ""
   foreach PLATFORM ($PLATFORM_NAMES)
      echo "$PLATFORM"
   end
   echo ""
   echo "You can choose to continue the installation, but the final test and"
   echo "verification will not be done automatically for you. At the end of"
   echo "this installation you will receive instructions on how to verify"
   echo "that the installation was successful."
   echo ""

   if ($FORCE == 1) then
      echo "You have 5 seconds to abort with cntrl-C ..."
      sleep 5
   else
      set ANSWER = x
      while ($ANSWER != y && $ANSWER != n)
         echo -n "Continue (y/n)? "
         set ANSWER = $<
         check_answer
      end
      if ($ANSWER == n) then
         echo "Ok. Installation cancelled."
         goto CANCEL
      endif
   endif

endif

if ($FORCE == 1) then
   echo ""
   echo "Welcome to Acrobat Distiller for Unix. You are running this installation"
   echo 'script in "forced" (non-interactive) mode. In this mode the installation'
   echo "does  not require any  input from  you.  However,  you will  have  the"
   echo "opportunity to abort the installation with cntrl-C at various times"
   echo "during the installation."
   echo ""
   echo "For this installation you have chosen to:"
   echo ""
   if ($INSTALL_SPARCSOLARIS == 1) then
      echo "- Include support for sparcsolaris"
   endif
   if ($INSTALL_PENTIUMLINUX == 1) then
      echo "- Include support for pentiumlinux"
   endif
   if ($NO_CJK == 1) then
      echo "- EXCLUDE support for asian fonts (CJK)"
   else
      echo "- Include support for asian fonts (CJK)"
   endif
   echo ""
   echo "You now have 5 seconds to abort with cntrl-C ..."
   sleep 5
else
   echo ""
   echo "Welcome to Acrobat Distiller for Unix. You will now be guided through"
   echo "the installation process. This installation script will not override"
   echo "any files on your computer without a positive confirmation from you."
   echo "First you must read and accept the End User License Agreement which"
   echo "will be displayed next."
   echo ""

CHOOSE_COUNTRY:

   echo "Choose the country in which you purchased this software:"
   echo ""
   echo "  1) United States/Canada      16) Korea"
   echo "  2) America Latina            17) Luxembourg"
   echo "  3) België                    18) Mexico"
   echo "  4) Belgique                  19) Nederland"
   echo "  5) Brasil                    20) Norge"
   echo "  6) Canada/Francais           21) Österreich"
   echo "  7) Chinese Simplified        22) Portugal"
   echo "  8) Chinese Traditional       23) Republic of South Africa"
   echo "  9) Danmark & Island          24) Schweiz"
   echo " 10) Deutschland               25) Suisse"
   echo " 11) España                    26) Suomi"
   echo " 12) France                    27) Sverige"
   echo " 13) Ireland                   28) Svizzera"
   echo " 14) Italia                    29) United Kingdom"
   echo " 15) Japan                     30) All Other Countries"
   echo ""

   set COUNTRY_NUMBER = ""

   while ("$COUNTRY_NUMBER" == "")
      echo -n 'Enter the number of the country (1-30) or "q" to quit: '
      set COUNTRY_NUMBER = $<
   end

   switch ($COUNTRY_NUMBER)

          case  1:
                   set DISTILL_EULA = Distiller/EndUserLicense/NA_ENU.txt;   breaksw
          case  2:
                   set DISTILL_EULA = Distiller/EndUserLicense/LAS.txt;      breaksw
          case  3:
                   set DISTILL_EULA = Distiller/EndUserLicense/Belg_NL.txt;  breaksw
          case  4:
                   set DISTILL_EULA = Distiller/EndUserLicense/Belg_FRA.txt; breaksw
          case  5:
                   set DISTILL_EULA = Distiller/EndUserLicense/Braz_POR.txt; breaksw
          case  6:
                   set DISTILL_EULA = Distiller/EndUserLicense/NA_FRA.txt;   breaksw
          case  7:
                   set DISTILL_EULA = Distiller/EndUserLicense/Chin_SIM.txt; breaksw
          case  8:
                   set DISTILL_EULA = Distiller/EndUserLicense/Chin_TRA.txt; breaksw
          case  9:
                   set DISTILL_EULA = Distiller/EndUserLicense/Denmark.txt;  breaksw
          case 10:
                   set DISTILL_EULA = Distiller/EndUserLicense/Germany.txt;  breaksw
          case 11:
                   set DISTILL_EULA = Distiller/EndUserLicense/Spain.txt;    breaksw
          case 12:
                   set DISTILL_EULA = Distiller/EndUserLicense/France.txt;   breaksw
          case 13:
                   set DISTILL_EULA = Distiller/EndUserLicense/Ireland.txt;  breaksw
          case 14:
                   set DISTILL_EULA = Distiller/EndUserLicense/Italy.txt;    breaksw
          case 15:
                   set DISTILL_EULA = Distiller/EndUserLicense/Japan.txt;    breaksw
          case 16:
                   set DISTILL_EULA = Distiller/EndUserLicense/Korea.txt;    breaksw
          case 17:
                   set DISTILL_EULA = Distiller/EndUserLicense/Luxembo.txt;  breaksw
          case 18:
                   set DISTILL_EULA = Distiller/EndUserLicense/NA_ESP.txt;   breaksw
          case 19:
                   set DISTILL_EULA = Distiller/EndUserLicense/Netherla.txt; breaksw
          case 20:
                   set DISTILL_EULA = Distiller/EndUserLicense/Norway.txt;   breaksw
          case 21:
                   set DISTILL_EULA = Distiller/EndUserLicense/Austria.txt;  breaksw
          case 22:
                   set DISTILL_EULA = Distiller/EndUserLicense/Portugal.txt; breaksw
          case 23:
                   set DISTILL_EULA = Distiller/EndUserLicense/SAfrica.txt;  breaksw
          case 24:
                   set DISTILL_EULA = Distiller/EndUserLicense/Swis_DEU.txt; breaksw
          case 25:
                   set DISTILL_EULA = Distiller/EndUserLicense/Swis_FRA.txt; breaksw
          case 26:
                   set DISTILL_EULA = Distiller/EndUserLicense/Finland.txt;  breaksw
          case 27:
                   set DISTILL_EULA = Distiller/EndUserLicense/Sweden.txt;   breaksw
          case 28:
                   set DISTILL_EULA = Distiller/EndUserLicense/Swis_ITA.txt; breaksw
          case 29:
                   set DISTILL_EULA = Distiller/EndUserLicense/UK.txt;       breaksw
          case 30:
                   set DISTILL_EULA = Distiller/EndUserLicense/AllOther.txt; breaksw
          case Q:
          case q:
                   echo "Ok. Installation cancelled."
                   goto CANCEL

          default:
                  echo ""
                  echo "*** Invalid country number."
                  echo ""
                  sleep 1
                  goto CHOOSE_COUNTRY

   endsw

   echo "Extracting End User License Agreement ..."

   mkdir $TMP_DIR >& /dev/null
   cd    $TMP_DIR
   tar xf $HERE/$TAR_FILE ./$DISTILL_EULA

   if ( -e $DISTILL_EULA ) then
      echo ""
      more $DISTILL_EULA
      echo ""
      set ANSWER = x
      while ($ANSWER != y && $ANSWER != n)
         echo -n "Do you accept the End User License Agreement (y/n)? "
         set ANSWER = $<
         check_answer
      end
      if ($ANSWER == n) then
         echo "Ok. Installation cancelled."
         goto CANCEL
      endif
   else
      echo ""
      echo "*** ERROR: Could not find the End User License Agreement ($DISTILL_EULA)."
      echo "Please contact Adobe Systems."
      echo "Installation cancelled."
      exit 1
   endif

   cd $HERE
   rm -f -r $TMP_DIR

CHOOSE_INSTALL_DIR:

   # -----------------------------------------------------------------------------
   echo ""
   echo "Please enter the full pathname to the directory where you want to install"
   echo "Acrobat Distiller, for example: /usr/shared/Adobe/Acrobat4. A sub-directory"
   echo 'named "Distiller" will be created in the install directory you specify.'
   echo "The install directory must have at least 100 MBytes of free disk space."
   echo "Please choose a pathname that is accessible from all the computers that"
   echo "need to run Acrobat Distiller. Do not specify a pathname longer than"
   echo "200 characters. The pathname must not contain embedded spaces."
   echo ""
   set ANSWER = ""
   while ("$ANSWER" == "")
      echo -n "Install directory: "
      set ANSWER = $<
   end

   set INSTALL_DIR = $ANSWER

   echo $INSTALL_DIR > /tmp/Distill-install-dir

   if (`wc -c < /tmp/Distill-install-dir` > 201) then
      echo ""
      echo "*** The pathname is too long. The limit is 200 characters."
      sleep 1
      goto CHOOSE_INSTALL_DIR
   endif
   rm -f /tmp/Distill-install-dir

   # -----------------------------------------------------------------------------
   if (! -d $INSTALL_DIR) then
      echo ""
      set ANSWER = x
      while ($ANSWER != y && $ANSWER != n)
         echo -n "$INSTALL_DIR does not exist. Create it (y/n)? "
         set ANSWER = $<
         check_answer
      end
      if ($ANSWER == n) then
         echo "Ok. Installation cancelled."
         goto CANCEL
      endif
      mkdir -p $INSTALL_DIR
      set REMOVE_INSTALL_DIR = 1
   endif

endif

# -----------------------------------------------------------------------------
echo ""
echo "Distiller will be installed in $INSTALL_DIR/Distiller"
echo ""

if ($FORCE == 1) then
   mkdir -p $INSTALL_DIR >& /dev/null
   if (-e $INSTALL_DIR/Distiller) then
      echo "All files in $INSTALL_DIR/Distiller will be overwritten."
      echo ""
      echo "You have 5 seconds to abort with cntrl-C ..."
      sleep 5
      echo "Removing $INSTALL_DIR/Distiller ..."
      sleep 1
      rm -f -r $INSTALL_DIR/Distiller
      echo ""
   endif
else
   set ANSWER = x
   while ($ANSWER != y && $ANSWER != n)
      echo -n "Continue (y/n)? "
      set ANSWER = $<
      check_answer
   end
   if ($ANSWER == n) then
      echo "Ok. Installation cancelled."
      if ($REMOVE_INSTALL_DIR == 1) then
         echo "Removing $INSTALL_DIR ..."
         sleep 1
         rm -f -r $INSTALL_DIR
      endif
      goto CANCEL
   endif
endif

# -----------------------------------------------------------------------------
mkdir $INSTALL_DIR/tmp.tmp.$$ >& /dev/null

if ($status != 0) then
   echo ""
   echo "*** ERROR: Could not create directories in $INSTALL_DIR"
   echo "Please check the permissions of the install directory, then try again."
   echo "Installation cancelled."
   exit 1
endif

rmdir $INSTALL_DIR/tmp.tmp.$$

# -----------------------------------------------------------------------------
if (-e $INSTALL_DIR/Distiller) then

   if ($FORCE == 1) then
      echo "*** INTERNAL ERROR 1 ***"
      echo "Please contact Adobe Systems."
      echo "Installation cancelled."
      exit 1
   endif

   echo ""
   echo "$INSTALL_DIR/Distiller already exists."
   echo ""
   echo "Do you want to override it or save it to $INSTALL_DIR/Distiller.BAK?"
   echo ""

   while (1)
      echo -n 'Type "s" to save, "o" to override, or "c" to cancel: '
      set ANSWER = $<
      if ( ($ANSWER == s) || ($ANSWER == S) ) then
         set SAVE_IT = 1
         goto DECIDED
      else if ( ($ANSWER == o) || ($ANSWER == O) ) then
         set SAVE_IT = 0
         goto DECIDED
      else if ( ($ANSWER == c) || ($ANSWER == C) ) then
         echo "Ok. Installation cancelled."
         goto CANCEL
      endif
   end

DECIDED:

   if ($SAVE_IT == 0) then
      echo ""
      echo "$INSTALL_DIR/Distiller will be overwritten."
      echo ""
      set ANSWER = x
      while ($ANSWER != y && $ANSWER != n)
         echo -n "Continue (y/n)? "
         set ANSWER = $<
         check_answer
      end
      if ($ANSWER == n) then
         echo "Ok. Installation cancelled."
         goto CANCEL
      endif
   endif

   if ($SAVE_IT == 1) then
      if (-e $INSTALL_DIR/Distiller.BAK) then
         echo ""
         set ANSWER = x
         while ($ANSWER != y && $ANSWER != n)
            echo -n "$INSTALL_DIR/Distiller.BAK already exists. Overwrite it (y/n)? "
            set ANSWER = $<
            check_answer
         end
         if ($ANSWER == n) then
            echo "Ok. Installation cancelled."
            goto CANCEL
         endif
         echo "Removing $INSTALL_DIR/Distiller.BAK ..."
         sleep 1
         rm -f -r $INSTALL_DIR/Distiller.BAK
      endif

      echo "Saving $INSTALL_DIR/Distiller to $INSTALL_DIR/Distiller.BAK ..."
      set REMOVE_UNFINISHED = 1
      sleep 1
      mv $INSTALL_DIR/Distiller $INSTALL_DIR/Distiller.BAK
   else
      echo "Removing $INSTALL_DIR/Distiller ..."
      set REMOVE_UNFINISHED = 1
      sleep 1
      rm -f -r $INSTALL_DIR/Distiller
   endif
endif

# ----------------------- #
# Do the installation now #
# ----------------------- #

# -----------------------------------------------------------------------------
echo "Installing Distiller in $INSTALL_DIR/Distiller ..."
set REMOVE_UNFINISHED = 1
sleep 2

cd $INSTALL_DIR

tar xvf $HERE/$TAR_FILE ./Distiller

if ( ! -d $INSTALL_DIR/Distiller) then
   echo "*** INTERNAL ERROR 2 ***"
   echo "Please contact Adobe Systems."
   echo "Installation cancelled."
   exit 1
endif

# ------------------------ #
# Create the launch script #
# ------------------------ #

cd $INSTALL_DIR/Distiller

@ PLATFORM_NUM = 1

foreach PLATFORM ($PLATFORMS)

   sed -e "s#M_ACRO_INSTALL_DIR#$INSTALL_DIR#g"              \
       -e "s#M_ACRO_CONFIG#$PLATFORM#g"                      \
       -e "s#M_LIB_PATH_VAR#LD_LIBRARY_PATH#g"               \
       -e "s#M_X_LIBS_PATH#${X_LIBS_PATHS[$PLATFORM_NUM]}#g" \
       MasterScript > $PLATFORM/distill

   if ($NO_CJK == 1) then
      sed -e 's#:${RES_D1}:${RES_D2}:${RES_D3}:${RES_D4}:#:${RES_D1}:#g' \
      $PLATFORM/distill | grep -v "psdisk" > tmp.tmp
      mv tmp.tmp $PLATFORM/distill
   endif

   chmod a+x $PLATFORM/distill

   @ PLATFORM_NUM = $PLATFORM_NUM + 1
end

rm MasterScript

if ($NO_CJK == 1) then
   echo ""
   echo "Removing CJK support (CSL library) ..."
   rm -f -r $INSTALL_DIR/Distiller/Data/psdisk
   echo ""
endif

echo "Done."

# --------------------------- #
# Get serial number from user #
# --------------------------- #

SERIAL_NUMBER:

if ($FORCE == 0) then
   echo ""
   set SERIAL_NUMBER = ""
   while ("$SERIAL_NUMBER" == "")
      echo -n "Enter your Distiller Serial Number: "
      set SERIAL_NUMBER = $<
   end
endif

echo $SERIAL_NUMBER > $INSTALL_DIR/Distiller/SERIAL_NUMBER

if ($MY_PLATFORM != "none") then

   # ----------------------- #
   # Verify the installation #
   # ----------------------- #

   echo ""
   echo "Verifying installation ... "
   echo ""
   sleep 1

   set TEST_LOG = /tmp/Distill-test.log

   cd $INSTALL_DIR/Distiller

   # ------------------------------------------------- #
   # First test: Make sure all directories are present #
   # ------------------------------------------------- #

   set sub_dirs_missing = 0
      
   if ( ( ! -d Data)                      || \
        ( ! -e Data/Distinit.ps)          || \
        ( ! -e Data/Epilogue.ps)          || \
        ( ! -e Data/HelloWorld.ps)        || \
        ( ! -e Data/Prologue.ps)          || \
        ( ! -d EndUserLicense)            || \
        ( ! -d Fonts)                     || \
        ( ! -d ICCProfiles)               || \
        ( ! -d Settings)                  || \
        ( ! -d Startup)                   || \
        ( ! -e Startup/StartupExample.ps) || \
        ( ! -d ToUnicode)                 ) then
      set sub_dirs_missing = 1
   endif

   if ( ($NO_CJK == 0) && ( ! -d Data/psdisk ) ) then
      set sub_dirs_missing = 1
   endif

   foreach PLATFORM ($PLATFORMS)
      if ( ( ! -d $PLATFORM)     || \
           ( ! -d $PLATFORM/bin) || \
           ( ! -d $PLATFORM/lib) ) then
         set sub_dirs_missing = 1
      endif
   end
      
   if ($sub_dirs_missing == 1) then
      echo '*** ERROR: One of the subdirectories in the "Distiller" release directory is missing.'
      echo "Please contact Adobe Systems."
      echo "Installation cancelled."
      exit 1
   endif

   # --------------------------- #
   # Second test: distill -usage #
   # --------------------------- #

   cd $INSTALL_DIR
   echo -n 'Running simple test: "distill -usage" ... '
   sleep 1
   (Distiller/$MY_PLATFORM/distill -usage) >& $TEST_LOG

   grep "complete manpage" $TEST_LOG >& /dev/null

   if ($status == 0) then

      echo "Done."
      echo ""

      # --------------------------------- #
      # Third test: distill HelloWorld.ps #
      # --------------------------------- #
   
      echo -n "Distilling HelloWorld.ps ... "

      (Distiller/$MY_PLATFORM/distill -verbose Distiller/Data/HelloWorld.ps /tmp) >& $TEST_LOG
   
      if ($status == 0) then
         set success = -2
         if ($NO_CJK == 1) then
            grep "Optimizing PDF file" $TEST_LOG >& /dev/null
            if ($status == 0) set success = 1
         else
            grep "CID support library initialization completed" $TEST_LOG >& /dev/null
            if ($status == 0) set success = 1
         endif
         if ($success == 1) then
            echo "Done."
            echo ""
            rm -f $TEST_LOG
            rm -f /tmp/HelloWorld.pdf
         else
            echo "Failed."
            echo ""
         endif
      else
         echo "Failed."
         echo ""
         set success = -2
      endif

   else
      # --------------------------------------------------- #
      # Check if failure is caused by invalid serial number #
      # --------------------------------------------------- #

      grep "SERIAL_NUMBER" $TEST_LOG >& /dev/null

      if ($status == 0) then
         echo "Failed."
         echo ""
         if ($FORCE == 1) then
            echo "You did not enter a valid serial number."
            echo ""
            echo "Installation cancelled."
            echo ""
            echo "To remove the unfinished installation type this command:"
            echo ""
            echo "/bin/rm -f -r $INSTALL_DIR/Distiller"
            echo ""
            exit 0
         else
            echo "You did not enter a valid serial number."
            goto SERIAL_NUMBER
         endif
      endif
      set success = -1
   endif
else
   set success = 1
endif

# ------------------------------------------------------------ #
# Remove unwanted platforms (happens only when -force is used) #
# ------------------------------------------------------------ #

if ($INSTALL_SPARCSOLARIS == 0) then
   echo "Removing support for sparcsolaris ..."
   rm -f -r $INSTALL_DIR/Distiller/sparcsolaris
endif

if ($INSTALL_PENTIUMLINUX == 0) then
   echo "Removing support for pentiumlinux ..."
   rm -f -r $INSTALL_DIR/Distiller/pentiumlinux
endif

echo ""

if ($success == 1) then
   sleep 1
   echo 'Congratulations\!'
   echo ""
   echo "The installation of Acrobat Distiller for Unix was successful."
   echo ""
   echo ""
   foreach PLATFORM ($PLATFORMS)
      sleep 1

      if ( ( ($INSTALL_SPARCSOLARIS == 1) && ($PLATFORM == sparcsolaris) ) || \
           ( ($INSTALL_PENTIUMLINUX == 1) && ($PLATFORM == pentiumlinux) )    \
         ) then

         echo "To launch Distiller on $PLATFORM"
         echo "-----------------------------------"
         echo ""
         echo "   Prepend this directory to your search path:"
         echo ""
         echo "   $INSTALL_DIR/Distiller/$PLATFORM"
         echo ""
         echo '   Then type "distill -usage" to launch Distiller.'
         echo ""
         echo ""

      endif

   end
   if ($MY_PLATFORM == "none") then
      sleep 1
      echo "Please notice: You were running this installation script on an"
      echo "unsupported platform. To do the final test and verification of"
      echo "the installation please login to a computer running one of the"
      echo "supported operating systems and make sure that the distiller"
      echo "launch script is in your search path. Then type this command:"
      echo ""
      echo "distill -verbose < $INSTALL_DIR/Distiller/Data/HelloWorld.ps > /tmp/HelloWorld.pdf"
      echo ""
      echo "When the distillation has completed, inspect /tmp/HelloWorld.pdf with"
      echo 'Acrobat Reader and verify that it contains the text: "Hello World".'
      echo ""
   endif
else if ($success == -1) then
   echo ""
   echo "Sorry. The installation of Acrobat Distiller for Unix was not successful."
   echo "The final verification of the launch script failed. The following command"
   echo "was attempted, but failed:"
   echo ""
   echo '"distill -usage"'
   echo ""
   echo "Please contact Adobe Systems for support and send the"
   echo "content of the logfile: $TEST_LOG"
   echo ""
else
   echo ""
   echo "Sorry. The installation of Acrobat Distiller for Unix was not successful."
   echo "The final verification of the launch script failed. The following command"
   echo "was attempted, but failed:"
   echo ""
   echo '"distill -verbose < Data/HelloWorld.ps > /tmp/HelloWorld.pdf"'
   echo ""
   echo "Please contact Adobe Systems for support and send the"
   echo "content of the logfile: $TEST_LOG"
   echo ""
endif

sleep 1
echo "To uninstall Distiller"
echo "----------------------"
echo ""
echo "   Type this command:"
echo ""
echo "   /bin/rm -f -r $INSTALL_DIR/Distiller"
echo ""

DONE:
   goto REMOVE_TARFILE

CLEAN_UP:

   echo ""
   echo "Received interrupt, cleaning up ..."

CANCEL:

   cd /
   rm -f -r $TMP_DIR >& /dev/null

   if ( ($REMOVE_UNFINISHED == 1) && (-e $INSTALL_DIR/Distiller) ) then
      set ANSWER = x
      while ($ANSWER != y && $ANSWER != n)
         echo -n "Do you want to remove the unfinished installation in $INSTALL_DIR/Distiller (y/n)? "
         set ANSWER = $<
         check_answer
      end
      if ($ANSWER == y) then
         echo "Removing $INSTALL_DIR/Distiller ..."
         sleep 1
         rm -f -r $INSTALL_DIR/Distiller
         if ($REMOVE_INSTALL_DIR == 1) then
            echo "Removing $INSTALL_DIR ..."
            sleep 1
            rm -f -r $INSTALL_DIR
         endif
      else
         echo ""
         echo "Ok. To remove the unfinished installation type this command:"
         echo ""
         if ($REMOVE_INSTALL_DIR == 1) then
            echo "/bin/rm -f -r $INSTALL_DIR"
         else
            echo "/bin/rm -f -r $INSTALL_DIR/Distiller"
         endif
      endif
      echo ""
   endif

REMOVE_TARFILE:

   if ($FORCE == 1) then
      echo ""
      echo "Remember to remove the tar file: $TAR_FILE"
      echo "and the install script: Distiller.install"
      goto REALLY_DONE
   endif

   set ANSWER = x
   while ($ANSWER != y && $ANSWER != n)
      echo -n "Do you want to remove the tar file: $TAR_FILE (y/n)? "
      set ANSWER = $<
      check_answer
   end
   if ($ANSWER == y) then
      if (-e $HERE/$TAR_FILE) then
         echo ""
         echo "Removing $TAR_FILE ..."
         sleep 1
         rm -f $HERE/$TAR_FILE
         echo ""
      else
         echo '*** ERROR: Could not find $HERE/$TAR_FILE'
         exit 1
      endif
   endif

   set ANSWER = x
   while ($ANSWER != y && $ANSWER != n)
      echo -n "Do you want to remove the install script: Distiller.install (y/n)? "
      set ANSWER = $<
      check_answer
   end
   if ($ANSWER == y) then
      if (-e $HERE/Distiller.install) then
         echo ""
         echo "Removing Distiller.install ..."
         sleep 1
         rm -f $HERE/Distiller.install
      else
         echo '*** ERROR: Could not find $HERE/Distiller.install'
         exit 1
      endif
   endif

REALLY_DONE:

   echo ""
   echo "Done."

   exit 0

# === End of Distiller.install

