#!/bin/ksh
###############################################################################
#
#   This Shell Script is for installing CDE Snapins.
#
#   Lexmark International Inc. 1996, 2003
#  
#   (c) Copyright, 2003, Lexmark International Inc. All Rights Reserved.
#
###############################################################################

remove_file()
{
	local_file="${1}"

        if [ -f "${local_file}" ]; then
           printf "Removing ${local_file} ... " 
           rm -f ${local_file}
           if [ $? -ne 0 ]; then
              printf "failed.\n" 
           else
              printf "complete.\n" 
           fi

        fi
}

restore_dt_types()
{
        if [ -d "${HOME}/.dt/types" ]; then
           FP_FILES=`ls ${HOME}/.dt/types/*.fp 2>/dev/null | wc -l`
           if [ "${FP_FILES}" != "0" ]; then
              cp ${HOME}/.dt/types/*.fp ${HOME}/.dt/types/fp_dynamic 2>/dev/null
              rm -f ${HOME}/.dt/types/*.fp 2>/dev/null
           fi
        fi
}

restore_dt_types_fp_dynamic()
{
	if [ -d ${HOME}/.dt/types/fp_dynamic ]; then
		FP_FILES=`ls $HOME/.dt/types/fp_dynamic/*.fp 2>/dev/null | wc -l`
		if [ $FP_FILES != '0' ]; then
			cp $HOME/.dt/types/fp_dynamic/*.fp $HOME/.dt/types/ 2>/dev/null
			rm -f /$HOME/.dt/types/fp_dynamic/*.fp 2>/dev/null
		fi
	fi
}


Delete() 
{	
	# Restore fp_dynamic
	restore_dt_types_fp_dynamic

        # MarkVision Classic 
	remove_file $HOME/.dt/types/Lexmark.fp
	remove_file $HOME/.dt/types/Lexmark_client.fp
	remove_file /etc/dt/appconfig/types/$LANG/NetMarkVision.dt 2>/dev/null
	remove_file /etc/dt/appconfig/types/$LANG/Lexmark_client.fp

        # Lexmark MarkVision Professional 
	remove_file $HOME/.dt/types/Lexmark_mvp.fp
	remove_file /etc/dt/appconfig/types/$LANG/Lexmark_mvp.fp
	remove_file $HOME/.dt/types/mv_pro.fp
	remove_file /etc/dt/appconfig/types/$LANG/mv_pro.fp

        # IBM MarkVision Professional 
	remove_file $HOME/.dt/types/ibm_mv_pro.fp
	remove_file /etc/dt/appconfig/types/$LANG/ibm_mv_pro.fp

        # Lexmark Enhanced Printer Drivers
	remove_file $HOME/.dt/types/Lexmark_print.fp
	remove_file /etc/dt/appconfig/types/$LANG/Lexmark_print.fp
	remove_file $HOME/.dt/types/LexmarkApp.dt	
	remove_file /etc/dt/appconfig/types/$LANG/LexmarkApp.dt
	remove_file $HOME/.dt/types/LexmarkAppAix.dt	
	remove_file /etc/dt/appconfig/types/$LANG/LexmarkAppAix.dt

        # OEM Enhanced Printer Drivers
	remove_file $HOME/.dt/types/MVprint.fp
	remove_file /etc/dt/appconfig/types/$LANG/MVprint.fp
	remove_file $HOME/.dt/types/MVprintApp.dt	
	remove_file /etc/dt/appconfig/types/$LANG/MVprintApp.dt
	remove_file $HOME/.dt/types/MVprintAppAix.dt	
	remove_file /etc/dt/appconfig/types/$LANG/MVprintAppAix.dt

        # Print Drivers for UNIX & Linux Systems
	remove_file $HOME/.dt/types/lex_vision_print.fp
	remove_file /etc/dt/appconfig/types/$LANG/lex_vision_print.fp
	remove_file $HOME/.dt/types/lex_print_drivers.fp
	remove_file /etc/dt/appconfig/types/$LANG/lex_print_drivers.fp

        # IBM Print Drivers for UNIX & Linux Systems
	remove_file $HOME/.dt/types/ibm_print_drivers.fp
	remove_file /etc/dt/appconfig/types/$LANG/ibm_print_drivers.fp

        # DELL Print Drivers for UNIX & Linux Systems
        remove_file $HOME/.dt/types/dell_print_drivers.fp
        remove_file /etc/dt/appconfig/types/$LANG/dell_print_drivers.fp

        # Images
	remove_file /etc/dt/appconfig/icons/$LANG/markvision.bmp 
	remove_file /etc/dt/appconfig/icons/$LANG/markvision.xpm
	remove_file /etc/dt/appconfig/icons/$LANG/details.bmp
	remove_file /etc/dt/appconfig/icons/$LANG/details.xpm

        # Old Files, No longer used. Clean up.
	remove_file $HOME/.dt/types/dtwm.fp
	remove_file /etc/dt/appconfig/types/$LANG/dtwm.fp
	remove_file /usr/dt/lib/xutil.sh
	remove_file /usr/dt/bin/getpdd
	remove_file /usr/dt/bin/sniff


        # The remaining section is no longer used.  We need to restore if needed.
        if [ -f $HOME/.dt/types/print.dt ]; then
	   remove_file $HOME/.dt/types/print.dt 
           mv $HOME/.dt/types/print.dt.lex $HOME/.dt/types/print.dt
        fi

	if [ -f /etc/dt/appconfig/types/$LANG/print.dt.lex ]; then
	   cp /etc/dt/appconfig/types/$LANG/print.dt.lex /etc/dt/appconfig/types/$LANG/print.dt 2>/dev/null
	   remove_file /etc/dt/appconfig/types/$LANG/print.dt.lex
	fi

	if [ -f /usr/dt/bin/dtlp.lex ]; then
	   cp /usr/dt/bin/dtlp.lex /usr/dt/bin/dtlp 2>/dev/null
	   remove_file /usr/dt/bin/dtlp.lex
	fi	

}

cleanup_appmanager()
{
    	package="${1}"
        case ${package} in
        drivers)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/Lexmark ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/Lexmark
                fi
		if [ -d /etc/dt/appconfig/appmanager/$LANG/Enhanced_Drivers ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/Enhanced_Drivers
                fi
                ;;
	mvp)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/MarkVision_Pro ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/Markvision_Pro
                fi
                ;;
	ibmmvp)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/IBM_MarkVision_Pro ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/IBM_Markvision_Pro
                fi
                ;;
        lexdrv)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/Lexmark_Print_Drivers ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/Lexmark_Print_Drivers
                fi
                ;;
        ibmdrv)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/IBM_Print_Drivers ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/IBM_Print_Drivers
                fi
                ;;
        delldrv)
		if [ -d /etc/dt/appconfig/appmanager/$LANG/Dell_Print_Drivers ];then
	           rm -f -r /etc/dt/appconfig/appmanager/$LANG/Dell_Print_Drivers
                fi
                ;;
        esac
}

unintegrate ()
{
	lpkgname="${1}"
        lpkgpath="${2}"
        lpkgshort="${3}"

        if [ -d "${lpkgpath}" ];then
           echo
           echo "Removing ${lpkgname} from the CDE Desktop."  
	   /usr/dt/bin/dtappintegrate -s ${lpkgpath} -u

           echo
        else
           # Package may have been already removed before uninstalling mark2cde, 
           # Lets clean up if we can.
           cleanup_appmanager ${lpkgshort}
        fi
}

Delete1()
{
	unintegrate "Enhanced Printer Drivers" "${MARKPATH}" drivers
	unintegrate "MarkVision Professional" "${MVPPATH}" mvp
	unintegrate "IBM MarkVision Professional" "${IBMMVPPATH}" ibmmvp
	unintegrate "Lexmark Print Drivers for UNIX & LINUX Systems" "${LEXDRVPATH}" lexdrv
	unintegrate "IBM Print Drivers for UNIX & LINUX Systems" "${IBMDRVPATH}" ibmdrv
	unintegrate "Dell Print Drivers for UNIX & LINUX Systems" "${DELLDRVPATH}" delldrv

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/Lexmark ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/Lexmark
        fi

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/Enhanced_Drivers ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/Enhanced_Drivers
        fi

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/MarkVision_Pro ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/MarkVision_Pro
        fi
        
        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/IBM_MarkVision_Pro ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/IBM_MarkVision_Pro
        fi

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/Lexmark_Print_Drivers ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/Lexmark_Print_Drivers
        fi

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/IBM_Print_Drivers ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/IBM_Print_Drivers
        fi

        if [ -d /var/dt/appconfig/appmanager/$DTUSERSESSION/Dell_Print_Drivers ]; then
	       rm -f -r /var/dt/appconfig/appmanager/$DTUSERSESSION/Dell_Print_Drivers
        fi
	CDE_HOST=`echo $DTUSERSESSION | awk -F- '{print $2}'`
        if [ "$CDE_HOST" = `uname -n`  ]; then
		/usr/dt/bin/dtaction RestorePanel
	else 
                echo 
		echo You may run this shell script remotely, but restoring 
                echo the current CDE front panel can only be done on the 
                echo console. You must manually restart your Workspace
                echo Manager.
                echo
	fi 

        restore_dt_types
}


copy_datatype_file()
{

   # Copy datatype file. 

   echo
   if   [ -f $DELLDRVPATH/dt/appconfig/types/C/${datatype_file} ];then

                echo "Using Dell Print Drivers' Datatype file"
                cp $DELLDRVPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $DELLDRVPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null

   elif   [ -f $LEXDRVPATH/dt/appconfig/types/C/${datatype_file} -o -f $IBMDRVPATH/dt/appconfig/types/C/${datatype_file} ];then

           if   [ -f $IBMDRVPATH/dt/appconfig/types/C/${datatype_file} ];then
                echo "Using IBM Print Drivers' Datatype file"
                cp $IBMDRVPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $IBMDRVPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null
           else
                echo "Using Lexmark Print Drivers' Datatype file"
                cp $LEXDRVPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $LEXDRVPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null
           fi

   elif [ -f "$MVPPATH/dt/appconfig/types/C/${datatype_file}" -o -f $IBMMVPPATH/dt/appconfig/types/C/${datatype_file} ];then

           if [ -f $MVPPATH/dt/appconfig/types/C/${datatype_file} ]; then
                echo "Using MarkVision Professional's Datatype file"
                cp $MVPPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $MVPPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null
           else
                echo "Using IBM MarkVision Professional's Datatype file"
                cp $IBMMVPPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $IBMMVPPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null
           fi

   else

           echo "Using MarkVision Native Datatype file"
           if [ -f $MARKPATH/dt/appconfig/types/C/${datatype_file} ]; then
                cp $MARKPATH/dt/appconfig/types/C/${datatype_file} /etc/dt/appconfig/types/$LANG 2>/dev/null
                cp $MARKPATH/dt/appconfig/types/C/${datatype_file} $HOME/.dt/types 2>/dev/null
           fi
   fi
       
}


##########################################################################
#
#
# main shell
#
#
##########################################################################

MARKPATH=/usr/markvision;export MARKPATH
MVPPATH=/usr/mvp;export MVPPATH
IBMMVPPATH=/usr/ibmmvp;export IBMMVPPATH
LEXDRVPATH=/usr/lexprint;export LEXDRVPATH
IBMDRVPATH=/usr/ibmprint;export IBMDRVPATH
DELLDRVPATH=/usr/dellprint;export DELLDRVPATH
PATH=$PATH:/usr/ucb:/usr/bin:/usr/dt/bin:/usr/sbin;export PATH


if [ "$LANG" = "" ]; then
   echo "Language variable is null, it is going to use the default C"
   export LANG=C 
fi

if [ "$USER" = "" ]; then
   echo "USER variable is null, please set up your USER variable"
   exit 1
fi

if [ "$HOME" = "" ]; then
   echo "HOME variable is null, please set up your HOME variable"
   exit 1
fi
  
USER_ID=`whoami`
if [ "$USER_ID" != "root" ] ; then 
   echo "You must be root to run $0!"
   exit 1
fi

if [ ! -d "/usr/dt" ] || [ ! -f "/usr/dt/bin/dtlogin" ]; then
   echo "No CDE found on this system."
   exit 1
fi

if [ "${1}" != "" ]; then
   if [ "${1}" != "-d" ]; then
      echo "USAGE: $0 [-d]"
      echo
      echo "	-d   deinstalls Applications Links from the CDE environment."
      echo
      exit 1
   else
      Delete
      Delete1
      echo "Successfully removed CDE applications links."
      exit 0
   fi
fi

#Create the links for system-wide MarkVision of CDE or user MarkVision
 
ICONS=/etc/dt/appconfig/icons/$LANG


if [ ! -d $ICONS ]; then
   mkdir -p $ICONS 
   chmod 755 $ICONS
   chown root $ICONS
fi

# Create the actions and applications links for system-wide MarkVision of CDE

TYPES=/etc/dt/appconfig/types/$LANG

 
if [ ! -d $TYPES  ]; then
   mkdir -p $TYPES
   chmod 755 $TYPES
   chown root $TYPES
fi

if [[ -f $TYPES/Lexmark_print.fp    || -f $TYPES/Lexmark_client.fp    || 
      -f $TYPES/Lexmark_mvp.fp      || -f $TYPES/mv_pro.fp            || 
      -f $TYPES/ibm_mv_pro.fp       || -f $TYPES/lex_print_drivers.fp ||
      -f $TYPES/lex_vision_print.fp || -f $TYPES/ibm_print_drivers.fp ]]; then

   if [ ! -d $HOME/.dt/types ]; then
      mkdir -p $HOME/.dt/types
      chmod 755 $HOME/.dt/types
      chown $USER $HOME/.dt/types
   fi	

   Delete
   restore_dt_types

   echo 'Updating CDE....'
		
   if [  `uname` = "AIX" ]; then
      datatype_file="LexmarkAppAix.dt"
   else
      datatype_file="LexmarkApp.dt"
   fi

   copy_datatype_file
	
   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp /etc/dt/appconfig/types/$LANG/Lexmark_client.fp 2>/dev/null
   fi

   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp /etc/dt/appconfig/types/$LANG/Lexmark_mvp.fp 2>/dev/null
   fi

   if [ -f $MVPPATH/dt/appconfig/types/C/mv_pro.fp ]; then
      cp $MVPPATH/dt/appconfig/types/C/mv_pro.fp /etc/dt/appconfig/types/$LANG/mv_pro.fp 2>/dev/null
   fi

   if [ -f $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp ]; then
      cp $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp /etc/dt/appconfig/types/$LANG/ibm_mv_pro.fp 2>/dev/null
   fi

   if [ -f $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp ]; then
      cp $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp /etc/dt/appconfig/types/$LANG/lex_print_drivers.fp 2>/dev/null
   fi

   if [ -f $IBMDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp ]; then
      cp $IMBDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp /etc/dt/appconfig/types/$LANG/ibm_print_drivers.fp 2>/dev/null
   fi

   if [ -f $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp ]; then
      cp $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp /etc/dt/appconfig/types/$LANG/dell_print_drivers.fp 2>/dev/null
   fi
   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp /etc/dt/appconfig/types/$LANG/Lexmark_print.fp 2>/dev/null
   fi

else

   if [  `uname` = "AIX" ]; then
      datatype_file="LexmarkAppAix.dt"
   else
      datatype_file="LexmarkApp.dt"
   fi

   Delete
   restore_dt_types

   echo 'Installing applications into the CDE Desktop ...'
  
   # Remove existing mark2cde
   if [ -f /usr/bin/mark2cde ]; then
      rm -f /usr/bin/mark2cde
   fi
	
   if [ ! -d $HOME/.dt/types ]; then
      mkdir -p $HOME/.dt/types
      chmod 755 $HOME/.dt/types
      chown $USER $HOME/.dt/types
   fi	

   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp /etc/dt/appconfig/types/$LANG/Lexmark_client.fp  2>/dev/null
   fi

   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp /etc/dt/appconfig/types/$LANG/Lexmark_mvp.fp  2>/dev/null
   fi

   if [ -f $MVPPATH/dt/appconfig/types/C/mv_pro.fp ]; then
      cp $MVPPATH/dt/appconfig/types/C/mv_pro.fp /etc/dt/appconfig/types/$LANG/mv_pro.fp 2>/dev/null
   fi

   if [ -f $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp ]; then
      cp $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp /etc/dt/appconfig/types/$LANG/ibm_mv_pro.fp 2>/dev/null
   fi

   if [ -f $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp ]; then
      cp $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp /etc/dt/appconfig/types/$LANG/lex_print_drivers.fp 2>/dev/null
   fi

   if [ -f $IBMDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp ]; then
      cp $IBMDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp /etc/dt/appconfig/types/$LANG/ibm_print_drivers.fp 2>/dev/null
   fi

   if [ -f $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp ]; then
      cp $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp /etc/dt/appconfig/types/$LANG/dell_print_drivers.fp 2>/dev/null
   fi

   if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp ]; then
      cp $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp /etc/dt/appconfig/types/$LANG/Lexmark_print.fp  2>/dev/null
   fi
   
   copy_datatype_file
	
   if [ ! -f $HOME/.dt/types/Lexmark_client.fp ]; then
      if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp ]; then	
         cp $MARKPATH/dt/appconfig/types/C/Lexmark_client.fp $HOME/.dt/types/Lexmark_client.fp  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/Lexmark_print.fp ]; then
      if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp ]; then	
         cp $MARKPATH/dt/appconfig/types/C/Lexmark_print.fp $HOME/.dt/types/Lexmark_print.fp  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/Lexmark_mvp.fp ]; then
      if [ -f $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp ]; then
         cp $MARKPATH/dt/appconfig/types/C/Lexmark_mvp.fp $HOME/.dt/types/Lexmark_mvp.fp  2>/dev/null
      fi
   fi
   
   if [ ! -f $HOME/.dt/types/ibm_mv_pro.fp ]; then
      if [ -f $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp ]; then
         cp $IBMMVPPATH/dt/appconfig/types/C/ibm_mv_pro.fp $HOME/.dt/types  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/mv_pro.fp ]; then
      if [ -f $MVPPATH/dt/appconfig/types/C/mv_pro.fp ]; then
         cp $MVPPATH/dt/appconfig/types/C/mv_pro.fp $HOME/.dt/types  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/lex_print_drivers.fp ]; then
      if [ -f $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp ]; then
         cp $LEXDRVPATH/dt/appconfig/types/C/lex_print_drivers.fp $HOME/.dt/types  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/ibm_print_drivers.fp ]; then
      if [ -f $IBMDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp ]; then
         cp $IBMDRVPATH/dt/appconfig/types/C/ibm_print_drivers.fp $HOME/.dt/types  2>/dev/null
      fi
   fi

   if [ ! -f $HOME/.dt/types/dell_print_drivers.fp ]; then
      if [ -f $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp ]; then
         cp $DELLDRVPATH/dt/appconfig/types/C/dell_print_drivers.fp $HOME/.dt/types  2>/dev/null
      fi
   fi

fi

if [ -f $MARKPATH/dt/appconfig/icons/C/markvision.bmp ] ; then
   cp $MARKPATH/dt/appconfig/icons/C/markvision.bmp /etc/dt/appconfig/icons/$LANG
fi

if [ -f $MARKPATH/dt/appconfig/icons/C/markvision.xpm ]; then
   cp $MARKPATH/dt/appconfig/icons/C/markvision.xpm /etc/dt/appconfig/icons/$LANG
fi

if [ -f $MARKPATH/dt/appconfig/icons/C/details.bmp ] ; then	
   cp $MARKPATH/dt/appconfig/icons/C/details.bmp /etc/dt/appconfig/icons/$LANG
fi

if [ -f $MARKPATH/dt/appconfig/icons/C/details.xpm ] ; then
   cp $MARKPATH/dt/appconfig/icons/C/details.xpm /etc/dt/appconfig/icons/$LANG
fi

if [ -d $HOME/.dt/types ]; then
   chmod 777 $HOME/.dt/types/*
   if [ -d $HOME/.dt/types/fp_dynamic ]; then
      FP_FILES=`ls $HOME/.dt/types/fp_dynamic/*.fp 2>/dev/null | wc -l`
      if [ $FP_FILES != '0' ]; then
         cp $HOME/.dt/types/fp_dynamic/*.fp $HOME/.dt/types/ 2>/dev/null
         rm -f $HOME/.dt/types/fp_dynamic/*.fp 2>/dev/null
      fi
   fi
fi

if [ -d $MARKPATH ]; then
   echo
   echo "Installing Enhanced Printer Driver into the CDE Desktop."  
   /usr/dt/bin/dtappintegrate -s $MARKPATH
fi
if [ -d $MVPPATH ]; then
   echo
   echo "Installing MarkVision Professional into the CDE Desktop."  
   /usr/dt/bin/dtappintegrate -s $MVPPATH
fi
if [ -d $IBMMVPPATH ]; then
   echo
   echo "Installing IBM MarkVision Professional into the CDE Desktop."  
   /usr/dt/bin/dtappintegrate -s $IBMMVPPATH
fi
if [ -d $LEXDRVPATH ]; then
   echo
   echo "Installing Lexmark Print Drivers for UNIX & LINUX Systems into CDE."  
   /usr/dt/bin/dtappintegrate -s $LEXDRVPATH
fi
if [ -d $IBMDRVPATH ]; then
   echo
   echo "Installing IBM Print Drivers for UNIX & LINUX Systems into CDE."  
   /usr/dt/bin/dtappintegrate -s $IBMDRVPATH
fi
if [ -d $DELLDRVPATH ]; then
   echo
   echo "Installing DELL Print Drivers for UNIX & LINUX Systems into CDE."  
   /usr/dt/bin/dtappintegrate -s $DELLDRVPATH
fi


/usr/dt/bin/dtaction ReloadApps

CDE_HOST=`echo $DTUSERSESSION | awk -F- '{print $2}'`
if [ "$CDE_HOST" != `uname -n`  ]; then
   echo
   echo You may run this shell script remotely, but restoring
   echo the current CDE front panel can only be done on the
   echo console. You must manually restart your Workspace
   echo Manager.
   echo
else
   # installs files and updates running CDE
   /usr/dt/bin/dtaction RestorePanel
fi

if [ -d $HOME/.dt/types ]; then
   FP_FILES=`ls $HOME/.dt/types/*.fp 2>/dev/null | wc -l`
   if [ $FP_FILES != '0' ]; then
      if [ ! -d $HOME/.dt/types/fp_dynamic ]; then
          mkdir $HOME/.dt/types/fp_dynamic
          chmod 755 $HOME/.dt/types/fp_dynamic
          chown $USER $HOME/.dt/type/fp_dynamic
      fi	
      cp $HOME/.dt/types/*.fp $HOME/.dt/types/fp_dynamic 2>/dev/null
      rm -f $HOME/.dt/types/*.fp 2>/dev/null
    fi
    chmod 755 $HOME/.dt/types/*
fi

echo
echo "NOTE:"
echo "If there are icons missing from the personal printers' sub-panel, you"
echo "may have to re-logon for changes to take affect."
echo
 
 
exit 0

######################### End of Script ######################################## 
