#!/bin/sh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/lpp/bosinst/samples/AE/AS/resetWASProfiles.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2008,2009 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# @(#)41        1.1  src/bos/usr/lpp/bosinst/samples/AE/AS/resetWASProfiles.sh, bosinst, bos720 3/29/09 15:20:29

#
# A utility for resetting WAS profiles back to the original.
#
# usage: sh resetWASProfiles  

# source include for debug output
. /opt/IBM/AE/AS/debugWAS

WAS=/opt/IBM/WebSphere
WAS_HOME=$WAS/AppServer
WAS_PROFILES=$WAS/Profiles
USER_DESKTOP=/home/virtuser/Desktop

   echodebug "Resetting the WebSphere profiles back to the original pre-configured versions"  
   
   echodebug "Remove all existing profiles"
   rm -rf $WAS_PROFILES/* > /dev/null
   
   echodebug "Removing desktop icons"
   rm -rf $USER_DESKTOP/*
   
   echodebug "Unzipping the original profiles"
   unzip $WAS_PROFILES/.ibm/profiles.reset.zip -d $WAS_PROFILES/ > /dev/null
   
   echodebug "Changing permissions"
   chown -R virtuser $WAS_PROFILES
   chgrp -R $WASGROUP $WAS_PROFILES
   
   echodebug "Deleting any init.d services"
   if [ "$UNAME" = "AIX" ]
   then
       rm -rf /etc/rc.d/init.d/*was.init
       rm -rf /etc/rc.d/rc2.d/*was.init
       rm -rf /etc/rc.d/rc3.d/*was.init
       rm -rf /etc/rc.d/rc4.d/*was.init
       rm -rf /etc/rc.d/rc5.d/*was.init
   else
       rm -rf /etc/init.d/*was.init
       rm -rf /etc/init.d/rc2.d/*was.init
       rm -rf /etc/init.d/rc3.d/*was.init
       rm -rf /etc/init.d/rc4.d/*was.init
       rm -rf /etc/init.d/rc5.d/*was.init
   fi

   echodebug "Validating the profile registry"
   $WAS_HOME/bin/manageprofiles.sh -validateAndUpdateRegistry
   
   #remove configuration markers so was config can be run again
   rm -f $CONFIGWAS7/.started
   rm -f $CONFIGWAS7/.ok
      
   echodebug "Done resetting the WebSphere profiles back to the original pre-configured versions"  
    
