#!/bin/sh

# Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)postpatch 1.1     03/06/09 SMI"

AF=/opt/SUNWsespsw/conf/admin_file

if `pkginfo SUNWmdemo > /dev/null 2>&1` ; then 
  /usr/sbin/pkgrm -n -a $AF SUNWmdemo > /dev/null 2>&1
fi

if `pkginfo SUNWmdoc > /dev/null 2>&1` ; then
  /usr/sbin/pkgrm -n -a $AF SUNWmdoc > /dev/null 2>&1
fi

if `pkginfo SUNWjatodmo > /dev/null 2>&1` ; then
  /usr/sbin/pkgrm -n -a $AF SUNWjatodmo > /dev/null 2>&1
fi

if `pkginfo SUNWjatodoc > /dev/null 2>&1` ; then
  /usr/sbin/pkgrm -n -a $AF SUNWjatodoc > /dev/null 2>&1
fi

if `pkginfo SUNWse9hk > /dev/null 2>&1` ; then
  rm /opt/SUNWse6920/bin/SUNWse9hk.tar
else
  cd /opt/SUNWse6920/bin > /dev/null 2>&1
  tar xf SUNWse9hk.tar > /dev/null 2>&1 
  pkgadd -n -a $AF -d /opt/SUNWse6920/bin SUNWse9hk > /dev/null 2>&1
  rm -rf /opt/SUNWse6920/bin/SUNWse9hk.tar SUNWse9hk > /dev/null 2>&1
fi

SAVE_EDITOR=$EDITOR
EDITOR=ex;export EDITOR
# Remove restart_se6000 out of crontab
while crontab -l | grep restart_se6000 > /dev/null ; do
   /usr/bin/crontab -e << end  > /dev/null
/restart_se6000
d
w
q
end
done

EDITOR=$SAVE_EDITOR;export EDITOR

echo "postpatch completed successfully!"
