home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
w
/
wr06004.zip
/
WR06004.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-01-27
|
19KB
|
492 lines
/****************************************************************************
Module Name = WR06004.CMD
Descriptive Name = SelectPak 4 (Distributed Data Services)
install tool
Copyright = 04G1049 (C) Copyright IBM Corp. 1988, 1991.
All rights reserved.
US Government Users Restricted Rights -
Use, duplication or disclosure restricted by
GSA ADP Schedule Contract with IBM Corp.
Licensed Materials - Property of IBM
Function = Installation tool for SelectPak 004
Operating System = OS/2 Extended Services
****************************************************************************/
signal on halt /* call HALT: routine on CTRL-BREAK */
"echo off"
/*************************************************/
/* Read in command line arguements if they exist */
/*************************************************/
parse upper arg Base_Drive Update_Drive Backed .
/***********************************************************/
/* Verify that the Database SelectPak message file exists */
/***********************************************************/
MSG_FILE = stream('WR06DBM.MSG' , 'c' , 'query exists')
if MSG_FILE = "" then
do
say " ERROR: could not find message file WR06DBM.MSG "
signal End
end
/***************************************************/
/* Read the message file into an array of messages */
/***************************************************/
do while lines(MSG_FILE) \= 0 /* While not at EOF */
text_of_message = MSG_Parse(linein(MSG_FILE))
MSG.message_number = text_of_message
end /* End of While loop */
/**************************************/
/* Close the message file */
/**************************************/
RC = stream('WR06DBM.MSG' , 'c' , 'close')
start:
"cls"
/****************************************/
/* One possible input parameter is '?' */
/* Display the help panel in this case */
/****************************************/
if Base_Drive = "?" then signal syntax
/*************************/
/* Introductory panel */
/*************************/
say
say
say centre(MSG.43,50)
say centre(Create_MSG(MSG.01,'004'),50)
say centre(MSG.02,50)
say
say
/***************************************************/
/* The Base Drive letter is the Drive letter that */
/* contains the Base Operating System. */
/***************************************************/
get_Base_Drive:
if Base_Drive \= "" then signal got_Base_Drive
call charout ," "MSG.03" "
parse upper linein Base_Drive
if Base_Drive = "" then
do
say " "MSG.04
signal get_Base_Drive
end
got_Base_Drive:
/*************************************************/
/* Verify that the \OS2\INSTALL directory exists */
/* on the drive specified by the user */
/*************************************************/
Base_Drive = substr(Base_Drive, 1, 1)
"dir "Base_Drive":\OS2\INSTALL > NUL 2>>&1"
if RC \= 0 then
do
say
say " "Create_MSG2(MSG.05,Base_Drive,'\OS2\INSTALL')
say " "Create_MSG(MSG.06,'\OS2\INSTALL')
say " "MSG.07
parse linein ignore
Base_Drive = ""
signal get_Base_Drive
end
/***************************************************/
/* The log varible will contain the full path name */
/* of the output log. The output log will contain */
/* any error messages from this installation */
/***************************************************/
LOG = ""Base_Drive":\OS2\INSTALL\WR06004.LOG"
say
say " "Create_MSG(MSG.08,LOG)
say
say
/******************************************************/
/* The Update Drive letter is the letter of the Drive */
/* containing the Database system directory that */
/* you wish to upgrade. */
/******************************************************/
get_Update_Drive:
if Update_Drive \= "" then signal got_Update_Drive
call charout ," "MSG.09" "
parse upper linein Update_Drive
if Update_Drive = "" then
do
say " "MSG.04
signal get_Update_Drive
end
got_Update_Drive:
/*************************************************/
/* Verify that the \SQLLIB directory exists */
/* on the drive specified by the user */
/*************************************************/
Update_Drive = substr(Update_Drive, 1, 1)
"dir "Update_Drive":\SQLLIB > NUL 2>>&1"
if RC \= 0 then
do
say
say " "Create_MSG2(MSG.05,Update_Drive,'\SQLLIB')
say " "Create_MSG(MSG.06,'\SQLLIB')
say " "MSG.07
parse linein ignore
Update_Drive = ""
signal get_Update_Drive
end
/***********************************************************/
/* Display to the user, the directory that will be updated */
/***********************************************************/
say
say " "Create_MSG2(MSG.12,Update_Drive,'SQLLIB')
say
Backup:
/***********************************************************/
/* Ask the user if they would like the old files to be */
/* backed up to the current directory. */
/***********************************************************/
say
say " "Create_MSG(MSG.13,'0.22')
call charout , " "Create_MSG(MSG.14,Backed)
if Backed \= "" then signal got_Backup
parse upper linein Backed
got_Backup:
if Backed = "0" then signal verify
if Backed \= "1" then /* Only 0 and 1 are acceptable inputs */
do
say
say " "MSG.15
Backed = ""
signal Backup
end
verify:
/*************************************************/
/* Ask for verification of the input parameters. */
/* This is done even if the user is using the */
/* command line interface. */
/*************************************************/
say
say
call charout ," "MSG.16" "
parse upper linein Verified
if Verified = "0" then /* If the user answers NO to verification */
do /* then reset all of the input parameters */
Base_Drive = "" /* and go back to the start. */
Update_Drive = ""
Backed = ""
Verified = ""
signal start
end
if Verified \= "1" then /* Only 0 and 1 are acceptable inputs */
do
say
say " "MSG.15
Verified = ""
signal verify
end
say
/*****************************************************************************/
/* */
/* Set up the following variables: */
/* SYSLEVEL: The fully qualified path name of the SYSLEVEL file for database */
/* SQL_PATH: The fully qualified path name of the SQLLIB directory */
/* DLL_PATH: The fully qualified path name of the SQLLIB\DLL directory */
/* REQ_PATH: The fully qualified path name of the SQLLIB\REQDLL directory */
/* */
/*****************************************************************************/
SYSLEVEL = Update_Drive":\SQLLIB\SYSLEVEL.SQL"
SQL_PATH = Update_Drive":\SQLLIB"
DLL_PATH = Update_Drive":\SQLLIB\DLL"
REQ_PATH = Update_Drive":\SQLLIB\REQDLL"
/*******************************************************************/
/* Check to see that the customer has WR06000 or WR06010 installed */
/* by reading the syslevel file. */
/*******************************************************************/
firstline = linein(SYSLEVEL)
/*****************************************************/
/* Close the syslevel file so that it can be updated */
/*****************************************************/
RC = stream(SYSLEVEL,'c','close')
/************************************************************/
/* CSD_LEVEL will contain the current level of service and */
/* PAK_TYPE will tell us weather this installation was from */
/* a server package or requester package. */
/************************************************************/
csd_level = substr(firstline,45,7)
pak_type = substr(firstline,101,8)
/**************************************************************/
/* Only allow this installation if the users current CSD */
/* level is WR06000 ( ES 1.0 ) or WR06010 ( ES 1.0 plus this */
/* first round of SelectPaks ) */
/**************************************************************/
if csd_level \= 'WR06010' & csd_level \= 'WR06000' then
do
say
say " "MSG.17
say " "MSG.18
say " "MSG.19
say
signal End
end
/***********************************************************/
/* If the initial installation was from a server package, */
/* then install SYSLEVEL.SQS as SYSLEVEL.SQL. Otherwise */
/* install SYSLEVEL.SQC as SYSLEVEL.SQL. */
/***********************************************************/
if pak_type = 'with Ser' then SYSLVL_FILE = SYSLEVEL.SQS
else SYSLVL_FILE = SYSLEVEL.SQC
"echo. >> "LOG" 2>>&1"
"echo " centre(MSG.43,50) " >> "LOG" 2>>&1"
"echo " centre(Create_MSG(MSG.01,'004'),50) " >> "LOG" 2>>&1"
"echo. >> "LOG" 2>>&1"
"echo. >> "LOG" 2>>&1"
"echo. >> "LOG" 2>>&1"
/***********************************************************************/
/* If the user had chosen to backup the old version of the files, */
/* then copy the files that will be changing from the SQLLIB directory */
/* to the current directory. */
/***********************************************************************/
if Backed = "0" then signal skip_Backup
"echo "MSG.20 SQL_PATH"\SYSLEVEL.SQL >>"LOG" 2>>&1"
"copy "SQL_PATH"\SYSLEVEL.SQL SYSLVOLD.SQL >>"LOG" 2>>&1"
"echo "MSG.20 DLL_PATH"\SQLC.DLL >>"LOG" 2>>&1"
"copy "DLL_PATH"\SQLC.DLL >>"LOG" 2>>&1"
"echo "MSG.20 DLL_PATH"\SQLCST10.DLL >>"LOG" 2>>&1"
"copy "DLL_PATH"\SQLCST10.DLL >>"LOG" 2>>&1"
"echo "MSG.20 REQ_PATH"\SQLC.DLL to SQLCREQ.DLL >>"LOG" 2>>&1"
"copy "REQ_PATH"\SQLC.DLL SQLCREQ.DLL >>"LOG" 2>>&1"
skip_Backup:
/*****************************************************************************/
/* Determine what type of Database configuration exists. */
/* ie. is it a Server, Requester, Standalone or Requester w/ local databases */
/*****************************************************************************/
"WR06DBM"
nodetype = RC
"echo "MSG.44 " " nodetype " >>"LOG" 2>>&1"
"echo "MSG.45 " >>"LOG" 2>>&1"
/***************************************************************************/
/* Unzip the SQLLIB files -n means only unzip newer files */
/***************************************************************************/
"PKUNZIP2 -n WR06004.SPK *.* "DLL_PATH" >>"LOG" 2>>&1"
if RC = 0 then signal Zip_Done1
if RC = 11 then /* Make a note in the log if no files were unziped */
do
say
say " "Create_MSG(MSG.21,SQL_PATH)
signal Zip_Done1
end
/****************************************************************************/
/* If there were any errors then tell the user that there were problems. */
/****************************************************************************/
say " "MSG.22
say " "Create_MSG(MSG.23,LOG)
say " "
say " "MSG.07
parse linein ignore
Zip_Done1:
/****************************************************************/
/* Copy and delete files based on nodetype of the installation */
/****************************************************************/
if nodetype = 2 then do
"echo copying SQLCREQ.DLL to SQLC.DLL >>"LOG" 2>>&1"
"copy "DLL_PATH"\SQLCREQ.DLL "DLL_PATH"\SQLC.DLL >>"LOG" 2>>&1"
end
if nodetype = 1 then do
"echo copying SQLCSVR.DLL to SQLC.DLL >>"LOG" 2>>&1"
"copy "DLL_PATH"\SQLCSVR.DLL "DLL_PATH"\SQLC.DLL >>"LOG" 2>>&1"
end
if nodetype = 0 then do
"echo deleting SQLCST10.DLL >>"LOG" 2>>&1"
"del "DLL_PATH"\SQLCST10.DLL >>"LOG" 2>>&1"
end
"echo deleting SQLCSVR.DLL, SQLCREQ.DLL >>"LOG" 2>>&1"
"del "DLL_PATH"\SQLCREQ.DLL >>"LOG" 2>>&1"
"del "DLL_PATH"\SQLCSVR.DLL >>"LOG" 2>>&1"
/**********************************************************************/
/* Update the SYSLEVEL file to indicate a SelectPak has been applied */
/**********************************************************************/
"echo "MSG.24" >>"LOG" 2>>&1"
"attrib -r "SQL_PATH"\SYSLEVEL.SQL > NUL 2>>&1"
"copy "DLL_PATH"\"SYSLVL_FILE SQL_PATH"\SYSLEVEL.SQL >>"LOG" 2>>&1"
"del "DLL_PATH"\SYSLEVEL.SQS >>"LOG" 2>>&1"
"del "DLL_PATH"\SYSLEVEL.SQC >>"LOG" 2>>&1"
"attrib +r "SQL_PATH"\SYSLEVEL.SQL > NUL 2>>&1"
REQDLL:
/***********************************************************/
/* If the REQDLL directory exists and has files in it then */
/* update them with the ones in the ZIP file */
/***********************************************************/
"dir "REQ_PATH" > NUL 2>>&1"
if RC \= 0 then signal Done
"PKUNZIP2 -n WR06004.SPK SQLCREQ.DLL "REQ_PATH" >>"LOG" 2>>&1"
if RC = 0 then signal Zip_Done2
/*****************************************************/
/* If there were no files to unpack, notify the user */
/*****************************************************/
if RC = 11 then
do
say
say " "Create_MSG(MSG.21,REQ_PATH)
signal Zip_Done2
end
/****************************************************************************/
/* If there were any errors then tell the user that there were problems. */
/****************************************************************************/
say " "MSG.22
say " "Create_MSG(MSG.23,LOG)
say
say " "MSG.07
parse linein ignore
Zip_Done2:
/*******************************************************************/
/* Clean up the REQDLL directory by renaming the appropriate files */
/*******************************************************************/
if nodetype = 1 || nodetype = 3 then do
"echo copying SQLCREQ.DLL to SQLC.DLL in REQDLL >>"LOG "2>>&1"
"copy "REQ_PATH"\SQLCREQ.DLL "REQ_PATH"\SQLC.DLL >>"LOG "2>>&1"
"echo deleting SQLCREQ.DLL in REQDLL >>"LOG "2>>&1"
"del "REQ_PATH"\SQLCREQ.DLL >>"LOG "2>>&1"
end
else do
"echo deleting SQLCREQ.DLL in REQDLL >>"LOG "2>>&1"
"del "REQ_PATH"\SQLCREQ.DLL >>"LOG "2>>&1"
end
Done:
/**************************************************************/
/* The installation is now complete, inform the user and exit */
/**************************************************************/
say
say centre(Create_MSG(MSG.25,'WR06004'),50)
say
signal End
/***********************************************************/
/* This routine will be called if the user uses CTRL-BREAK */
/***********************************************************/
HALT:
say
say
say MSG.26
say MSG.27
say
signal End
/* Help panel */
syntax:
say
say " "Create_MSG(MSG.28,'WR06004')
say
say " "MSG.29
say " "MSG.30
say " "Create_MSG(MSG.31,'\OS2\INSTALL')
say " "MSG.32
say " "Create_MSG(MSG.31,'\SQLLIB')
say " "MSG.34
say " "Create_MSG(MSG.35,'0.22')
say " "MSG.36
say " "MSG.37
say
say
say " "Create_MSG(MSG.38,'WR06004')
say " WR06004 C C 1 "
say " "MSG.39
say
say
signal End
/*****************************************************************/
/* This routine will take a message and a variable and place the */
/* variable in the proper position in the string. */
/*****************************************************************/
Create_MSG:
parse arg MESSAGE,VARIABLE
PART1 = SUBSTR(MESSAGE,1,POS('%1',MESSAGE)-1)
PART2 = SUBSTR(MESSAGE,POS('%1',MESSAGE)+2)
RETURN PART1 || VARIABLE || PART2
/*********************************************************************/
/* This routine will take a message and two variables and place the */
/* variables in their proper positions in the string. */
/*********************************************************************/
Create_MSG2:
parse arg MESSAGE,VARIABLE1,VARIABLE2
POS1 = POS('%1',MESSAGE)
POS2 = POS('%2',MESSAGE)
PART1 = SUBSTR(MESSAGE,1,POS1-1)
PART2 = SUBSTR(MESSAGE,POS1+2,POS2-POS1-2)
PART3 = SUBSTR(MESSAGE,POS2+2)
RETURN PART1 || VARIABLE1 || PART2 || VARIABLE2 || PART3
/*******************************************************************/
/* This routine will take a message line from the message file */
/* and parse it into a message number and a text string */
/*******************************************************************/
MSG_Parse:
parse arg MESSAGE
TEXT = SUBSTR(MESSAGE,POS(' ',MESSAGE)+1)
message_number = SUBSTR(MESSAGE,1,POS(' ',MESSAGE)-1)
RETURN TEXT
End: