
Installgen
Features and Benefits
Installgen
Demo Available for download...
Bookmark This Page

#!/usr/local/bin/perl
# program: 3_win_920_prepinstall_1.pl
# features: This script creates c:\archive, c:\backup, c:\v901
# c:\server_scripts and Oracle OFA directories.
# The Oracle installation CDs are copied to the server
# hard drive if requested by the user.
# Oracle database software is installed using response files in silent
# mode of the Oracle Java-based installer, for the database and OEM/OMS
# software.
# The database build process is started by executing
# file: 17_win_920_db_build_1_1.pl
#
# Script Sequence# : 3
# Used By: run manually by DBA using Administrator account
#
# Copyright 2002 by .com Solutions Inc.
#
# --------------- Revision History ---------------
# Date By Changes
# 11-28-2001 dsimpson Initial Release
# 12-16-2001 dsimpson Added check for additional directories
# in addition to mount_point/SID structure
# Removed creation of OraInventory location - this
# gets created by Oracle installer in Program Files/Oracle.
# 12-24-2001 dsimpson Added removal of OracleDirectoryService_ORCL Service which
# gets inadvertantly created during the silent install process.
# 12-27-2001 dsimpson Added ORACLE_SID environment variable
# 12-28-2001 dsimpson Added use of orahome_name variable.
# 07-25-2002 dsimpson Added support for Oracle 9.2.0, used global variables
# for names of CD install data directories.
# Added request for CD-ROM drive letter.
# Added check for Service Pack 2 or higher.
# This output file was created by Installgen version 1.38 on Thu Nov 14 17:48:05 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net
use strict;
use File::Path;
use Win32::Service;
use Win32::Lanman;
use Win32::Daemon;
use Mail::Sendmail;
use Win32::AdminMisc;
# insure that environment variable is used by this perl script
$ENV{'ORACLE_SID'} = "PROD3";
my $tempsqlcode='';
my $temp_sql_filename="temp_sql_filename.sql";
my $answer='';
my $short_backup_location='c:\backup';
my @proglist = '';
my $double_slash_plsql_compiled_code_dirs = 'c:\v901' . '\plsql_compiled_code\d';
my $double_slash_plsql_compiled_code_dirs2 = $double_slash_plsql_compiled_code_dirs;
$double_slash_plsql_compiled_code_dirs2 =~ s(\\)(\\\\)g;
my $cdrom_drive_letter='';
my ($os_string, $os_major, $os_minor, $os_build, $os_ID) = Win32::GetOSVersion();
my @os_string_array = split(/ /,$os_string);
my $os_string_num = @os_string_array;
my $os_string_version = @os_string_array[$os_string_num-1];
# make sure the Administrator user is running this script
my ($login_name) = Win32::LoginName;
if ($login_name ne "Administrator")
{
# the user running this script is not Administrator - exit
print "You must be logged in as the Administrator user to run this script, exiting....";
# exit immediately!
die
}
if ($os_ID == 2 && $os_major == 5)
{
# Windows 2000 - check for Service Pack 2 or later installed - required for Oracle 9.2.0
if ($os_string_version < 2)
{
# Service Pack 2 or later is not installed - print error and exit
print "********** Windows 2000 info detected: $os_string\n";
print "********** Windows 2000 Service Pack 2 or later is required \n";
print "********** prior to installing Oracle. \n";
print "********** Please update Windows 2000 with Windows Update - then run this script again. \n";
die
}
}
# make sure STDOUT and STDERR are not buffered
select (STDOUT);
$|=1;
select (STDERR);
$|=1;
# request CD-ROM drive letter
print "\n\n";
print "Please enter the drive letter used for the CD-ROM drive: \n";
print "\n\n";
$cdrom_drive_letter = ;
chop($cdrom_drive_letter);
# is this a re-install of Oracle
print "\n\n";
print "Is this a clean install of Oracle software on a server which has \n";
print "never previously contained any Oracle software?(y/n)\n";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "n")
{
# ask user to check for removal of registry and OraInventory entries
print "\n\n";
print "If this is a new installation into a new Oracle Home - please continue normally with the installation.\n";
print "\n";
print "If this is a re-installation into an existing Oracle Home, \n";
print "the following items should be removed prior to continuing the installation.\n";
print "\n";
print "Oracle registry entries for Oracle Home: c:\\v901\n";
print "Remove the ORACLE_SID and OLAP_HOME environment variables.\n";
print "c:\\u01\\bdump\n";
print "c:\\u01\\cdump\n";
print "c:\\u01\\udump\n";
print "c:\\oracle\n";
print "c:\\server_scripts\n";
print "\n";
print "If there is only one Oracle Home on this server, remove the following directories:\n";
print "c:\\Program Files\\Oracle\\Inventory\n";
print "c:\\Program Files\\Oracle\\oraconfig\n";
print "c:\\Program Files\\Oracle\\oui\n";
print "\n";
print "If there are multiple Oracle Homes on this server, run the Oracle installer to remove \n";
print "the Oracle software from c:\\v901.\n";
print "Then remove the c:\\v901 directory.\n";
print "\n\n";
}
# are there multiple Oracle Homes?
print "\n\n";
print "Is there an existing Oracle Home named v9012 on this server?(y/n)\n ";
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# edit response file with new Oracle Home name
print "\n\n";
print "Please pick another Oracle Home name, then re-generate the install scripts.\n";
print "\n\n";
}
# create c:\backup location
if (!-d 'c:\backup')
{
# directory does not exist - prompt to create c:\backup directory
print "\n\n";
print 'Create c:\backup directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\backup location directory
system ("mkdir",'c:\backup');
}
}
# create c:\archive location
if (!-d 'c:\archive')
{
# directory does not exist - prompt to create c:\archive directory
print "\n\n";
print 'Create c:\archive directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\archive location directory
system ("mkdir",'c:\archive');
}
}
# create c:\server_scripts directory
if (!-d 'c:\server_scripts')
{
# directory does not exist - prompt to create c:\server_scripts directory
print "\n\n";
print 'Create c:\server_scripts directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\server_scripts directory
system ("mkdir",'c:\server_scripts');
}
}
# create Oracle Home directory
if (!-d 'c:\v901')
{
# directory does not exist - prompt to create Oracle Home directory
print "\n\n";
print 'Create c:\v901 as Oracle Home directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create Oracle Home directory
@proglist = ("mkdir",'c:\v901');
system (@proglist);
system ("mkdir",'c:\v901\plsql_compiled_code');
for (my $plsql_dir_count=0;$plsql_dir_count <= 999; $plsql_dir_count++)
{
# create 1000 compiled code subdirectories for Oracle to use for compiled PL/SQL
@proglist = ("mkdir","$double_slash_plsql_compiled_code_dirs2$plsql_dir_count");
print "Creating directory $double_slash_plsql_compiled_code_dirs$plsql_dir_count\n";
system (@proglist);
}
}
}
# create compiled pl/sql directories within oracle_home location
if (!-d 'c:\v901\plsql_compiled_code')
{
# directory does not exist - prompt to create compiled pl/sql directories
print "\n\n";
print 'Create c:\v901\plsql_compiled_code directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create compiled pl/sql directories
@proglist = ("mkdir",'c:\v901\plsql_compiled_code');
system (@proglist);
for (my $plsql_dir_count=0;$plsql_dir_count <= 999; $plsql_dir_count++)
{
# create 1000 compiled code subdirectories for Oracle to use for compiled PL/SQL
@proglist = ("mkdir","$double_slash_plsql_compiled_code_dirs2$plsql_dir_count");
print "Creating directory $double_slash_plsql_compiled_code_dirs$plsql_dir_count\n";
system (@proglist);
}
}
}
# create Oracle OFA directories
# Create a prod3 subdirectory under each mount point
if (!-d 'c:\u01')
{
# directory does not exist - prompt to create c:\u01 directory
print "\n\n";
print 'Create c:\u01 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u01 directory
system ("mkdir",'c:\u01');
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u01\prod3');
}
}
if (!-d 'c:\u02')
{
# directory does not exist - prompt to create c:\u02 directory
print "\n\n";
print 'Create c:\u02 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u02 directory
system ("mkdir",'c:\u02');
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u02\prod3');
}
}
if (!-d 'c:\u03')
{
# directory does not exist - prompt to create c:\u03 directory
print "\n\n";
print 'Create c:\u03 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u03 directory
system ("mkdir",'c:\u03');
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u03\prod3');
}
}
# Create a prod3 subdirectory under each mount point - in case id didn't get create previously
if (!-d 'c:\u01\prod3')
{
# directory does not exist - prompt to create c:\u01\prod3 directory
print "\n\n";
print 'Create c:\u01\prod3 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u01\prod3');
}
}
if (!-d 'c:\u02\prod3')
{
# directory does not exist - prompt to create c:\u02\prod3 directory
print "\n\n";
print 'Create c:\u02\prod3 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u02\prod3');
}
}
if (!-d 'c:\u03\prod3')
{
# directory does not exist - prompt to create c:\u03\prod3 directory
print "\n\n";
print 'Create c:\u03\prod3 directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create SID-specific directory within OFA directory
system ("mkdir",'c:\u03\prod3');
}
}
# create udump, cdump, bdump directories
if (!-d 'c:\u01\udump')
{
# directory does not exist - prompt to create c:\u01\udump directory
print "\n\n";
print 'Create c:\u01\udump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u01\udump directory
system ("mkdir",'c:\u01\udump');
}
}
if (!-d 'c:\u01\bdump')
{
# directory does not exist - prompt to create c:\u01\bdump directory
print "\n\n";
print 'Create c:\u01\bdump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u01\bdump directory
system ("mkdir",'c:\u01\bdump');
}
}
if (!-d 'c:\u01\cdump')
{
# directory does not exist - prompt to create c:\u01\cdump directory
print "\n\n";
print 'Create c:\u01\cdump directory?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# create c:\u01\cdump directory
system ("mkdir",'c:\u01\cdump');
}
}
# create UTL_FILE directory
if (!-d 'c:\backup\utl_file_dir')
{
# create UTL_FILE directory
system ("mkdir",'c:\backup\utl_file_dir');
}
# copy Oracle install CDs
if (!-d 'c:\oracle\920_cd1')
{
system ("mkdir",'c:\oracle\920_cd1');
}
print "\n\n";
print 'Copy Oracle 9i CD #1?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# copy Oracle 9i CD #1 to c:\oracle$install_cd_dir1 directory
system ("xcopy",'/Y','/E','/H',"$cdrom_drive_letter:",'c:\oracle\920_cd1');
}
if (!-d 'c:\oracle\920_cd2')
{
system ("mkdir",'c:\oracle\920_cd2');
}
print "\n\n";
print 'Copy Oracle 9i CD #2?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# copy Oracle 9i CD #2 to c:\oracle$install_cd_dir2 directory
system ("xcopy",'/Y','/E','/H',"$cdrom_drive_letter:",'c:\oracle\920_cd2');
}
if (!-d 'c:\oracle\920_cd3')
{
system ("mkdir",'c:\oracle\920_cd3');
}
print "\n\n";
print 'Copy Oracle 9i CD #3?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# copy Oracle 9i CD #3 to c:\oracle$install_cd_dir3 directory
system ("xcopy",'/Y','/E','/H',"$cdrom_drive_letter:",'c:\oracle\920_cd3');
}
print "\n\n";
print 'Start Oracle installation now?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# run installer in silent mode using response file
system ("c:\\oracle\\920_cd1\\install\\win32\\setup.exe",'-responseFile','c:\\oracle\\64_win_920EE_prod3_db_installer_response_1.rsp','-silent');
}
print "\n\n";
print 'After the Oracle installation has completed, press Return to continue';
print "\n\n";
$answer = ;
# shut down the ORCL instance/service - hostname defaults to localhost
Win32::Service::StopService('','OracleServiceORCL');
# add 30 second delay to insure previous task completes
print "Waiting 30 seconds to insure previous task of stopping service completes.\n";
sleep(30);
# delete the ORCL instance with oradim
system ("c:\\v901\\bin\\oradim.exe",'-DELETE','-SID','ORCL');
# remove the OracleServiceORCL
system ("c:\\v901\\bin\\oradim.exe",'-DELETE','-SVRC','ORCL');
# stop the Intelligent Agent - hostname defaults to localhost
Win32::Service::StopService('','agent_service_name');
system ("c:\\v901\\bin\\agentctl.exe",'stop');
# stop the Listener - hostname defaults to localhost
Win32::Service::StopService('','listener_service_name');
system ("c:\\v901\\bin\\lsnrctl.exe",'stop');
# remove oracle datafile directories for ORCL instance - which were created unecessarily by the installer
# files and directories can now be removed - since database is not active
rmtree ("c:\\v901\\orcl");
rmtree ("c:\\v901\\oradata");
# add 15 second delay to insure previous task completes
print "Waiting 15 seconds to insure previous tasks have completed.\n";
sleep(15);
print "\n\n";
print 'Start Oracle OEM/OMS software installation now?(y/n)';
print "\n\n";
$answer = ;
chop($answer);
if ($answer eq "y")
{
# install OEM/OMS software - run installer in silent mode using response file
system ("c:\\oracle\\920_cd1\\install\\win32\\setup.exe",'-responseFile','c:\\oracle\\66_win_920_prod3_oem_installer_response_1.rsp','-silent');
print "\n\n";
print 'After the OEM/OMS installation has completed, press Return to continue';
print "\n\n";
print "(If the Database Creation Assistant starts creating a database - cancel this process in DBCA before it creates another database instance.)\n";
print "\n\n";
$answer = ;
}
# rename Apache/Perl directory to prevent confusion with c:\Perl interpreter
rename("c:\\v901\\Apache\\perl","c:\\v901\\Apache\\old-perl");
# delete the 2nd ORCL instance created by the OEM/OMS installation process
# shut down the ORCL instance - hostname defaults to localhost
Win32::Service::StopService('','OracleServiceORCL');
# add 30 second delay to insure previous task completes
print "Waiting 30 seconds to insure previous task of stopping service completes.\n";
sleep(30);
# delete the ORCL instance with oradim
print "Deleting ORCL SID and Instance ...\n";
system ("c:\\v901\\bin\\oradim.exe",'-DELETE','-SID','ORCL');
# remove the OracleServiceORCL
system ("c:\\v901\\bin\\oradim.exe",'-DELETE','-SVRC','ORCL');
# stop OracleDirectoryService service - before removing
Win32::Lanman::StopService('','',"OracleDirectoryService_ORCL");
# add 30 second delay to insure previous task completes
print "Waiting 30 seconds to insure previous task of stopping service completes.\n";
sleep(30);
# remove OracleDirectoryService service
Win32::Lanman::DeleteService('','',"OracleDirectoryService_ORCL");
# stop the Intelligent Agent - hostname defaults to localhost
Win32::Service::StopService('','agent_service_name');
system ("c:\\v901\\bin\\agentctl.exe stop");
# stop the Listener - hostname defaults to localhost
Win32::Service::StopService('','listener_service_name');
system ("c:\\v901\\bin\\lsnrctl.exe stop");
# add 30 second delay to insure previous task completes
print "Waiting 30 seconds to insure previous task of stopping service completes.\n";
sleep(30);
# remove oracle datafile directories for ORCL instance - which were created unecessarily by the installer
# files and directories can now be removed - since database is not active
rmtree ("c:\\v901\\orcl");
rmtree ("c:\\v901\\oradata");
rmtree ("c:\\v901\\prod3");
print "\n\n";
print 'Press Return to start building the Oracle database instance prod3';
print "\n\n";
$answer = ;
print "\n\n";
print "Running script 17_win_920_db_build_1_1.pl to build database instance...\n";
print "[Note: If 17_win_920_db_build_1_1.pl does not create a database, re-run]\n";
print "[17_win_920_db_build_1_1.pl manually in another window.]\n";
print "\n\n";
# start building the Oracle database instance
system ('17_win_920_db_build_1_1.pl');
print "\n\n";
print 'Run script 4_win_920_postinstall_1.pl to patch the database and perform post-install tasks.';
print "\n\n";

