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

   FILE: template.ins							   

   CONTENTS: Template of various OIS blocks  

   AUTHOR: Athmaraman R

   DATE: 29/11/95
   
   Warning!!!
   Modifications to this file may affect all the scripts generated by OIS.

*/
{
	if (doit)
	{
	/*BEGIN_OIS,INS_FIRST_BLOCK*/ 
		ins_ratchet = "1.0.0.0";
		execute("%INSTALLER_HOME%\%script_os%.ins");
		permit_retry_operations  = TRUE;
		permit_ignore_operations = TRUE;
		permit_process_operations= TRUE;
	
	/*END_OIS*/

 	/*BEGIN_OIS,INS_DEPENDENCY_BLOCK*/
		if (is_depend_exist)
		{
			OIS_EXECUTE_SCRIPT = "INSTALL_DEPENDENCIES";
			{
				execute(instantiate("%%ois_product_location%%\toolsois.ins"));
			}
			['FILE_NOT_FOUND:
			{
				sys_file = "toolsois.ins";
				signal('FAILURE,instantiate(no_sys_file));
			}
			]
		}
	
		/**************************
		Install Components
		***************************/
		if (is_parent_product)
		{
			OIS_EXECUTE_SCRIPT = "INSTALL_COMPONENTS";
			execute(instantiate("%%ois_product_location%%\toolsois.ins"));
		}
	/*END_OIS*/

	/*BEGIN_OIS,INS_BIND_VARIABLES_BLOCK*/
		OIS_EXECUTE_SCRIPT = "INSTALL_ENVIRONMENT_VARIABLES";
		{
			execute(instantiate("%%ois_product_location%%\toolsois.ins"));
		}
		['FILE_NOT_FOUND:
			{
				sys_file = "%%ois_product_location%%\toolsois.ins";
				signal('FAILURE,instantiate(no_sys_file));
			}
		]
	/*END_OIS*/

	/*BEGIN_OIS,INS_REGISTRATION_BLOCK*/
		ui_product(product_label);
		ui_action(instantiate(registering));
		register(current_product);
		if (member(selected_products, current_product))
			reference(current_product);
		if (is_depend_exist)
		{
			OIS_EXECUTE_SCRIPT = "REGISTER_REFERENCE_PRODUCT";
			execute(instantiate("%%ois_product_location%%\toolsois.ins"));
		}
	/*END_OIS*/

	/*BEGIN_OIS,INS_THIRDPARTY_BLOCK*/
		
		thirdparty_info_file = "%PROD_HOME%\oisimprt.ini";
		cur_dir = current_directory();
		change_directory("%PROD_HOME%");
		if (not(exists(thirdparty_info_file)))
		{
			signal('FAILURE,"%thirdparty_info_file% does not exist. Installation cannot continue");
		}
		section_heading = "Third-Party Product Parameters";
		{
			zip_name = translate("name", thirdparty_info_file,section_heading); 
		}
		['UNBOUND_ENVIRONMENT_VARIABLE:
			signal('FAILURE,"Third Party info file corrupted. Installtion termianated");
		]
		
		unzip_command = "%INSTALLER_HOME%\unzip.exe -o %PROD_HOME%\%zip_name%.zip -d %PROD_HOME%";
		{ 
			temp=spawn(instantiate(unzip_command));
		}
		['NO_RESPONSE: continue();] 
		{
			thirdparty_install_name	= translate("InstallerName", thirdparty_info_file,section_heading);
		}
		['unbound_environment_variable:
			signal('FAILURE,"Third Party info file corrupted. Installtion cannot continue");
		]
		/* remove the drive name */
		thirdparty_install_list = explode(thirdparty_install_name,"\");
		thirdparty_install_list = rest(thirdparty_install_list);
		thirdparty_install_name = implode(thirdparty_install_list,"\");				
		
		/* Form the parameters */
		{
			thirdparty_install_parameters = translate("InstallerParam", thirdparty_info_file,section_heading);
		}	
		['unbound_environment_variable:
			{
				thirdparty_install_parameters = "";
				continue();
			}
		]
		thirdparty_directory = directory_name(thirdparty_install_name);		
		thirdparty_install_name = file_name(thirdparty_install_name);
		install_command = "%%thirdparty_install_name%% %%thirdparty_install_parameters%%";
		
		if (installation_mode != 'SHARED)
		{
			change_directory("%thirdparty_directory%");
			{ 
				temp=spawn(instantiate("%install_command%")); 
			}
			['NO_RESPONSE: continue();] 
		}
		else
		{
			information_dialog(instantiate(thirdparty_shared_msg));
		}			
		remove_file(instantiate("%PROD_HOME%\%zip_name%.zip"));
		remove_file(instantiate("%INSTALLER_HOME%\unzip.exe"));
		change_directory(cur_dir);

		/* if no deinstaller name are there remove the entire product directory */
		{
			deinstall_name = translate("DeinstallerName", thirdparty_info_file,section_heading);
		}
		['UNBOUND_ENVIRONMENT_VARIABLE:
		{
			OIS_EXECUTE_SCRIPT = "REMOVE_DIRECTORIES";
			deldir = "%PROD_HOME%";
			execute(instantiate("%%ois_product_location%%\toolsois.ins"));
			remove_directory("%PROD_HOME%");
		}
		]
			

	/*END_OIS*/
	}

}