#!/sbin/sh
#------------------------------------------------------------------#
#
# HPUX_ID: @(#) $Revision: 17.3 $ generated on Mon Mar  5 08:20:36 EST 2001
#
# (c)Copyright 1983-2001 Hewlett-Packard Co.,  All Rights Reserved.
#
#------------------------------------------------------------------#
# SD postremove script template for 11.X patches.                  #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to perform any necessary cleanup actions after the     #
# patch's files have been removed.                                 #
#------------------------------------------------------------------#

_PATCHID=PHNE_22159

UTILS="/usr/lbin/sw/control_utils"

if [ ! -f $UTILS ]; then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

. $UTILS
exitval=$SUCCESS

#####
##### Insert any code you may require at this point in the script.
##### Pay attention to the exitval variable and set appropriately
##### in your code.  If you are unsure as to what types of operations
##### are legal in this file and what types aren't, consult the 
##### "Guidelines for SD Control Scripts" document.
#####
##### START_CUSTOMIZATION_HERE

SAVE_DIR="${SW_ROOT_DIRECTORY}var/adm/sw/save_custom"
DEST_DIR="${SAVE_DIR}/$_PATCHID/backup"

if [ -f ${SW_ROOT_DIRECTORY}usr/share/man/cat1m.Z/telnetd.1m ]
then
  rm -f ${SW_ROOT_DIRECTORY}usr/share/man/cat1m.Z/telnetd.1m 1>/dev/null 2>&1
fi

# Remove the telnet pty files

 rm -rf /dev/pts/t* 1> /dev/null 2>&1

# Place back the backed up old telnet device files.

 ls ${DEST_DIR}/t* 1>/dev/null 2>&1		# Get telnet tty files if any.

 if [ $? -eq 0 ]				# Telnet tty files available.
 then

   echo "NOTE:    Restoring the previous telnet ptys."
   mv ${DEST_DIR}/t* /dev/pts 1>/dev/null 2>&1

   if [ $? -ne 0 ]				# Move fails ?
   then
     echo "WARNING: Unable to restore the telnet ptys to /dev/pts"
     echo "         You need to manually create telnet ptys."
     echo "         /sbin/insf -D/dev -d tels"
     exitval=$WARNING
   fi						# end of $? check.

 else						# if ls fails ?
     echo "WARNING: Unable to restore the telnet ptys to /dev/pts"
     echo "         You need to manually create telnet ptys."
     echo "         /sbin/insf -D/dev -d tels"
     exitval=$WARNING

 fi						# JAGab21120

   rm -rf ${SAVE_DIR}/$_PATCHID 1>/dev/null 2>&1 # Remove backed up dir.

   rmdir ${SAVE_DIR} 1>/dev/null 2>&1		 # Remove save_custom if empty.
exit $exitval
