#
# $Header: dbup.ins.pp 1.2 95/04/17 17:43:41 wyim Osd<unix> $ Copyr (c) 1992 Oracle
#

/* Copyright (c) Oracle Corporation 1992.  All Rights Reserved */

/***************************************************************************
NAME
    dbup.ins

FUNCTION
    Install the pseudo-product DBUP.

NOTES

CREATED
    PKu		06/24/92

MODIFIED 
***************************************************************************/
{mark{
/*
 * $Header: macros.vrf.pp 3090000.1 95/09/05 15:17:19 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */

/*
 * $Header: misc.ins.pp 3090000.1 95/09/05 15:17:24 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */








problem_error_info=nls( "problem_error_info","A problem occured trying to process the last error." );
problem_error_info_help=nls( "problem_error_info_help","?html problem_error_info_help" );
problem_error_info_content=nls( "problem_error_info_content","Error Processing Problem" );

problem_dlg_help=nls( "problem_dlg_help","?html problem_dlg_help" );

problem_header_dflt=nls( "problem_header_dflt", "
Platform:	%%operating_system%%
Release:	%%rel_version%%
Product: 	%%pname%%
Version:	%%current_version%%

Area:		(Installation)	

Install information:

	Installer Version:  %%installer_version%%
	Installer Script:   %%_line%% 
	Install Action:     %%Inst_Action%%

	Stage Home	    %%Stage_Home%%
	Oracle_Base	    %%Oracle_Base%%	(%%OFA_Compliant%%)
	Oracle Home	    %%Oracle_Home%%
	Owner		    %%Owner%%
	Log		    %%Install_Log%%

	During installation of the above product the error below is
	encountered:
");




Sys_Macro_Holdfile="%%Oracle_Home%%/orainst/holdfile.log";
Sys_Macro_Help=nls("Sys_Macro_Help", "?html Sys_Macro_Help" );
Sys_Macro_Content=nls( "Sys_Macro_Content", "O/S Error" );
Sys_Macro_Prompt=nls("Sys_Macro_Prompt", "
Error during action '%%_com%%'.

Command:  %%_cmd%%

");
Sys_Macro_Cancel_Prompt=nls("Sys_Macro_Cancel_Prompt", "Installation terminated at user request." );








/* Galina  
	{ 
	  if (exists(User_Dflt_File)) 
	  { 
	    { _tmp_var=translate(dflt_idx, User_Dflt_File, "="); 
	      _dflt_str="%_tmp_var%"; 
	    } 
	    [ 'UNBOUND_ENVIRONMENT_VARIABLE: _dflt_str=list_dflt; ] 
	  } 
	  else 
	    _dflt_str=list_dflt; 
	  if (Default_Install) 
	    output = _dflt_str; 
   else \ 

	    output=MULTIPLE_TEXT_DIALOG(prompt, _dflt_str, content, help); 
   if (exists(User_Dflt_File)) modify(dflt_idx, output, User_Dflt_File, "=");\ 
	  LOG_HDR("MULTIPLE_TEXT") 
	  _prompt=prompt; _answer=output; 
	  first_log=first(_answer); _answer1=rest(_answer); 
	  second_log=first(answer1); _answer=rest(answer1); 
	  third_log=first(answer); answer1=rest(answer); forth_log=first(answer1); 
	  _dummy="       Q> %_prompt%"; modify("", _dummy, Install_Log); 
	  _dummy="       A> %first_log%"; modify("", _dummy, Install_Log); 
	  _dummy="       A> %second_log%"; modify("", _dummy, Install_Log); 
	  _dummy="       A> %third_log%"; modify("", _dummy, Install_Log); 
	  _dummy="       A> %forth_log%"; modify("", _dummy, Install_Log); 
	}
  Galina */















/*
 * $Header: macros.ins.pp 3090000.1 95/09/05 15:17:16 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */


/*
 * $Header: misc.ins.pp 3090000.1 95/09/05 15:17:24 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */









    enter_ins_msg = nls("enter_ins_msg", "Entering dbup.ins");
    leave_ins_msg = nls("leave_ins_msg", "Leaving dbup.ins");

     
	{ /*_ECHO ( enter_ins_msg ) */ 
	  _dummy = enter_ins_msg ; 
	  modify ( "" , ">>> %_dummy%" , Install_Log ) ; 
	}

    /* String initialization */
    start_db_prompt = nls("start_db_prompt", "Starting up the database (SID=%Oracle_Sid%).  See %Install_Log% for status.");
    db_fail_prompt = nls("db_fail_prompt", "Failed to start database (SID=%Oracle_Sid%).  See %Install_Log% for details.  Abort installation.");
    db_started_msg = nls("db_started_msg", "Database (SID=%Oracle_Sid%) started");
    cont_inst_prompt=nls("cont_inst_prompt", "The database startup appears to have failed.  [Yes] to continue installation (of software only) for the rest of selected products.  [No] to abort installation.");
    cont_inst_content=nls("cont_inst_content", "DB Failed");
    cont_inst_help=nls("cont_inst_help", "*The database startup appears to have failed.  Therefore, the Installer cannot create or upgrade database objects in the database.  See log file (%Install_Log%) for diagnostics.

You can still continue with the installation of selected products' software; you need to create or upgrade database objects in the database at a later time.  Alternately, you can abort the installation and retry installing the softwrae and database at a later time.");

    if (product_name(current_product) == "dbup")
    {
         
	{ /*_INSTALL_PRODUCT ( __dbupload ) */ 
	  { 
	    _prod_bound = TRUE ; 
	    _tmp_var = product_interface_label ( __dbupload ) ; 
	  } 
	  [ 'UNBOUND_VARIABLE : { _prod_bound = FALSE ; } ] 
	  { 
	    if ( _prod_bound ) 
	      install ( __dbupload ) ; 
	  } 
	}
        if (Client_Only)
        {
             
	{ /*_INSTALL_PRODUCT ( ocommon ) */ 
	  { 
	    _prod_bound = TRUE ; 
	    _tmp_var = product_interface_label ( ocommon ) ; 
	  } 
	  [ 'UNBOUND_VARIABLE : { _prod_bound = FALSE ; } ] 
	  { 
	    if ( _prod_bound ) 
	      install ( ocommon ) ; 
	  } 
	}
        } 
        else
        {
            if(not(registered("rdbms")))
            {
                
	{ /*_INSTALL_PRODUCT ( rdbms ) */ 
	  { 
	    _prod_bound = TRUE ; 
	    _tmp_var = product_interface_label ( rdbms ) ; 
	  } 
	  [ 'UNBOUND_VARIABLE : { _prod_bound = FALSE ; } ] 
	  { 
	    if ( _prod_bound ) 
	      install ( rdbms ) ; 
	  } 
	}
            }
        }
    }

/*
 * $Header: pinit.ins.pp 3090000.1 95/09/05 15:17:25 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */
/***************************************************************************
NAME
    pinit.ins

FUNCTION
    Contains common initialization code for *.ins scripts.

NOTES

CREATED
    PKu		07/26/92

MODIFIED 
***************************************************************************/
   { /* pinit.ins */
/*
 * $Header: macros.ins.pp 3090000.1 95/09/05 15:17:16 wyim Generic<base> $ Copyr (c) 1992 Oracle
 */

    ui_product(product_label);
    ui_action("");

    if (Install_Doc_Only) {
      install_cd_doc=true;
       
	{ /*_INST_CD_DOC*/ 
	   if ( OraDoc ) { 
	     _pname = product_name ( product ) ; 
	     _pversion = product_version ( product ) ; 
	     if ( install_cd_doc ) 
	       _dummy = "%_pname% %_pversion%" ; 
	     else 
	       _dummy = "" ; 
	     modify ( "%_pname%_%_pversion%" , _dummy , CD_Doc_Inst_File , "=" ) ; 
	   } 
	}
	    }
	  } /*end of pinit.ins*/

    if (product_name(current_product) == "__dbupload")
    {
        /*
         * Loading files....
         */
        if (do_load) 
        {
             
	{ /*_BEGIN_SW_INST*/ 
	  _ploc = product_location ( product ) ; 
	  _pfname = product_file_name ( product ) ; 
	  _pSW = "%Stage_Home%/%_ploc%/%_pfname%.SW" ; 
	  if ( not ( Keep_Stage ) && ( exists ( _pSW ) ) ) remove_file ( _pSW ) ; 
	  _bsi_prdname = "%Oracle_Home%/%_ploc%/partial.prdO" ; 
	  if ( not ( Patch_Install ) ) 
	      if ( exists ( _bsi_prdname ) ) remove_file ( _bsi_prdname ) ; 
	}
	    remove_file("%Oracle_Home%/dbup/install/partial.prd");
            copy(base);

            /* Don't transfer the instal group since it is already
               being copied in the base group */
            /*TRANSF(Load_Admin, instal)*/
             
	{ /*_REG_PROD*/ 
	  
	{ /*_ACTION ( instantiate ( Register_Prompt ) ) */ 
	  _com = instantiate ( Register_Prompt ) ; 
	  ui_action ( "%_com%" ) ; 
	  
	{ /*_LOG_MSG ( "%_com%" ,  Install_Log ) */ 
	  _msg = "%_com%" ; 
	  _logfile = Install_Log ; 
	  if ( _logfile == "" ) 
	  { 
	    modify ( "" , ">>> %_msg%" , Install_Log ) ; 
	    modify ( "" , ">>> %_msg%" , Sql_Log ) ; 
	    modify ( "" , ">>> %_msg%" , Make_Log ) ; 
	    modify ( "" , ">>> %_msg%" , OS_Log ) ; 
	    if ( ORCA_Debug ) 
	      modify ( "" , ">>> %_msg%" , Debug_Log ) ; 
	  } 
	  else if ( _logfile == Install_Log ) 
	    modify ( "" , "     - %_msg%" , Install_Log ) ; 
	  else if ( _logfile == Sql_Log ) 
	    modify ( "" , "     - %_msg%" , Sql_Log ) ; 
	  else if ( _logfile == Make_Log ) 
	    modify ( "" , "     - %_msg%" , Make_Log ) ; 
	  else if ( _logfile == OS_Log ) 
	    modify ( "" , "     - %_msg%" , OS_Log ) ; 
	  else if ( _logfile == Debug_Log ) 
	    if ( ORCA_Debug ) 
	      modify ( "" , "     - %_msg%" , Debub_Log ) ; 
	  else 
	    information_dialog ( "Bad Log file name" ) ; 
	} 
	} 
	  register ( product , File_Loaded_Msg ) ; 
	} /* Need to register product for floppy install. */
            if (not(internally_called)) reference(product);

        } /* if (do_load) */
    }

    /* Only need to do the following if it is a local database. */
    if ((product_name(current_product) == "dbup") && not(Client_Only))
    {
        sgadef_file="%Oracle_Home%/dbs/sgadef%Oracle_Sid%.dbf";
        /*
         * If global list indicates that DB creation did not fail do 
         * this, else do nothing 
         */
        if (empty(DB_Startup_Failed))
        {
            /* Otherwise is DB is not up, try to start it up */ 
            if (not(exists(sgadef_file)))
            {
                ui_action(instantiate(start_db_prompt));
                if (registered("pso"))
                {
                    start_mode="shared";
                } else {
                    start_mode="exclusive";
                }

                 
	{ /*_GET_PFILE ( Oracle_Sid , pfile_spec ) */ 
	  pfile_spec = "" ; 
	  _pfile_log = "%Oracle_Home%/orainst/pfile.spc" ; 
	  if ( exists ( _pfile_log ) ) 
	  { 
	    _ora_sid = Oracle_Sid ; 
	    _tmp_str = translate ( "PFILE_%_ora_sid%" , _pfile_log , "=" ) ; 
	    pfile_spec = "pfile=%_tmp_str%" ; 
	  } 
	  [   'UNBOUND_ENVIRONMENT_VARIABLE : pfile = "" ; 
	  ] 
	}

                instantiate_file ("%Oracle_Home%/rdbms/install/rdbms/startup.orc",
                    "%Oracle_Home%/rdbms/admin/startup%Oracle_Sid%.sql");
                svrmgrl_exec="%Oracle_Home%/bin/svrmgrl";
                startup_sql="%Oracle_Home%/rdbms/admin/startup%Oracle_Sid%.sql";
args="<<!
@%startup_sql%
exit
!";
                 
	{ /*_SYS ( "%svrmgrl_exec% %args%" , "" ) */ 
	  _cmd = "%svrmgrl_exec% %args%" ; _exe = "%svrmgrl_exec% %args%" ; _com = "" ; _help = Sys_Macro_Help ; 
	  
	{ /*_LOG_SEL ( _cmd ,  _log_file ) */ 
	    _log_file = OS_Log ; 
	   if ( contains ( _cmd , "bin/sqldba" ) || contains ( _cmd , "bin/sqlplus" ) || contains ( _cmd , "bin/svrmgrl" ) ) 
	      _log_file = Sql_Log ; 
	   if ( contains ( _cmd , "make " ) ) 
	      _log_file = Make_Log ; 
	} 
	  
	  { { /*_SYS_RETRY*/ 
	    _result = "Retry" ; 
	    _log_file = _log_file ; 
	    problem_holdfile = instantiate ( Sys_Macro_Holdfile ) ; 
	    while ( _result == "Retry" ) { 
	      problem_holdfile = instantiate ( Sys_Macro_Holdfile ) ; 
	      modify ( "" , log_divider ( ) , _log_file ) ; 
	      modify ( "" , "Action:  %_com%" , _log_file ) ; 
	      modify ( "" , "Command: (%_cmd%), Out,Err=%_log_file%" , _log_file ) ; 
	      remove_file ( problem_holdfile ) ; 
	      _line = replace ( log_divider ( ) , "-" , "" ) ; 
	      _stat = spawn ( _exe , problem_holdfile , problem_holdfile ) ; 
	      modify ( "" , "Status:  %_stat%" , _log_file ) ; 
	      if ( _stat != 0 ) { 
	      modify ( "" , "(( OIERR-SYS: %_cmd% ))" , _log_file ) ; 
	      } 
	      _s = _stat ; _result = "Ok" ; 
	      while ( ( _s != 0 ) || ( Sys_Option_ProcessDflt && ( _result == "Process" ) ) ) { 
	        _result = full_retry_dialog ( instantiate ( Sys_Macro_Prompt ) , 
	  	      problem_holdfile , true , Sys_Option_Ignore , true , 
	  	      instantiate ( Sys_Macro_Content ) , instantiate ( _help ) ) ; 
	        if ( Sys_Option_ProcessDflt && ( _result == "Process" ) ) 
	          
		  { /*_SYS_PROCESS_ERROR*/ 
		    { problem_header  = instantiate ( Problem_Header_Dflt ) ; 
	  	      problem_text    = instantiate ( Sys_Macro_Prompt ) ; 
	    	      problem_action  = _com ; 
		      execute ( "problem.ins" ) ; 
		    } 
		    [ 'DEFAULT : { information_dialog ( problem_error_info , problem_error_info_content , problem_error_info_help ) ; } ] 
		  } /*End SYS_PROCESS_ERROR*/ 
	        _s = 0 ; 
	      } 
	      
	    { modify ( "" , "{" , _log_file ) ; 
	      create_file ( problem_holdfile ) ; /*To stop sed raising error*/ 
	      _pfx = "OIERR-SYS" ; if ( _result == "Ok" ) _pfx = "Ok" ; 
	      spawn ( instantiate ( "sed -e 's/^/| %%_pfx%%: /' < %%problem_holdfile%% >>%%_log_file%%" ) ) ; 
	      modify ( "" , "}" , _log_file ) ; } 
	    [ 'DEFAULT : { } ]  
	      modify ( "" , instantiate ( "Result:  %%_result%%" ) , _log_file ) ; 
	    } 
	    modify ( "" , log_divider ( ) , _log_file ) ; 
	    Sys_Option_Ignore = true ; 
	    Sys_Option_ProcessDflt = true ; 
	   } 
	   [ 'CANCEL : { modify ( "" , "Result:  Cancel" , _log_file ) ; 
	      		signal ( 'CANCEL , Sys_Macro_Cancel_Prompt ) ; } ] 
	  } /*End _SYS_RETRY*/ 
	} /*End SYS*/
/*
                spawn("%svrmgrl_exec% <<! @%startup_sql%!", Install_Log, Install_Log);
*/
                if (not(exists(sgadef_file)))
                {
    	            /* If this SW and DB Installation, let the user decides 
                     * whether to continue w/ sw install only or to abort 
                     * installation.
                     */
    	            if (Inst_Action==Inst_Fresh)
    	            {
    		        cont_sw_inst_only=yesno_dialog(cont_inst_prompt, 
                            cont_inst_content, cont_inst_help);
                        if (cont_sw_inst_only)
                        {
    		            add(DB_Startup_Failed, true);
                        } else {
                            signal('cancel);
                        }
    	            } else {
                        signal('failure, db_fail_prompt);
                    }
                } /* if (not(exists(sgadef_file))) */
                ui_action(db_started_msg);
            } /* if (not(exists(sgadef_file))) */
        } /* if (empty(DB_Startup_Failed)) */
    } /* if (product_name(current_product) == "dbup") */
     
	{ /*_ECHO ( leave_ins_msg ) */ 
	  _dummy = leave_ins_msg ; 
	  modify ( "" , ">>> %_dummy%" , Install_Log ) ; 
	}
}}

 
