home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 29 Fixes_o
/
29-Fixes_o.zip
/
ip7005.zip
/
HPFS.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-10-29
|
28KB
|
759 lines
/****************************************************************************
Module Name = HPFS.CMD
Descriptive Name = Select Pak IP07005 ( HPFS386FS )
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 Select Pak
Operating System = OS/2 2.x
****************************************************************************/
signal on halt /* call HALT: routine on CTRL-BREAK */
"echo off"
final_rc = 0 /* preset return code */
/*************************************************/
/* Set the following variables to substitute the */
/* correct SelectPak data */
/*************************************************/
Prod_id.1 = "HPFS" /* extension for syslevel files */
Prod_dir = "IBM386FS"
Prod_title = "MSG.80"
SPak = "IP07005"
Backup_size = '150k'
subdirs.0 = '1' /* number of subdirectories in product */
subdirs.1 = 'IBM386FS' /* subdirectories in product */
syslvl_prefix.0 = '1' /* number of syslevels to be updated */
syslvl_prefix.1 = 'IP0' /* syslevel prefix for prereqs */
/***********************************************************/
/*************************************************/
/* Read in command line arguments if they exist */
/*************************************************/
parse upper arg var1 var2 var3 var4 rest
/***********************************************************/
/* Serach for SYSLEVEL.SRV drive */
/***********************************************************/
drive_array = "CDEFGHIJKLMNOPQRSTUVWXYZ"
do k = 1 to 24
drive_letter = substr(drive_array,k,1)
sysl = drive_letter":\IBMLAN\SYSLEVEL.SRV"
'dir 'sysl' >>NUL 2>>&1 '
if rc \= 0 then do /* if syslevel not found, keep seraching */
sysl = ''
iterate
end
else do
sysline = linein(sysl) /* read in SYSLEVEL.SRV */
RC = stream(sysl,'c','close')
/* close the SYSLEVEL.SRV file so that it can be upkated */
country = substr(sysline,47,1)
signal vmsg
end
end
say " This SelectPak has a prereq to "
say " LS3.0 IBM386FS with LAN SERVER syslevel 7001 "
say " which is not installed ... Quitting "
signal End
vmsg:
/* SELPAK.MSG = "IP"country"7005.MSG" */
/***********************************************************/
/* Verify that the Select Pak message file exists */
/***********************************************************/
MSG_FILE = stream('SELPAK.MSG' , 'c' , 'query exists')
if MSG_FILE = "" then
do
say " ERROR: could not find message file SELPAK.MSG "
signal End
end
/***************************************************/
/* Read the message file into an array of messages */
/***************************************************/
do while lines(MSG_FILE) \= 0 /* While not at EOF */
Message = linein(MSG_FILE)
parse var Message message_number text_of_message
MSG.message_number = text_of_message
end /* End of While loop */
/**************************************/
/* Close the message file */
/**************************************/
RC = stream('SELPAK.MSG' , 'c' , 'close')
/****************************************/
/* One possible input parameter is '?' */
/* Display the help panel in this case */
/****************************************/
backup_dir = '\'prod_id.1'_BAK'
if var1 = "?" then signal syntax
"cls"
/*************************/
/* Introductory panel */
/*************************/
say
say
say center(value(prod_title),80)
say center(Create_MSG(MSG.01,SPak),80)
say center(Create_MSG(MSG.02,"SRV"),80)
say
say " Please shut down LAN Server before applying this SelectPak "
say " ( Ctrl_Break, then Enter to exit ) "
say
Source_path = ""
Base_Drive = ""
Update_Drive = ""
Log_File = ""
Verified = ""
Backup_dir = ""
Backed = ""
First_lock = "1"
Filename. = "aaa"
Prod_msg = value(prod_title)
result=0
token.1 = var1
token.2 = var2
token.3 = var3
token.4 = var4
token.5 = var5
token.6 = rest
do i = 1 to 6 until token.i = ""
select
when substr(token.i,1,3) = "/B:" then
Base_Drive = substr(token.i,4,,)
when substr(token.i,1,3) = "/T:" then
Update_drive = substr(token.i,4,,)
when substr(token.i,1,3) = "/K:" then
Backed = substr(token.i,4,,)
when substr(token.i,1,3) = "/S:" then
Source_path = substr(token.i,4,,)
when substr(token.i,1,3) = "/V:" then
Verified = substr(token.i,4,,)
otherwise
end /* end select */
end /* do loop */
start:
/***************************************************/
/* The Base Drive letter is the Drive letter that */
/* contains the Base Operating System. */
/***************************************************/
if Base_Drive \= "" then signal got_Base_Drive
get_Base_Drive:
call charout ," "MSG.03" "
parse upper linein Base_Drive
got_Base_Drive:
Base_Drive = strip(Base_drive,T,':') /* remove trailing colon */
/*************************************************/
/* Verify that the \OS2\INSTALL directory exists */
/* on the drive specified by the user */
/*************************************************/
"dir "Base_Drive":\OS2\INSTALL > NUL 2>>&1"
if RC \= 0 then
do
say
say " "Create_MSG(MSG.05,Base_Drive':\OS2\INSTALL')" "
Base_Drive = ""
signal get_Base_Drive
end
Base_done:
/***************************************************/
/* 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_file = ""Base_drive":\OS2\INSTALL\"SPak".LOG"
/******************************************************/
/* 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.91" "
parse upper linein Update_Drive
got_Update_Drive:
Update_drive = STRIP(Update_drive,T,':') /* remove trailing colon */
/*************************************************/
/* Verify that the Product directory exists */
/* on the drive specified by the user */
/*************************************************/
"dir "Update_Drive":\"Prod_dir" > NUL 2>>&1"
if RC \= 0 then
do
say
say " "Create_MSG(MSG.05,Update_Drive':\'Prod_dir)" "
Update_Drive = ""
signal get_Update_Drive
end
/******************************************************/
/* The Source path is the path where the updates */
/* reside. */
/******************************************************/
get_Source_Path:
if Source_Path \= "" then signal got_Source_Path
call charout," "Create_MSG(MSG.10,SPak'.SPK')" "
parse upper linein Source_Path
got_Source_Path:
/*************************************************/
/* Verify that the zip file exists */
/* on the path specified by the user */
/*************************************************/
if length(Source_Path) = 1 then /* allow user to enter */
Source_Path = Source_Path':' /* drive letter only */
source_file = stream(source_path'\'SPak'.SPK','c','query exists')
if source_file = "" then
do
say
say " "Create_MSG(MSG.11,source_path'\'SPak'.SPK')" "
Source_Path = ""
signal get_Source_Path
end
/*************************************************/
/* Set up backup directory for verification */
/*************************************************/
Get_backup:
backup_dir = Update_drive':\'prod_id.1'_BAK'
if Backed \= "" then signal got_Backup
/***********************************************************/
/* Ask the user if they would like the old files to be */
/* backed up to the default directory or specify their own */
/***********************************************************/
say
say " "Create_MSG(MSG.13,Backup_size)
ask_Backup:
say " "MSG.14
/* call charout , " "Create_MSG(MSG.35,Backup_dir) */
say " "Create_MSG(MSG.35,Backup_dir)" "
say " "MSG.72
parse linein Backed
if Backed = "" then signal ask_Backup
got_Backup:
if backed \= '0' & backed \= '1' then
do
backup_dir = backed
end
start_verify:
/***********************************************************/
/* Display the log file name */
/***********************************************************/
say
say " "Create_MSG(MSG.08,log_file)" "
/***********************************************************/
/* Display the directory that will be updated */
/***********************************************************/
say " "Create_MSG(MSG.12,Update_Drive':\'Prod_dir)" "
/***********************************************************/
/* Display the source path for update data */
/***********************************************************/
say " "Create_MSG(MSG.63,Source_Path'\'SPak'.SPK')" "
/***********************************************************/
/* Display the backup path */
/***********************************************************/
if backed = '0' then
say " "msg.60
else
say " "Create_MSG(msg.61,Backup_dir)" "
say
/*************************************************/
/* Ask for verification of the input parameters. */
/*************************************************/
ask_verify:
if Verified \= "" then signal got_verify
call charout ," "MSG.16" "
parse upper linein Verified
got_verify:
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 = ""
Source_Path = ""
Verified = ""
Backed = ""
"cls"
signal start
end
if Verified \= "1" then /* only 0 and 1 are acceptable inputs */
do
say
say " "MSG.15" "
Verified = ""
signal ask_verify
end
say
say
/***********************************************************/
/* Set up pertinent variables */
/***********************************************************/
PROD_ID_PATH = Update_Drive":\"Prod_dir
do k = 1 to syslvl_prefix.0
/* syslvl.k = Update_Drive":\"Prod_dir"\SYSLEVEL."Prod_id.k */
syslvl.k = drive_letter":\IBMLAN\SYSLEVEL.SRV"
'dir 'syslvl.k' >> NUL 2>>&1 '
if rc \= 0 then /* skip this syslevel if not present */
do
syslvl.k = ''
iterate
end
/***********************************************************/
/* Check to see that the customer has IP07001 */
/* installed by reading the syslevel file. */
/***********************************************************/
firstline.k = linein(syslvl.k) /* firstline used in later loop */
/***********************************************************/
/* Close the syslevel file so that it can be updated */
/***********************************************************/
RC = stream(syslvl.k,'c','close')
/************************************************************/
/* CSD_LEVEL will contain the current level of service */
/************************************************************/
csd_level = substr(firstline.k,48,4)
/**************************************************************/
/* Only allow this installation if the users current CSD */
/* level is IP07001 ( LS 3.0 ) */
/**************************************************************/
if csd_level < 7001 | csd_level > 7005 then
do
say
say " "MSG.17
say " "create_msg(msg.18,msg.86)
say " "MSG.19
say
signal End
end
end /* syslevel loop */
/* put CSD header in the log file */
"echo. >> "Log_file" 2>>&1"
"echo " center(prod_msg,80) " >> "Log_file" 2>>&1"
"echo " center(Create_MSG(MSG.01,SPak),80) " >> "Log_file" 2>>&1"
"echo " center(date('L') time(),80) " >> "Log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
Backup:
if backed = '0' then signal skip_backup
/***********************************************************/
/* Backup the files! */
/***********************************************************/
"dir "backup_dir" > NUL 2>>&1"
if RC \= 0 then /* if not found */
do
'MD 'backup_dir' >>NUL 2>>&1'
if rc \= 0 then
do
failed_RC = rc
signal error
end
end /* Do RC \= 0 */
dirname=""
do i = 1 to subdirs.0 /* subdirs.0 = num dirs found */
dirname = dirname||'\'subdirs.i /* skip c:\ */
'MD 'Backup_dir'\'dirname' >> NUL 2>>&1 '
end /* do dir loop */
say
say Create_msg(MSG.20,backup_dir)
say
"echo " Create_msg(msg.20,backup_dir) " >>"log_file" 2>>&1"
SPAK_vew = update_drive':\'prod_dir'\'SPAK'.vew'
"PKUNZIP2 -v "Source_Path"\"SPak".SPK hpfs*.* >> "SPak_vew" "
if RC \= 0 then
do
failed_RC = RC
signal error
end /* do */
call find_filename spak_vew filename.
file_count = RESULT
rc = stream(SPak_vew,'c','close') /* close view file */
do file = 1 to file_count
"copy "Update_Drive":\"filename.file" "Backup_dir"\"filename.file" >> NUL"
copy_rc = rc
if copy_rc = 1 then iterate /* new file */
if copy_rc = 0 then
do
say create_msg(MSG.69,filename.file)
"echo "create_msg(MSG.69,filename.file)" >> "log_file" 2>>&1"
end
else do
say create_msg(msg.70,filename.file)
"echo "create_msg(MSG.70,filename.file)" >> "log_file" 2>>&1"
failed_rc = copy_RC
signal backup_err
end /* backup error */
copy_end:
end /* do backups */
skip_Backup:
/***********************************************************/
/* Unzip the files! */
/***********************************************************/
say
say MSG.62
say
Prod_id_tmp = Update_drive":\"Prod_dir"\"SPak".tmp"
/*"PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "Update_Drive":\ >> "Prod_id_tmp" "*/
"PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "Update_Drive":\ "Prod_dir"\*.* >> "Prod_id_tmp" "
zip_rc = RC
"echo. >> "Log_file" 2>>&1"
"echo "create_msg(MSG.64,Update_drive":\"Prod_dir) " >> "Log_file" 2>>&1"
"copy "Log_file" + "Prod_ID_tmp" "Log_file" >> NUL " /* append to log file */
if RC \= 0 then
do
failed_RC = RC
signal error
end
/* two places for PKUNZIP output to avoid confusion when there is */
/* more than one SelectPak in the log_file */
select
when Zip_RC = 11 then
do
say
say " "Create_MSG(MSG.21,Prod_id_Path)" "
signal Done
end
when Zip_RC = 10 then
do
failed_RC = Zip_RC
signal error
end
when Zip_RC = 1 then
do
Lock_lines. = ""
SPak_fnd = update_drive':\'prod_dir'\'SPak'.fnd'
'find "can''t create" 'Prod_ID_tmp' >>'SPak_fnd' '
if RC \= 0 then
do
failed_RC = RC
signal error
end
if lines(SPak_fnd) \= 0 then
do
say
say MSG.71 /* warning message */
say create_MSG(MSG.23,Log_file)
do j = 1 to 4 /* skip 4 line header */
trash = linein(SPak_fnd) /* generated by find cmd */
end /* do */
j = 0
do while lines(SPak_fnd) \= 0
j = j + 1 /* create what SysFileSearch */
lock_lines.j = linein(SPak_fnd) /* would have created */
end
lock_lines.0 = j
rc = stream(SPak_fnd,'c','close') /* close find file */
signal files_locked
end /* end lines \= 0 */
end /* end zip_rc = 1 */
when Zip_RC = 0 then signal Done
otherwise
do
/****************************************************************************/
/* If there were any errors then tell the user that there were problems. */
/****************************************************************************/
say " PKUNZIP failure. Return code = " Zip_RC
say MSG.22
say Create_MSG(MSG.23,LOG_file)
say
end
end /* select */
Done:
/* The installation is now complete, inform the user and exit */
say
say center(Create_MSG(MSG.90,SPak),80)
say
"echo "create_msg(MSG.90,SPak)" >> "log_file" 2>>&1"
final_rc = 0
signal End
/***********************************************************/
/* This routine will be called if the user uses CTRL-BREAK */
/***********************************************************/
HALT:
say
say
say MSG.26
say MSG.27
say
final_RC = '9999'
signal END
/*****************************************************************/
/* This routine will be called when there is a failure when */
/* backing up the files to be replaced. */
/*****************************************************************/
Backup_err:
Error:
say
say SPak" install cannot continue. See "LOG_file" for more info "
say " Return Code" Failed_RC "from line "sigl
say
"echo "create_msg(MSG.73,SPak)" >> "log_file" 2>>&1"
"echo "create_msg2(MSG.74,Failed_RC,sigl)" >> "log_file" 2>>&1"
final_rc = "0804"
signal END
/*****************************************************************/
/* this routine reads a redirected pkunzip view file */
/* and parses for the filename. It returns the number of */
/* filenames found in RESULT. */
/*****************************************************************/
find_filename:
parse upper arg zipfile filename.
do while first \= "Length"
data = linein(zipfile)
parse var data first rest
end /* do */
name_token = wordpos("Name",data)
data = linein(zipfile) /* throw away dashed line */
count = 1
data = linein(zipfile) /* get first data line */
token1 = word(data,1)
do until token1 = "------"
filename.count = word(data,name_token)
filename.count = translate(filename.count,"\","/")
count = count + 1
data = linein(zipfile)
token1 = word(data,1)
end /* do */
return count - 1
/*****************************************************************/
/* this routine copies locked files to the IBMLANLK subdirectory */
/* and creates the locked file list for use in the file */
/* replacement after reboot */
/*****************************************************************/
files_locked:
If first_lock = "1" then
do
first_lock = "0"
/* query existence of IBMLANLK subdirectory on the update drive */
"dir "Update_drive":\IBMLANLK > NUL 2>>&1"
if RC \= 0 then /* if not found */
do
'MD 'Update_drive':\IBMLANLK'
if rc \= 0 then
do
say "error " RC " creating IBMLANLK subdirectory"
failed_RC = RC
signal error
end
end /* Do RC 18 */
LanLock = Update_drive":\IBMLANLK"
/* query existence of OS2\INSTALL\LOCK subdirectory on base drive */
/* "dir "Base_drive":\OS2\INSTALL\LOCK > NUL 2>>&1" */
/* if RC \= 0 then */
/* do */
/* lock_path = Base_drive":\OS2\INSTALL" */
/* end end not found */
/* else */
/* do */
/* lock_path = Base_drive":\OS2\INSTALL\LOCK" */
/* end end not found */
/* query existence of SPKLOCK subdirectory on the update drive */
"dir "Update_drive":\SPKLOCK >> NUL 2>>&1"
if RC \= 0 then /* if not found */
do
'MD 'Update_drive':\SPKLOCK'
if rc \= 0 then
do
say "error " RC " creating SPKLOCK subdirectory"
failed_RC = RC
signal error
end
end /* Do RC 18 */
/* unzip the locked file handler to the SPKLOCK subdirectory */
lock_path = Update_drive":\SPKLOCK"
"echo. >> "Log_file" 2>>&1"
"pkunzip2 -n "Source_path"\SPKLOCK.ZIP "lock_path" >> "Log_file" 2>>&1"
end /* end First_lock */
lock_list = lock_path"\IBMLANLK.LST"
EOF = x2c(1A)
out_file = stream(lock_list,'c',"open write")
if out_file \= "READY:" then
do
failed_RC = out_file
signal error
end
write_pos = stream(lock_list,'C','seek <1') /* set to overlay eof if present */
Remove_text = "RMTREE "Update_drive":\IBMLANLK"
RC = lineout(lock_list,Remove_text)
"echo. >> "Log_file" 2>>&1"
"echo "create_msg(MSG.65,LanLock"\"Prod_dir)" >> "Log_file" 2>>&1"
lock_string = "can't create: "
do i = 1 to Lock_lines.0
parse var Lock_lines.i junk (lock_string) Locked_filespec.i
locked_filespec.i = translate(locked_filespec.i,"\","/")
locked_file_path.i = substr(locked_filespec.i,4) /* after drive: */
/* write the locked file move stmt to update_drive:\spklock\ibmlanlk.lst */
list_text = "move "LanLock"\"locked_file_path.i" "locked_filespec.i" "
Call LINEOUT lock_list,list_text
if RESULT \= 0 then
do
failed_RC = RESULT
signal error
end
/* copy the locked file replacement to the IBMLANLK directory */
"echo "Locked_file_path.i" >> "Log_file" 2>>&1 "
"pkunzip2 -o -d "Source_Path"\"SPak".SPK "LanLock" "Locked_file_path.i" >> NUL 2>>&1 "
if RC \= 0 then
do
failed_RC = RC
signal error
end
end /* end locked file loop */
/* write eof and close file */
call charout lock_list,eof
if RESULT \= 0 then
do
failed_rc = RESULT
signal error
end
out_file = stream(lock_list,'c','close')
if out_file \= "READY:" then
do
failed_RC = out_file
signal error
end
/* Update Config.sys with IBMLANLK.SYS and RUN IBMLANLK.EXE stmts */
/* call ecfg config.sys */
/* if RESULT \= 0 then */
/* do */
/* failed_RC = RESULT */
/* signal error */
/* end */
Reboot_required = "FE00"
final_rc = Reboot_required
say
say
say "DISKETTE" msg.67
say
say " After reboot from diskettes, please manually accomplish "
say " the MOVE command contained in the \SPKLOCK\IBMLANLK.LST, "
say " then erase all SPKLOCK related files. "
say
"echo. >> "Log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
"echo DISKETTE "msg.67" >> "log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
"echo After reboot from diskettes, please manually accomplish >> "log_file" 2>>&1"
"echo the MOVE command contained in the \SPKLOCK\IBMLANLK.LST, >> "log_file" 2>>&1"
"echo then erase all SPKLOCK related files. >> "log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
"echo. >> "Log_file" 2>>&1"
signal Done
/*****************************************************************/
/* 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,VARIABLE.1,VARIABLE.2
percent = "%"
parse var message part1 (percent) part2 (percent) part3
parse var part2 part2n 2 part2t
parse var part3 part3n 2 part3t
RETURN PART1 || VARIABLE.part2n || PART2T || VARIABLE.part3n || PART3T
/*********************************************************************/
/* Help panel */
/*********************************************************************/
syntax:
say " "
say " "Create_MSG(MSG.28,Prod_id.1)" "
say " "
say " "MSG.29" "
say " "
say " "MSG.30" "
say " "Create_MSG(MSG.31,'\OS2\INSTALL')" "
say " "
say " "MSG.92" "
say " "Create_MSG(MSG.31,'\'Prod_dir)" "
say " "
say " "Create_MSG(MSG.33,SPak'.SPK')" "
say " "Create_MSG(MSG.10,SPak'.SPK')" "
say " "
say " "MSG.34" "
say " "Create_MSG(MSG.35,Backup_dir)" "
say " "MSG.72" "
say " "Create_MSG(MSG.13,Backup_size)" "
say " "
say " "MSG.36" "
say " "MSG.37" "
say " "
say " "
say " "MSG.38" "
say " "Prod_id.1" /S:C:\service\"SPak" /T:c /B:c /K:c:\"prod_dir"\bak /V:1"
say " "MSG.68" "
say " "MSG.39" "
say " "
say " "
signal END
END:
'erase 'Prod_id_tmp' >>NUL 2>>&1'
'erase 'SPak_vew' >>NUL 2>>&1'
'erase 'SPak_fnd' >>NUL 2>>&1'
EXIT x2d(final_rc)