#!/bin/ksh -p
#
# ident "@(#)M05OSPatches.ksh	1.21 05/08/10 SMI"
#
# Copyright 2001,2004,2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

#
# MODULE NAME: OSPatches 
# AUTHOR     :
# DESCRIPTION: To install Solaris OS patches.
#
# The following exported variables (initialized by the master task) are
# available (read-only) for the module:
#
# G_PROGRAM_ID    : program name
# G_MEDIA_DIR     : pathname of the install directory on the media (CD,...)
# G_PRODUCT_DIR   : pathname of the bundles directory on the media (CD,...)
# G_ADMIN_FILE    : pathname of the admin file used by pkgadd. default provided.
# G_DEBUG         : debug on/off. Possible values "yes", "no"
# G_QUICK_INSTALL : used to force a quick install (no user inputs).
#                   possible values "yes", "no"
# G_TMP_DIR       : pathname of the temporary directory
# G_UT_PROD_NAME  : product name
# G_UT_VERSION    : product version
# G_DAEMON_LOC    : location of OS daemon scripts
# G_LOGFILE       : pathname of the log file.
#


#
# InstallOSPatches()
#
# Description:
#    Installation of Solaris patches
#
# Parameters:
#    (none)
#
# Globals used:
# 	(none) 
#   

InstallOSPatches() {

   InstallPatches "$OS_PATCH_DIR"

   return $?
}

OS_Patch_Preinstall() {
   #
   # Description:
   #    Pre-install procedure
   #
   # Parameters:
   #    (none)
   #
   # Globals used:
   #        (none) 

   case "$G_OS_REL,$G_ISA" in
     5.10,i386) OS_PATCH_DIR="${G_PRODUCT_DIR}/Patches/Solaris_10";;
     *)         OS_PATCH_DIR="";;
   esac

   if [[ -n "$OS_PATCH_DIR" ]]; then
        _DO_INSTALL="yes"
        AddPostInitMessage "Install\t [ Solaris Patches for $G_OS_REL $G_ISA ]"
   fi
 
   return 0
}

#
# Module developers to provide the following functions:
# Module_Init, Module_Preserve, Module_Remove, Module_Install, Module_Restore
# Module_Abort, Module_Exit
#

#
# Module_Init()
#

Module_Init() {

   exit_no=0

   if IsInstallRequired; then

     OS_Patch_Preinstall
     exit_no=$?

   fi

   return $exit_no
}

#
# Module_Preserve()
#

Module_Preserve() {
	
   return 0

}

#
# Module_Remove()
#

Module_Remove() {

   return 0 

}

#
# Module_Install()
#
# Description:  To install Solaris Patches
#
# Parameters:
#   (none)
#
# Globals used: none
#

Module_Install() {

   InstallOSPatches 

   return 0
}

#
# Module_Restore()
#

Module_Restore() {

  return 0

}

#
# Module_Abort()
#

Module_Abort() {

   return 0

}

#
# Module_Exit()
#
# Description:
#    Exit procedure (normal termination)
#
# Parameters:
#   (none)
#
# Globals used:
#

Module_Exit() {

   return 0

}

#
# END
#

#
# MAIN STARTS HERE
#

trap "exit 2" HUP INT QUIT TERM

#
# include libraries
#

. ${G_MEDIA_DIR}/support_lib/iu_lib
. ${G_MEDIA_DIR}/support_lib/module_lib
. ${G_MEDIA_DIR}/support_lib/upgrade_lib

export _EVENT=$1
export _MODULE_NAME=$(basename $0)
export _VARS_LIST=""
export _EXIT_CODE=0
export _RETURN_VAL=0
export _VAR_STORAGE_FILE="${G_TMP_DIR}/.${G_PROGRAM_ID}.${_MODULE_NAME#???}"


DeclareModuleVar _DO_INSTALL="no"
DeclareModuleVar _DO_REMOVE="no"
DeclareModuleVar _SW_INSTALLED="no"
DeclareModuleVar _SW_COMPATIBLE="yes"

#
# BEGIN: Developers module variables definition here
#

DeclareModuleVar OS_PATCH_DIR

#
# END
#

#
# FRAMEWORK CODE 
#

. ${G_MEDIA_DIR}/support_lib/framework_lib
