####################################################
WEBESVER=500;export WEBESVER
#

# These are used to restore existing startup symlinks
DESTA_SYMLINK="false"
CCAT_SYMLINK="false"

find_startup_symlinks()
{
 if [ -f /etc/rc.d/rc3.d/*desta ]; then
    TEMP="`/bin/ls /etc/rc.d/rc3.d/*desta`"
    [ -n "$TEMP" ] && DESTA_SYMLINK="true"
 fi

 if [ -f /etc/rc.d/rc3.d/*ccat ]; then
    TEMP="`/bin/ls /etc/rc.d/rc3.d/*ccat`"
    [ -n "$TEMP" ] && CCAT_SYMLINK="true"
 fi
}


restore_startup_symlinks()
{
  OldDir=`/bin/pwd`
  if [ "$DESTA_SYMLINK" = true ]; then
     cd /etc/rc.d/rc2.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc3.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc4.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc5.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     
     cd /etc/rc.d/rc0.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
     cd /etc/rc.d/rc1.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
     cd /etc/rc.d/rc6.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
  fi
  if [ "$CCAT_SYMLINK" = true ]; then
     cd /etc/rc.d/rc3.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/wccat_startup ./S99wccat
  fi
  cd $OldDir
}


get_all_installed_WEBES_products()
{
    get_already_installed_product WEBES_INSTALLED ""; export WEBES_INSTALLED
    get_already_installed_product CA_INSTALLED ""; export CA_INSTALLED
    get_already_installed_product CCAT_INSTALLED ""; export CCAT_INSTALLED
}

sed_temp1_registry()
 {
   if [ -f $1 ]; then
      ARGS=$#
      /bin/sed "s/$2.*$//g" $1 | /bin/grep -v '^ *$' > ./tempfile
      /bin/mv ./tempfile $1
      if [ $ARGS -eq 3 ]; then
        /bin/echo "$2$3" >> $1
      fi
   fi
 }


nodeSpecificStuff()
{
 if [ -n "$CA_INSTALLED" -o -n "$CCAT_INSTALLED" ]; then


### VIJAYANT-- For upgrade changes(Jim's mail)
 
    desta exec com.compaq.svctools.desta.services.managedentities.LoadManagedEntities

### VIJAYANT-- For upgrade changes(Jim's mail) 

### Fix for bug 3778 - start
	desta exec com.compaq.svctools.desta.configuration.ConfigUtil -chgconf com.compaq.svctools.desta.services.hsqldb.ManageHsqldb 4 false b
     ### Fix for bug 3778 -end

    echo "Restarting Director on $FULL_HOSTNAME..."
    desta_process_start EXIT_CODE
    if [ "$EXIT_CODE" -ne 0 ]; then
       echo "Could not start Director on $FULL_HOSTNAME."
       exit 350
    fi
    echo "Waiting 60 seconds for Director to finish startup tasks..."
    /bin/sleep 60
 fi
}

get_already_installed_product()
{
# get the installed version of WEBES and SEA/CA 

   if [ "$1" = "WEBES_INSTALLED" ]; then
       INSTALLED_PRODUCT="` rpm -qa| grep ^WEBESBASE 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 `"
   elif [ "$1" = "CCAT_INSTALLED" ]; then
   	INSTALLED_PRODUCT="`rpm -qa|grep ^WEBESCCAT 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5`"
   elif [ "$1" = "CA_INSTALLED" ]; then
   	INSTALLED_PRODUCT="` rpm -qa | grep ^WEBESSEA 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5`"
   fi

   eval $1=${INSTALLED_PRODUCT}
}


uninstall_webes()
{

  # Find any symlinks in the system startup directories
  find_startup_symlinks


 if [ -f ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG ];then
      NOTIFICATION_FLAG=`/bin/grep "notification.Queried" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      export NOTIFICATION_FLAG
      NOTIFICATION_FLAG="YES"
      NOTIFICATION_TYPE=`/bin/grep "notification.Type" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      export NOTIFICATION_TYPE
      WEBES_CFGSTATE=`/bin/grep "webes.CfgState" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /usr/bin/cut -f 2 -d=`
      export WEBES_CFGSTATE
      KIT_PATH=`/bin/grep "kit.path" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /usr/bin/cut -f 2 -d=`
      export KIT_PATH
  fi


  filename="${SVCTOOLS_HOME}/common/desta/config/CommonFiles/SystemState"
  if [ -f $filename ]; then
      stringname=ca.configure
      GR_ITEM=""
      GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
      if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
      fi
      if [ "$GR_ITEM" = "CONFIGURED" ]; then
	 if [ -f "${SVCTOOLS_HOME}/common/ca/config/ACHSInfo" ]; then
	    /bin/cp ${SVCTOOLS_HOME}/common/ca/config/ACHSInfo ${SVCTOOLS_HOME}
         fi
	 ENABLE_DESTA=1
	    if [ ! -e $SVCTOOLS_HOME/specific/ca/save ]; then
	       /bin/mkdir -p $SVCTOOLS_HOME/specific/ca/save
	    fi
            
            /bin/touch $SVCTOOLS_HOME/specific/ca/save/ca_configured
	    
            if [ -f ${SVCTOOLS_HOME}/specific/desta/config/NotifyCA.txt ];then
	     /bin/cp ${SVCTOOLS_HOME}/specific/desta/config/NotifyCA.txt ${SVCTOOLS_HOME}/specific/ca/save
	    fi
     fi
       stringname=ccat.configure
       GR_ITEM=""
       GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
       if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
       fi
       if [ "$GR_ITEM" = "CONFIGURED" ]; then
	  ENABLE_DESTA=1
	     if [ ! -e $SVCTOOLS_HOME/specific/ccat/save ]; then
	        /bin/mkdir -p $SVCTOOLS_HOME/specific/ccat/save
	     fi

             /bin/touch ${SVCTOOLS_HOME}/specific/ccat/save/ccat_configured

	     if [ -f ${SVCTOOLS_HOME}/specific/desta/config/CCATNotify.txt ]; then
	       /bin/cp ${SVCTOOLS_HOME}/specific/desta/config/CCATNotify.txt ${SVCTOOLS_HOME}/specific/ccat/save
	     fi
       fi
        
        stringname=system.state
        GR_ITEM=""
        GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
        if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
        fi
        if [ "$GR_ITEM" = "CONFIGURED" ]; then
            if [ ! -e ${SVCTOOLS_HOME}/specific/desta/userdata ]; then
               /bin/mkdir -p ${SVCTOOLS_HOME}/specific/desta/userdata
            fi
              
            /bin/touch ${SVCTOOLS_HOME}/specific/desta/userdata/desta_configured
              
            COP_FILE="profile.txt DESTA.REG Configuration.dat"
            for FILE in ${COP_FILE}; do
	        if [ -f  $SVCTOOLS_HOME/specific/desta/config/$FILE ]; then
	          /bin/cp $SVCTOOLS_HOME/specific/desta/config/$FILE $SVCTOOLS_HOME/specific/desta/userdata
                  /bin/cp $SVCTOOLS_HOME/specific/desta/config/$FILE $SVCTOOLS_HOME/specific/desta/userdata
                 fi
            done

            if [ -f  $SVCTOOLS_HOME/specific/desta/data/entities.dat ]; then
                  /bin/cp $SVCTOOLS_HOME/specific/desta/data/entities.dat $SVCTOOLS_HOME/specific/desta/userdata
 
            fi 
	      
            if [ -f $SVCTOOLS_HOME/specific/desta/data/Obligation ]; then
              /bin/cp $SVCTOOLS_HOME/specific/desta/data/Obligation $SVCTOOLS_HOME/specific/desta/userdata

            fi


### VIJAYANT-- For upgrade changes (Jim's mail) 

          if [ -f $SVCTOOLS_HOME/specific/desta/data/me.script ]; then
                /bin/cp $SVCTOOLS_HOME/specific/desta/data/me.script $SVCTOOLS_HOME/specific/desta/userdata
          fi

          if [ -f $SVCTOOLS_HOME/specific/desta/data/me.properties ]; then
                /bin/cp $SVCTOOLS_HOME/specific/desta/data/me.properties $SVCTOOLS_HOME/specific/desta/userdata
          fi

       #   if [ -f $SVCTOOLS_HOME/specific/desta/data/managedentities/*.xml ]; then
           #     /bin/cp -r $SVCTOOLS_HOME/specific/desta/data/managedentities/*.xml $SVCTOOLS_HOME/specific/desta/userdata
        #  fi

        XMLFILES=`/bin/ls $SVCTOOLS_HOME/specific/desta/data/managedentities/`

        for XML in $XMLFILES; do

                /bin/cp $SVCTOOLS_HOME/specific/desta/data/managedentities/$XML $SVCTOOLS_HOME/specific/desta/userdata
        done


        fi
   fi



  userInfo_filename="${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation"

  if [ -f $userInfo_filename ]; then
     if [ ! -e $SVCTOOLS_HOME ]; then
        /bin/mkdir -p $SVCTOOLS_HOME
     fi

     if [ -f "${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation" ]; then
        /bin/cp ${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation ${SVCTOOLS_HOME}
     fi
  fi


/bin/echo ""
/bin/echo " WEBESBASE${UNINSTALL_VER} will be uninstalled "
/bin/echo ""
 
  get_all_installed_WEBES_products

####  if [ "$CA_INSTALLED" = "442" -o "$CA_INSTALLED" = "443" ]; then

     if [ "$CA_INSTALLED" = "450" -o "$CA_INSTALLED" = "451"  ]; then	

      UNINSTALL_CAVER=`echo $CA_INSTALLED  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
      UNINSTALL_ANY_CA=WEBESSEA-$UNINSTALL_CAVER
   fi

#Fix for Upgrade support for 4.4.2 over 4.4.0 and 4.4.1

####Fix for Upgrade support for 5.0 over 4.4.3 and 4.5

#   if [ "$CCAT_INSTALLED" = "511" -o "$CCAT_INSTALLED" = "512" ]; then
    if [ "$CCAT_INSTALLED" = "512" -o "$CCAT_INSTALLED" = "520" ]; then
      UNINSTALL_CCATVER=`echo $CCAT_INSTALLED  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
      UNINSTALL_ANY_CCAT=WEBESCCAT-$UNINSTALL_CCATVER
   fi

   if [ -n "$UNINSTALL_ANY_CCAT" ];then
         rpm -e $UNINSTALL_ANY_CCAT
         # Fix for PTR 91-22-1868
           if [ -e ${SVCTOOLS_HOME}/specific/ccat/data ]; then
              /bin/rm -rf $SVCTOOLS_HOME/specific/ccat/data
	   fi 
         # Fix for PTR 91-22-1868
   fi
   if [ -n "$UNINSTALL_ANY_CA" ];then
        rpm -e $UNINSTALL_ANY_CA
        # Fix for PTR 91-22-1868
          if [ -e ${SVCTOOLS_HOME}/specific/ca/data ]; then
             /bin/rm -rf $SVCTOOLS_HOME/specific/ca/data
	  fi 
        # Fix for PTR 91-22-1868
   fi

    rpm -e WEBESBASE-${UNINSTALL_VER}

   if [ $? != 0 ]; then
         SVCTOOLS_HOME=/usr/opt/hp/svctools           
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ca/save/NotifyCA.txt
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ccat/save/CCATNotify.txt
         /bin/rm -f ${SVCTOOLS_HOME}/specific/desta/userdata/Obligation
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ca/save/ca_configured
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ccat/save/ccat_configured
         /bin/rm -f ${SVCTOOLS_HOME}/specific/desta/userdata/desta_configured
	 /bin/rm -f $SVCTOOLS_HOME/specific/desta/userdata/Configuration.dat
         /bin/rm -f $SVCTOOLS_HOME/specific/desta/userdata/entities.dat
	 /bin/rm -rf ${SVCTOOLS_HOME}/specific/ca/save/auto
         /bin/rm -f ${SVCTOOLS_HOME}/UserInformation
      exit 1
   fi    
SVCTOOLS_HOME=/usr/opt/hp/svctools
}

check_if_WEBES_installed()
{
   INSTALLED=""
   INSTALLEDVER=""
   INSTALLEDDOTVER=""
   INSTALLED_PKG=`rpm -qa|grep ^WEBESBASE `
   
  if [ "$INSTALLED_PKG" != "" ]; then
      INSTALLED="true"
      INSTALLEDVER="`echo ${INSTALLED_PKG} 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 `"
      INSTALLEDDOTVER="`echo ${INSTALLED_PKG} 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 | /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/p'`"
      UNINSTALL_VER=`echo ${INSTALLEDVER}  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
fi

   if [ -n "${INSTALLED}" ]; then
      if [ "${INSTALLEDVER}" -eq "${WEBESVER}" ]; then
	  /bin/cat <<EOF
This procedure can be used to install/upgrade WEBES (${INSTALLEDDOTVER}). But
Web-Based Enterprise Service Suite (${INSTALLEDDOTVER}) is already installed.
Please use webes_install_update or rpm command directly to reinstall/uninstall
any optional subset of WEBES ${INSTALLEDDOTVER}.
EOF
	exit 0
      fi
      if [ "${INSTALLEDVER}" -lt "${WEBESVER}" ]; then
####    if [ "${INSTALLEDVER}" -eq  "442" -o "${INSTALLEDVER}" -eq "443" ]; then
	if [ "${INSTALLEDVER}" -eq  "450" -o "${INSTALLEDVER}" -eq "451" ]; then
	   /bin/cat << EOF

Webes V${INSTALLEDVER} is currently installed.

This script will deinstall V${INSTALLEDVER} and migrate its configuration data
to the V4.5 installation.

EOF
           echo -ne "Do you wish to upgrade to WEBES V5.0.0 (y/n) ? \c"
           read input
           if [ "$input" = "" ]; then
              uninstall_webes
           elif [ ! -z "$input" ]; then
              input=`echo $input | tr [A-Z]  [a-z]`
              if [ "$input" = "yes" -o "$input" = "y" ]; then
                uninstall_webes
              else
                exit 0
              fi
           fi
        else
	/bin/cat <<EOF
An older version of the Web-Based Enterprise Service Suite (${INSTALLEDDOTVER})
is currently installed. That version must be deinstalled before 
this procedure can be executed.
Please use "webes_install_update" config tool  or the "rpm" command directly to uninstall WEBES.
EOF
                exit 1
        fi
      fi
      if [ -n "${INSTALLEDVER}" ]; then
        if [ "${INSTALLEDVER}" -eq "450" -o "${INSTALLEDVER}" -eq "451" ]; then
           echo " "
        else
	        /bin/cat <<EOF
A newer version of the Web-Based Enterprise Service Suite (${INSTALLEDDOTVER})
is currently installed. That version must be deinstalled before 
this procedure can be executed.
EOF
	        exit 1
        fi
      fi
  fi
}


###########################################################################
# Start of script execution

SVCTOOLS_HOME="/usr/opt/hp/svctools"
#WEBES_UPDATE_HOME=`pwd`
WEBES_UPDATE_HOME="."
THROUGH_SCRIPT=1
DESTA_CLI="/usr/sbin/desta"
REGISTRY_HOME="${SVCTOOLS_HOME}"/specific/desta/config

get_all_installed_WEBES_products

if [ -n "$WEBES_INSTALLED" ]; then
    NEW_WEBES="WEBESBASE-5.0-0.i386.rpm"
fi
if [ -n "$CA_INSTALLED" ]; then
    NEW_CA="WEBESSEA-5.0-0.i386.rpm"
fi
if [ -n "$CCAT_INSTALLED" ]; then
    NEW_CCAT="WEBESCCAT-5.3-0.i386.rpm"
fi

check_if_WEBES_installed

## choose from installing the proxy through the Wrapper script or including the wrapper script functions for 
## uninstalling and installing the proxy in this file. Remove lines  293 & 457 if u choose to do the former 
## and unhash line 6 and 432. Wccproxy and WEBES have extracted out their proxy verification and installation 
## in the install.sh and WEBESWrapper.sh scripts. 
${WEBES_UPDATE_HOME}/WEBESWrapper.sh

if [ -n "$CA_INSTALLED" ]; then
     rpm -ih $NEW_CA
fi

if [ -n "$CCAT_INSTALLED" ]; then
     rpm -ih $NEW_CCAT
fi

restore_startup_symlinks

 if [ -f $SVCTOOLS_HOME/common/install/wcc_install_500.sh ]; then
    . $SVCTOOLS_HOME/common/install/wcc_install_500.sh
 else
    echo "could not find the required file"
    exit 0
 fi

if [ "$ENABLE_DESTA" = "1" ]; then
   /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta /usr/sbin/desta
    
     get_hostnames
       if [ -f $SVCTOOLS_HOME/specific/desta/userdata/DESTA.REG ]; then
          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG webes.startOnBoot
	  if [ "$GR_ITEM" != "" ]; then
             sed_temp_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG webes.startOnBoot "$GR_ITEM"
	  fi

          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG desta.QSAPport
	  if [ "$GR_ITEM" != "" ]; then
             sed_temp_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG desta.QSAPport "$GR_ITEM"
	  fi

          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG desta.QSAP=
	  if [ "$GR_ITEM" != "" ]; then
	     sed_temp1_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG desta.QSAP= "$GR_ITEM"
	  fi
	  rm -f $SVCTOOLS_HOME/specific/desta/userdata/DESTA.REG
     fi




### For upgrade changes(Jim's mail) -Vijayant

   	if [ -f $SVCTOOLS_HOME/specific/desta/userdata/me.script ]; then
	/bin/cp -r $SVCTOOLS_HOME/specific/desta/userdata/me.script $SVCTOOLS_HOME/specific/desta/save

	fi

	if [ -f $SVCTOOLS_HOME/specific/desta/userdata/me.properties ]; then
	/bin/cp -r $SVCTOOLS_HOME/specific/desta/userdata/me.properties $SVCTOOLS_HOME/specific/desta/save
    	
	fi

  	
        XMLFILES=`/bin/ls $SVCTOOLS_HOME/specific/desta/userdata/*.xml`
        for XML in $XMLFILES; do

                /bin/cp $XML $SVCTOOLS_HOME/specific/desta/save/managedentities
        done

        rm -f $SVCTOOLS_HOME/specific/desta/userdata/*.xml
	rm -f $SVCTOOLS_HOME/specific/desta/userdata/me.properties
	rm -f $SVCTOOLS_HOME/specific/desta/userdata/me.script
    
    get_registry_item notification.Type; TYPE="$GR_ITEM"
   
    QSAP_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "QSAP"`
    ISEE_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "ISEE"`
    ACHS_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "ACHS"`
    
    get_supported_ISEE
    
#    /bin/echo "Please Note:"
#    /bin/echo ""

#    if [ -z "$ISEE_INSTALLED" -a -n "$QSAP_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "OSEM will continue to be supported, but it does not send notifications to HP customer support."
#        /bin/echo "To install ISEE, please contact your local field representative or visit the ISEE page at:"
#        /bin/echo "http://www.hp.com/hps/hardware/hw_enterprise.html"
#        /bin/echo "Click on the link \"Download ISEE\"." 
#        /bin/echo ""
#        /bin/echo "With the ISEE Client installed, you can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta qsap off"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with PRS or OSEM notification enabled."
#        /bin/echo ""
#    fi
   
#    if [ -z "$ISEE_INSTALLED" -a -n "$ACHS_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. To install ISEE, please contact your local field representative "
#        /bin/echo "or visit the ISEE page at:"
#        /bin/echo "http://www.hp.com/hps/hardware/hw_enterprise.html"
#	 /bin/echo "Click on the link \"Download ISEE\"." 
#        /bin/echo ""
#        /bin/echo "With the ISEE Client installed, you can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta sicl off"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#    fi
 
#    if [ -n "$ISEE_INSTALLED" -a -n "$QSAP_NOTIFY" -a -z "$ISEE_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "OSEM will continue to be supported, but it does not send notifications to HP customer support."

    if [ -n "$ISEE_INSTALLED" -a -z "$ISEE_NOTIFY" ]; then
        /bin/echo "The ISEE Client program is currently installed on your system. "
        /bin/echo "WEBES is now configured to send notifications to ISEE."
#        /bin/echo ""
	TYPE="$TYPE ISEE"
#       sed_registry_file notification.Type "$TYPE"
	output=`desta isee on nodir`
	
    fi

#	/bin/echo "You can issue the following "
#       /bin/echo "command to enable WEBES to issue notifications via ISEE:"
#       /bin/echo "desta isee on"
#       /bin/echo ""
#       /bin/echo "If you are currently using PRS rather than OSEM, you should then disable use of PRS to prevent "
#       /bin/echo "duplicate notifications from both PRS and ISEE, with the command:"
#       /bin/echo "desta qsap off"
#       /bin/echo "Disabling is not necessary if you are using OSEM instead of PRS, since OSEM does not send "
#       /bin/echo "notifications to HP customer support."
#       /bin/echo ""
#       /bin/echo "Continuing WEBES upgrade with PRS or OSEM notification enabled."



#    if [ -n "$ISEE_INSTALLED" -a -n "$ACHS_NOTIFY" -a -z "$ISEE_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. OSEM will continue to be supported, but it does not send "
#        /bin/echo "notifications to HP customer support. The ISEE Client program is currently installed on "
#        /bin/echo "your system. You can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#     fi

#     if [ -n "$ISEE_NOTIFY" -a -n "$QSAP_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "ISEE notification is currently enabled, which should NOT be possible."
#        /bin/echo "Please contact WEBES customer support."
#        /bin/echo "Continuing WEBES upgrade with both PRS/OSEM and ISEE notifications enabled."
#        /bin/echo ""
#     fi

#     if [ -n "$ISEE_NOTIFY" -a -n "$ACHS_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. OSEM will continue to be supported, but it does not send "
#        /bin/echo "notifications to HP customer support. The ISEE Client program is currently installed and "
#        /bin/echo "enabled for WEBES notifications on your system. You can issue the following command to "
#        /bin/echo "turn off SICL DSNlink notification:"
#        /bin/echo "desta sicl off"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#     fi
   
    get_all_installed_products

      ${SVCTOOLS_HOME}/common/bin/desta servob installationUpdate

#    if [ "${INSTALLEDVER}" -eq "434" ]; then
     # Fix for PTR 91-22-1719
#       ${DESTA_PATH} exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsDESTA.txt > /dev/null 2>&1
     # Fix for PTR 91-22-1719
#    fi


#     if [ -f ${SVCTOOLS_HOME}/common/wccproxy/ref.cnt ]; then
#        FILE=${SVCTOOLS_HOME}/common/wccproxy/ref.cnt
#        GR_ITEM=""
#        GR_ITEM=`/bin/grep REFERENCE_COUNT $FILE | /bin/cut -f 2 -d=`
#        if [ "${GR_ITEM}" -eq "2" -o "${GR_ITEM}" -gt "2" ]; then
#           GR_ITEM=2
#        else
#           GR_ITEM=`expr $GR_ITEM - 1`
#        fi
#        /bin/rm -f ${FILE}
#        /bin/touch ${FILE}
#        /bin/echo "REFERENCE_COUNT=$GR_ITEM" >> $FILE
#     fi


	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsDESTA.txt > /dev/null 2>&1
	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsCALinux.txt > /dev/null 2>&1
	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsWBEM.txt > /dev/null 2>&1
	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsCCAT.txt > /dev/null 2>&1
	START_FLAG=`/bin/grep "startOnBoot" $SVCTOOLS_HOME/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      
 if [ "$START_FLAG" = "true" ]; then
      nodeSpecificStuff
      else
     	 echo "desta is not configured to start at boot time on this machine"
      fi

fi

#${SVCTOOLS_HOME}/common/bin/desta start

/bin/touch $SVCTOOLS_HOME/specific/desta/data/webesInstalled.txt

rm -f $SVCTOOLS_HOME/specific/desta/save/managedentities/*.xml
rm -f $SVCTOOLS_HOME/specific/desta/save/me.properties
rm -f $SVCTOOLS_HOME/specific/desta/save/me.script

# Fix for PTR 91-22-1920
# sed_registry_file webes.Installed "t"
# Fix for PTR 91-22-1920
############# END OF UPGRADE SCRIPT #########################################################
####################################################
WEBESVER=500;export WEBESVER
#

# These are used to restore existing startup symlinks
DESTA_SYMLINK="false"
CCAT_SYMLINK="false"

find_startup_symlinks()
{
 if [ -f /etc/rc.d/rc3.d/*desta ]; then
    TEMP="`/bin/ls /etc/rc.d/rc3.d/*desta`"
    [ -n "$TEMP" ] && DESTA_SYMLINK="true"
 fi

 if [ -f /etc/rc.d/rc3.d/*ccat ]; then
    TEMP="`/bin/ls /etc/rc.d/rc3.d/*ccat`"
    [ -n "$TEMP" ] && CCAT_SYMLINK="true"
 fi
}


restore_startup_symlinks()
{
  OldDir=`/bin/pwd`
  if [ "$DESTA_SYMLINK" = true ]; then
     cd /etc/rc.d/rc2.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc3.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc4.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     cd /etc/rc.d/rc5.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./S89desta
     
     cd /etc/rc.d/rc0.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
     cd /etc/rc.d/rc1.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
     cd /etc/rc.d/rc6.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta_startup ./K01desta
  fi
  if [ "$CCAT_SYMLINK" = true ]; then
     cd /etc/rc.d/rc3.d; /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/wccat_startup ./S99wccat
  fi
  cd $OldDir
}


get_all_installed_WEBES_products()
{
    get_already_installed_product WEBES_INSTALLED ""; export WEBES_INSTALLED
    get_already_installed_product CA_INSTALLED ""; export CA_INSTALLED
    get_already_installed_product CCAT_INSTALLED ""; export CCAT_INSTALLED
}

sed_temp1_registry()
 {
   if [ -f $1 ]; then
      ARGS=$#
      /bin/sed "s/$2.*$//g" $1 | /bin/grep -v '^ *$' > ./tempfile
      /bin/mv ./tempfile $1
      if [ $ARGS -eq 3 ]; then
        /bin/echo "$2$3" >> $1
      fi
   fi
 }


nodeSpecificStuff()
{
 if [ -n "$CA_INSTALLED" -o -n "$CCAT_INSTALLED" ]; then
    echo "Restarting Director on $FULL_HOSTNAME..."
    desta_process_start EXIT_CODE
    if [ "$EXIT_CODE" -ne 0 ]; then
       echo "Could not start Director on $FULL_HOSTNAME."
       exit 350
    fi
    echo "Waiting 60 seconds for Director to finish startup tasks..."
    /bin/sleep 60
 fi
}

get_already_installed_product()
{
# get the installed version of WEBES and SEA/CA 

   if [ "$1" = "WEBES_INSTALLED" ]; then
       INSTALLED_PRODUCT="` rpm -qa| grep ^WEBESBASE 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 `"
   elif [ "$1" = "CCAT_INSTALLED" ]; then
   	INSTALLED_PRODUCT="`rpm -qa|grep ^WEBESCCAT 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5`"
   elif [ "$1" = "CA_INSTALLED" ]; then
   	INSTALLED_PRODUCT="` rpm -qa | grep ^WEBESSEA 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5`"
   fi

   eval $1=${INSTALLED_PRODUCT}
}


uninstall_webes()
{

  # Find any symlinks in the system startup directories
  find_startup_symlinks


 if [ -f ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG ];then
      NOTIFICATION_FLAG=`/bin/grep "notification.Queried" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      export NOTIFICATION_FLAG
      NOTIFICATION_FLAG="YES"
      NOTIFICATION_TYPE=`/bin/grep "notification.Type" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      export NOTIFICATION_TYPE
      WEBES_CFGSTATE=`/bin/grep "webes.CfgState" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /usr/bin/cut -f 2 -d=`
      export WEBES_CFGSTATE
      KIT_PATH=`/bin/grep "kit.path" ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG | /usr/bin/cut -f 2 -d=`
      export KIT_PATH
  fi


  filename="${SVCTOOLS_HOME}/common/desta/config/CommonFiles/SystemState"
  if [ -f $filename ]; then
      stringname=ca.configure
      GR_ITEM=""
      GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
      if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
      fi
      if [ "$GR_ITEM" = "CONFIGURED" ]; then
	 if [ -f "${SVCTOOLS_HOME}/common/ca/config/ACHSInfo" ]; then
	    /bin/cp ${SVCTOOLS_HOME}/common/ca/config/ACHSInfo ${SVCTOOLS_HOME}
         fi
	 ENABLE_DESTA=1
	    if [ ! -e $SVCTOOLS_HOME/specific/ca/save ]; then
	       /bin/mkdir -p $SVCTOOLS_HOME/specific/ca/save
	    fi
            
            /bin/touch $SVCTOOLS_HOME/specific/ca/save/ca_configured
	    
            if [ -f ${SVCTOOLS_HOME}/specific/desta/config/NotifyCA.txt ];then
	     /bin/cp ${SVCTOOLS_HOME}/specific/desta/config/NotifyCA.txt ${SVCTOOLS_HOME}/specific/ca/save
	    fi
     fi
       stringname=ccat.configure
       GR_ITEM=""
       GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
       if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
       fi
       if [ "$GR_ITEM" = "CONFIGURED" ]; then
	  ENABLE_DESTA=1
	     if [ ! -e $SVCTOOLS_HOME/specific/ccat/save ]; then
	        /bin/mkdir -p $SVCTOOLS_HOME/specific/ccat/save
	     fi

             /bin/touch ${SVCTOOLS_HOME}/specific/ccat/save/ccat_configured

	     if [ -f ${SVCTOOLS_HOME}/specific/desta/config/CCATNotify.txt ]; then
	       /bin/cp ${SVCTOOLS_HOME}/specific/desta/config/CCATNotify.txt ${SVCTOOLS_HOME}/specific/ccat/save
	     fi
       fi
        
        stringname=system.state
        GR_ITEM=""
        GR_ITEM=`/bin/grep "$stringname" $filename | /bin/cut -f 2 -d=`
        if [ "$GR_ITEM" = "" ]; then
	    GR_ITEM="NOT_INSTALLED"
        fi
        if [ "$GR_ITEM" = "CONFIGURED" ]; then
            if [ ! -e ${SVCTOOLS_HOME}/specific/desta/userdata ]; then
               /bin/mkdir -p ${SVCTOOLS_HOME}/specific/desta/userdata
            fi
              
            /bin/touch ${SVCTOOLS_HOME}/specific/desta/userdata/desta_configured
              
            COP_FILE="profile.txt DESTA.REG Configuration.dat"
            for FILE in ${COP_FILE}; do
	        if [ -f  $SVCTOOLS_HOME/specific/desta/config/$FILE ]; then
	          /bin/cp $SVCTOOLS_HOME/specific/desta/config/$FILE $SVCTOOLS_HOME/specific/desta/userdata
                  /bin/cp $SVCTOOLS_HOME/specific/desta/config/$FILE $SVCTOOLS_HOME/specific/desta/userdata
                 fi
            done

            if [ -f  $SVCTOOLS_HOME/specific/desta/data/entities.dat ]; then
                  /bin/cp $SVCTOOLS_HOME/specific/desta/data/entities.dat $SVCTOOLS_HOME/specific/desta/userdata
 
            fi 
	      
            if [ -f $SVCTOOLS_HOME/specific/desta/data/Obligation ]; then
              /bin/cp $SVCTOOLS_HOME/specific/desta/data/Obligation $SVCTOOLS_HOME/specific/desta/userdata
            fi
      fi
  fi

  userInfo_filename="${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation"

  if [ -f $userInfo_filename ]; then
     if [ ! -e $SVCTOOLS_HOME ]; then
        /bin/mkdir -p $SVCTOOLS_HOME
     fi

     if [ -f "${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation" ]; then
        /bin/cp ${SVCTOOLS_HOME}/common/desta/config/CommonFiles/UserInformation ${SVCTOOLS_HOME}
     fi
  fi


/bin/echo ""
/bin/echo " WEBESBASE${UNINSTALL_VER} will be uninstalled "
/bin/echo ""
 
  get_all_installed_WEBES_products

####  if [ "$CA_INSTALLED" = "442" -o "$CA_INSTALLED" = "443" ]; then

     if [ "$CA_INSTALLED" = "450" -o "$CA_INSTALLED" = "451"  ]; then	

      UNINSTALL_CAVER=`echo $CA_INSTALLED  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
      UNINSTALL_ANY_CA=WEBESSEA-$UNINSTALL_CAVER
   fi

#Fix for Upgrade support for 4.4.2 over 4.4.0 and 4.4.1

####Fix for Upgrade support for 5.0 over 4.4.3 and 4.5

#   if [ "$CCAT_INSTALLED" = "511" -o "$CCAT_INSTALLED" = "512" ]; then
    if [ "$CCAT_INSTALLED" = "512" -o "$CCAT_INSTALLED" = "520" ]; then
      UNINSTALL_CCATVER=`echo $CCAT_INSTALLED  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
      UNINSTALL_ANY_CCAT=WEBESCCAT-$UNINSTALL_CCATVER
   fi

   if [ -n "$UNINSTALL_ANY_CCAT" ];then
         rpm -e $UNINSTALL_ANY_CCAT
         # Fix for PTR 91-22-1868
           if [ -e ${SVCTOOLS_HOME}/specific/ccat/data ]; then
              /bin/rm -rf $SVCTOOLS_HOME/specific/ccat/data
	   fi 
         # Fix for PTR 91-22-1868
   fi
   if [ -n "$UNINSTALL_ANY_CA" ];then
        rpm -e $UNINSTALL_ANY_CA
        # Fix for PTR 91-22-1868
          if [ -e ${SVCTOOLS_HOME}/specific/ca/data ]; then
             /bin/rm -rf $SVCTOOLS_HOME/specific/ca/data
	  fi 
        # Fix for PTR 91-22-1868
   fi

    rpm -e WEBESBASE-${UNINSTALL_VER}

   if [ $? != 0 ]; then
         SVCTOOLS_HOME=/usr/opt/hp/svctools           
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ca/save/NotifyCA.txt
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ccat/save/CCATNotify.txt
         /bin/rm -f ${SVCTOOLS_HOME}/specific/desta/userdata/Obligation
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ca/save/ca_configured
         /bin/rm -f ${SVCTOOLS_HOME}/specific/ccat/save/ccat_configured
         /bin/rm -f ${SVCTOOLS_HOME}/specific/desta/userdata/desta_configured
	 /bin/rm -f $SVCTOOLS_HOME/specific/desta/userdata/Configuration.dat
         /bin/rm -f $SVCTOOLS_HOME/specific/desta/userdata/entities.dat
	 /bin/rm -rf ${SVCTOOLS_HOME}/specific/ca/save/auto
         /bin/rm -f ${SVCTOOLS_HOME}/UserInformation
      exit 1
   fi    
SVCTOOLS_HOME=/usr/opt/hp/svctools
}

check_if_WEBES_installed()
{
   INSTALLED=""
   INSTALLEDVER=""
   INSTALLEDDOTVER=""
   INSTALLED_PKG=`rpm -qa|grep ^WEBESBASE `
   
  if [ "$INSTALLED_PKG" != "" ]; then
      INSTALLED="true"
      INSTALLEDVER="`echo ${INSTALLED_PKG} 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 `"
      INSTALLEDDOTVER="`echo ${INSTALLED_PKG} 2> /dev/null | /bin/cut -f2,3 -d "-" | /bin/cut -c1,3,5 | /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/p'`"
      UNINSTALL_VER=`echo ${INSTALLEDVER}  2> /dev/null |  /bin/sed -n 's/\([0-9]\)\([0-9]\)\([0-9]\)/\1.\2-\3/p' `
fi

   if [ -n "${INSTALLED}" ]; then
      if [ "${INSTALLEDVER}" -eq "${WEBESVER}" ]; then
	  /bin/cat <<EOF
This procedure can be used to install/upgrade WEBES (${INSTALLEDDOTVER}). But
Web-Based Enterprise Service Suite (${INSTALLEDDOTVER}) is already installed.
Please use webes_install_update or rpm command directly to reinstall/uninstall
any optional subset of WEBES ${INSTALLEDDOTVER}.
EOF
	exit 0
      fi
      if [ "${INSTALLEDVER}" -lt "${WEBESVER}" ]; then
####    if [ "${INSTALLEDVER}" -eq  "442" -o "${INSTALLEDVER}" -eq "443" ]; then
	if [ "${INSTALLEDVER}" -eq  "450" -o "${INSTALLEDVER}" -eq "451" ]; then
	   /bin/cat << EOF

Webes V${INSTALLEDVER} is currently installed.

This script will deinstall V${INSTALLEDVER} and migrate its configuration data
to the V4.5 installation.

EOF
           echo -ne "Do you wish to upgrade to WEBES V5.0.0 (y/n) ? \c"
           read input
           if [ "$input" = "" ]; then
              uninstall_webes
           elif [ ! -z "$input" ]; then
              input=`echo $input | tr [A-Z]  [a-z]`
              if [ "$input" = "yes" -o "$input" = "y" ]; then
                uninstall_webes
              else
                exit 0
              fi
           fi
        else
	/bin/cat <<EOF
An older version of the Web-Based Enterprise Service Suite (${INSTALLEDDOTVER})
is currently installed. That version must be deinstalled before 
this procedure can be executed.
Please use "webes_install_update" config tool  or the "rpm" command directly to uninstall WEBES.
EOF
                exit 1
        fi
      fi
      if [ -n "${INSTALLEDVER}" ]; then
        if [ "${INSTALLEDVER}" -eq "450" -o "${INSTALLEDVER}" -eq "451" ]; then
           echo " "
        else
	        /bin/cat <<EOF
A newer version of the Web-Based Enterprise Service Suite (${INSTALLEDDOTVER})
is currently installed. That version must be deinstalled before 
this procedure can be executed.
EOF
	        exit 1
        fi
      fi
  fi
}


###########################################################################
# Start of script execution

SVCTOOLS_HOME="/usr/opt/hp/svctools"
#WEBES_UPDATE_HOME=`pwd`
WEBES_UPDATE_HOME="."
THROUGH_SCRIPT=1
DESTA_CLI="/usr/sbin/desta"
REGISTRY_HOME="${SVCTOOLS_HOME}"/specific/desta/config

get_all_installed_WEBES_products

if [ -n "$WEBES_INSTALLED" ]; then
    NEW_WEBES="WEBESBASE-5.0-0.i386.rpm"
fi
if [ -n "$CA_INSTALLED" ]; then
    NEW_CA="WEBESSEA-5.0-0.i386.rpm"
fi
if [ -n "$CCAT_INSTALLED" ]; then
    NEW_CCAT="WEBESCCAT-5.2-0.i386.rpm"
fi

check_if_WEBES_installed

## choose from installing the proxy through the Wrapper script or including the wrapper script functions for 
## uninstalling and installing the proxy in this file. Remove lines  293 & 457 if u choose to do the former 
## and unhash line 6 and 432. Wccproxy and WEBES have extracted out their proxy verification and installation 
## in the install.sh and WEBESWrapper.sh scripts. 
${WEBES_UPDATE_HOME}/WEBESWrapper.sh

if [ -n "$CA_INSTALLED" ]; then
     rpm -ih $NEW_CA
fi

if [ -n "$CCAT_INSTALLED" ]; then
     rpm -ih $NEW_CCAT
fi

restore_startup_symlinks

 if [ -f $SVCTOOLS_HOME/common/install/wcc_install_500.sh ]; then
    . $SVCTOOLS_HOME/common/install/wcc_install_500.sh
 else
    echo "could not find the required file"
    exit 0
 fi

if [ "$ENABLE_DESTA" = "1" ]; then
   /bin/ln -sf ${SVCTOOLS_HOME}/common/bin/desta /usr/sbin/desta
    
     get_hostnames
       if [ -f $SVCTOOLS_HOME/specific/desta/userdata/DESTA.REG ]; then
          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG webes.startOnBoot
	  if [ "$GR_ITEM" != "" ]; then
             sed_temp_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG webes.startOnBoot "$GR_ITEM"
	  fi

          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG desta.QSAPport
	  if [ "$GR_ITEM" != "" ]; then
             sed_temp_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG desta.QSAPport "$GR_ITEM"
	  fi

          get_temp_registry_item ${SVCTOOLS_HOME}/specific/desta/userdata/DESTA.REG desta.QSAP=
	  if [ "$GR_ITEM" != "" ]; then
	     sed_temp1_registry ${SVCTOOLS_HOME}/specific/desta/config/DESTA.REG desta.QSAP= "$GR_ITEM"
	  fi
	  rm -f $SVCTOOLS_HOME/specific/desta/userdata/DESTA.REG
     fi
    
    get_registry_item notification.Type; TYPE="$GR_ITEM"
   
    QSAP_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "QSAP"`
    ISEE_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "ISEE"`
    ACHS_NOTIFY=`/bin/echo "$TYPE" | /bin/grep "ACHS"`
    
    get_supported_ISEE
    
#    /bin/echo "Please Note:"
#    /bin/echo ""

#    if [ -z "$ISEE_INSTALLED" -a -n "$QSAP_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "OSEM will continue to be supported, but it does not send notifications to HP customer support."
#        /bin/echo "To install ISEE, please contact your local field representative or visit the ISEE page at:"
#        /bin/echo "http://www.hp.com/hps/hardware/hw_enterprise.html"
#        /bin/echo "Click on the link \"Download ISEE\"." 
#        /bin/echo ""
#        /bin/echo "With the ISEE Client installed, you can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta qsap off"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with PRS or OSEM notification enabled."
#        /bin/echo ""
#    fi
   
#    if [ -z "$ISEE_INSTALLED" -a -n "$ACHS_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. To install ISEE, please contact your local field representative "
#        /bin/echo "or visit the ISEE page at:"
#        /bin/echo "http://www.hp.com/hps/hardware/hw_enterprise.html"
#	 /bin/echo "Click on the link \"Download ISEE\"." 
#        /bin/echo ""
#        /bin/echo "With the ISEE Client installed, you can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta sicl off"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#    fi
 
#    if [ -n "$ISEE_INSTALLED" -a -n "$QSAP_NOTIFY" -a -z "$ISEE_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "OSEM will continue to be supported, but it does not send notifications to HP customer support."

    if [ -n "$ISEE_INSTALLED" -a -z "$ISEE_NOTIFY" ]; then
        /bin/echo "The ISEE Client program is currently installed on your system. "
        /bin/echo "WEBES is now configured to send notifications to ISEE."
        /bin/echo ""
	TYPE="$TYPE ISEE"
        sed_registry_file notification.Type "$TYPE"
    fi

#	/bin/echo "You can issue the following "
#       /bin/echo "command to enable WEBES to issue notifications via ISEE:"
#       /bin/echo "desta isee on"
#       /bin/echo ""
#       /bin/echo "If you are currently using PRS rather than OSEM, you should then disable use of PRS to prevent "
#       /bin/echo "duplicate notifications from both PRS and ISEE, with the command:"
#       /bin/echo "desta qsap off"
#       /bin/echo "Disabling is not necessary if you are using OSEM instead of PRS, since OSEM does not send "
#       /bin/echo "notifications to HP customer support."
#       /bin/echo ""
#       /bin/echo "Continuing WEBES upgrade with PRS or OSEM notification enabled."



#    if [ -n "$ISEE_INSTALLED" -a -n "$ACHS_NOTIFY" -a -z "$ISEE_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. OSEM will continue to be supported, but it does not send "
#        /bin/echo "notifications to HP customer support. The ISEE Client program is currently installed on "
#        /bin/echo "your system. You can issue the following commands to switch to ISEE notification:"
#        /bin/echo "desta isee on"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#     fi

#     if [ -n "$ISEE_NOTIFY" -a -n "$QSAP_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "PRS (CSG/QSAP) will not be supported after February 2005. It is being replaced with ISEE."
#        /bin/echo "ISEE notification is currently enabled, which should NOT be possible."
#        /bin/echo "Please contact WEBES customer support."
#        /bin/echo "Continuing WEBES upgrade with both PRS/OSEM and ISEE notifications enabled."
#        /bin/echo ""
#     fi

#     if [ -n "$ISEE_NOTIFY" -a -n "$ACHS_NOTIFY" ]; then
#        /bin/echo ""
#        /bin/echo "System Initiated Call Logging (SICL) via DSNlink will not be supported after January 2005."
#        /bin/echo "It is being replaced with ISEE. OSEM will continue to be supported, but it does not send "
#        /bin/echo "notifications to HP customer support. The ISEE Client program is currently installed and "
#        /bin/echo "enabled for WEBES notifications on your system. You can issue the following command to "
#        /bin/echo "turn off SICL DSNlink notification:"
#        /bin/echo "desta sicl off"
#        /bin/echo ""
#        /bin/echo "Continuing WEBES upgrade with SICL DSNlink notification enabled."
#        /bin/echo ""
#     fi
   
    get_all_installed_products

      ${SVCTOOLS_HOME}/common/bin/desta servob installationUpdate

#    if [ "${INSTALLEDVER}" -eq "434" ]; then
     # Fix for PTR 91-22-1719
#       ${DESTA_PATH} exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsDESTA.txt > /dev/null 2>&1
     # Fix for PTR 91-22-1719
#    fi


#     if [ -f ${SVCTOOLS_HOME}/common/wccproxy/ref.cnt ]; then
#        FILE=${SVCTOOLS_HOME}/common/wccproxy/ref.cnt
#        GR_ITEM=""
#        GR_ITEM=`/bin/grep REFERENCE_COUNT $FILE | /bin/cut -f 2 -d=`
#        if [ "${GR_ITEM}" -eq "2" -o "${GR_ITEM}" -gt "2" ]; then
#           GR_ITEM=2
#        else
#           GR_ITEM=`expr $GR_ITEM - 1`
#        fi
#        /bin/rm -f ${FILE}
#        /bin/touch ${FILE}
#        /bin/echo "REFERENCE_COUNT=$GR_ITEM" >> $FILE
#     fi


	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsDESTA.txt > /dev/null 2>&1
	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsCALinux.txt > /dev/null 2>&1
	/usr/sbin/desta exec com.compaq.svctools.desta.configuration.ChangeEnrollments -enroll ConfigDefaultsWBEM.txt > /dev/null 2>&1
	START_FLAG=`/bin/grep "startOnBoot" $SVCTOOLS_HOME/specific/desta/config/DESTA.REG | /bin/cut -f 2 -d=`
      
 if [ "$START_FLAG" = "true" ]; then
      nodeSpecificStuff
      else
     	 echo "desta is not configured to start at boot time on this machine"
      fi

fi

#${SVCTOOLS_HOME}/common/bin/desta start

/bin/touch $SVCTOOLS_HOME/specific/desta/data/webesInstalled.txt

# Fix for PTR 91-22-1920
# sed_registry_file webes.Installed "t"
# Fix for PTR 91-22-1920
############# END OF UPGRADE SCRIPT #########################################################
