#!/bin/ksh -p
#
# ident "@(#)framework_lib.ksh	1.7 02/11/19 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#

#
# FRAMEWORK CODE: code to be used by all modules to deal with events
#

#
# Restore module variables
#

RestoreModuleVars

case "$_EVENT" in

   Init)

      Module_Init
      _EXIT_CODE=$?

      ;;

   Preserve)

      # don't overwrite the existing preserved file.
      if ! OldPreservedExist && ! IsUninstallRequired && \
		[[ $_SW_INSTALLED = "yes" ]]; then

         if ! IsDataPreserved; then

            Module_Preserve
            _EXIT_CODE=$?

         fi
      fi

   ;;

   Remove)

      if [[ $_DO_REMOVE = "yes" ]]; then

          Module_Remove
         _EXIT_CODE=$?

      fi

   ;;

   Install)

      if [[ $_DO_INSTALL = "yes" ]]; then

         Module_Install
         _EXIT_CODE=$?
         if [[ $_EXIT_CODE = "0" ]]; then
            _SW_INSTALLED="yes"
            _SW_COMPATIBLE="yes"
         fi
      fi

  ;;

   Restore)

      # try restoring eventhough the package may not be installed.
      if OldPreservedExist || \
      ( ! IsUninstallRequired && [[ $_SW_INSTALLED = "yes" ]] ); then

         if IsModuleDataPreserved || [[ ${_DO_RESTORE:=no} = "yes" ]]; then
            Module_Restore
            _EXIT_CODE=$?
         fi

      fi

   ;;

   Abort)

      Module_Abort

      StopActivityMeter

      rm -f $_VAR_STORAGE_FILE 1> /dev/null 2>&1

   ;;

   Exit)

      Module_Exit

      StopActivityMeter

      rm -f $_VAR_STORAGE_FILE 1> /dev/null 2>&1

   ;;

esac

#
# save local variables
#

SaveModuleVars

return $_EXIT_CODE

