home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 29 Fixes_o
/
29-Fixes_o.zip
/
ip7005.zip
/
SRV.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1993-10-29
|
37KB
|
998 lines
/****************************************************************************
Module Name = SRV.CMD
Descriptive Name = Select Pak IP07005 ( LAN Server )
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 = "SRV" /* extension for syslevel files */
Prod_dir = "IBMLAN"
Prod_title = "MSG.86"
SPak = "IP07005"
Backup_size = '170k'
subdirs.0 = '2' /* number of subdirectories in product */
subdirs.1 = 'IBMLAN' /* subdirectories in product */
subdirs.2 = 'SERVICES'
subdirs.3 = 'IBMLAN\SERVICES'
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 var5 var6 rest
/***********************************************************/
/* 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,prod_id.1),80)
say
say " Please shut down LAN Server before applying this SelectPak "
say " ( Ctrl_Break, then Enter to exit ) "
say
say
Source_path = ""
Base_Drive = ""
Update_Drive = ""
RPL_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 = var6
token.7 = rest
do i = 1 to 7 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) = "/D:" then
RPL_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.09" "
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
/******************************************************/
/* The RPL Drive letter is the letter of the Drive */
/* containing the RPL directory to be upgraded */
/******************************************************/
get_RPL_Drive:
if RPL_Drive \= "" then signal got_RPL_Drive
call charout ," "MSG.75" "
parse upper linein RPL_Drive
got_RPL_Drive:
if RPL_Drive = 0 then signal Get_Backup
if RPL_Drive = "" then signal get_RPL_Drive
RPL_drive = STRIP(RPL_drive,T,':') /* remove trailing colon */
/*************************************************/
/* Verify that the Product directory exists */
/* on the drive specified by the user */
/*************************************************/
RPL_Path = RPL_drive':\IBMLAN\RPL\'subdirs.3
"dir "RPL_Path" > NUL 2>>&1"
if RC \= 0 then
do
say
say " "Create_MSG(MSG.05,RPL_Path)" "
RPL_Drive = ""
signal get_RPL_Drive
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 RPL path for update data */
/***********************************************************/
if RPL_Drive = 0 | RPL_Drive = "" then
say " RIPL is not installed. "
else
say " RPL_Path is" RPL_Path
/***********************************************************/
/* 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 = ""
RPL_Drive = ""
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
'dir 'syslvl.k' >> NUL 2>>&1 '
if rc \= 0 then /* skip this syslevel if not present */
do
syslvl.k = ''
say " This Selectpak has a prereq to "
say " LS3.0 Server with server level 7001 "
say " which is not installed ... Quitting "
signal end
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,prod_msg)
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 *.exe >> "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":\ "subdirs.3"\*.* >> "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 Unzip_RPL
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 Unzip_RPL
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:
/**********************************************************************/
/* Update SYSLEVEL files to indicate a select pak has been applied */
/**********************************************************************/
do k = 1 to syslvl_prefix.0
if syslvl.k = '' then iterate /* skip unapplied syslevel */
"echo. >> "Log_file" 2>>&1"
say create_msg(MSG.24,prod_id.k)
"echo "create_msg(MSG.24,prod_id.k)" >> "Log_file" 2>>&1"
"attrib -r "syslvl.k" > NUL 2>>&1"
parse var firstline.k 1 before 48 csd_num 52 more
csd_num = '7005'
new_first = before||csd_num||more
sys_rc = lineout(syslvl.k,new_first,1)
"attrib +r "syslvl.k" > NUL 2>>&1"
if sys_rc \= 0 then
do
failed_rc = sys_rc
signal error
end
end /* do */
if RPL_Drive = 0 | RPL_Drive = "" then signal Donesrv
else do
syslvl.k = Rpl_Drive":\IBMLAN\RPL\IBMLAN\SYSLEVEL.SRV"
"attrib -r "syslvl.k" > NUL 2>>&1"
sys_rc = lineout(syslvl.k,new_first,1)
"attrib +r "syslvl.k" > NUL 2>>&1"
if sys_rc \= 0 then
do
failed_rc = sys_rc
signal error
end
end /* do */
Donesrv:
/* The installation is now complete, inform the user and exit */
say
say center(Create_MSG(MSG.88,SPak),80)
say
"echo "create_msg(MSG.88,SPak)" >> "log_file" 2>>&1"
say
call charout ," "MSG.89" "
say
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
Unzip_RPL:
if RPL_Drive = 0 | RPL_Drive = "" then signal Done
else do
/***********************************************************/
/* Unzip the files into RPL directory */
/***********************************************************/
say
Prod_id_tmp2 = Update_drive":\"Prod_dir"\"SPak".tm2"
"PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "RPL_Drive":\IBMLAN\RPL\ "subdirs.3"\*.* >> "Prod_id_tmp2" "
zip_rc2 = RC
"echo. >> "Log_file" 2>>&1"
"echo "create_msg(MSG.64,RPL_Path) " >> "Log_file" 2>>&1"
"copy "Log_file" + "Prod_ID_tmp2" "Log_file" >> NUL " /* append to log file */
if RC \= 0 then
do
failed_RC = RC
signal error
end
select
when Zip_RC2 = 11 then
do
say
say " "Create_MSG(MSG.21,RPL_path)" "
signal Done
end
when Zip_RC2 = 10 then
do
failed_RC = Zip_RC2
signal error
end
when Zip_RC2 = 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_RC2
say MSG.22
say Create_MSG(MSG.23,LOG_file)
say
end
end /* select */
signal DONE
end /* Do UNZIP for RPL */
/*****************************************************************/
/* 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 MSG.67
say
"echo "msg.67" >> "log_file" 2>>&1"
signal Unzip_RPL
/*****************************************************************/
/* 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.32" "
say " "Create_MSG(MSG.31,'\'Prod_dir)" "
say " "
say " "MSG.76" "
say " "Create_MSG(MSG.31,'\IBMLAN\RPL\'Prod_dir)""
say " "MSG.77" "
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 /D:c /B:c /K:c:\"prod_dir"\bak /V:1"
say " "MSG.68" "
say " "MSG.39" "
say " "
say " "
signal END
ecfg:
/******************************************************************/
/* This routine will update CONFIG.SYS */
/* with IBMLANLK.SYS and RUN IBMLANLK.EXE stmts */
/******************************************************************/
parse arg file_in
Source_config = Base_drive":\"file_in
found = '1'
/* determine number for Config.sys backup */
do num = 0 to 999 until found = '0'
if num < 10 then
config_name = Base_drive':\CONFIG.00'||num
else if num > 100 then
config_name = Base_drive':\CONFIG.'||num
else config_name = Base_drive':\CONFIG.0'||num
"dir "config_name" >> NUL 2>>&1"
if rc \= 0 then
found = '0'
end /* do */
'copy 'Source_config' 'config_name' >>NUL 2>>&1 '
if rc = 0 then
do
say
say create_msg2(MSG.66,Source_config,config_name)
say
"echo. >> "Log_file" 2>>&1"
"echo "create_msg2(MSG.66,Source_config,config_name) " >> "Log_file" 2>>&1"
end
else
do
failed_rc = rc
signal error
end
/* read in target file */
i = 0
do while lines(Source_config) /* for all lines of Config.sys */
i = i + 1 /* get line in */
Target.i = linein(Source_config) /* Target. stem */
end
Target.0 = i /* Target.0 = # of lines */
rc = stream(Source_config,'C','CLOSE')
/* is new line already there? */
Line1 = "DEVICE="lock_path"\IBMLANLK.SYS "lock_list" "
exist1 = Whereis(Line1,'F') /* If this line exists and */
Line2 = "RUN="lock_path"\IBMLANLK.EXE "lock_list" "
exist2 = Whereis(Line2,'F') /* If this line exists and */
/* add locked file device driver after 1st IFS stmt or before 1st device stmt */
if exist1 \= '' then
do
after = exist1
signal Process_run
end
bstr = "IFS="
after = Whereis(bstr,'F') /* else get # of 1st */
parse var after after . /* line with this id. */
if after = '' then /* no IFS= found */
do
bstr = "DEVICE=" /* search for DEVICE= */
after = Whereis(bstr,'F') /* get # of 1st */
parse var after after . /* line with this id. */
if after ='' then /* no Device= found */
do
after=0 /* else add to top */
end
else
do /* Device stmt found */
after=max(0,after-1) /* Device= found in"after"*/
if after \= -1 then
do
call insert after Line1 /* add the line before */
after = after + 1 /* for run after device */
end
else signal error
end /* end Device stmt found */
end /* end no IFS= found */
else
do /* IFS stmt found */
after=max(0,after) /* IFS= found in"after" */
if after \= -1 then
do
call insert after Line1 /* add the line after */
after = after + 1 /* for run after device */
end
else signal error
end /* end IFS stmt found */
/* add run statement following Device statement */
Process_run:
if exist2 \= '' then signal END_ECFG
call insert after Line2 /* add run after device */
signal END_ECFG
/******************************************************************/
/* Insert a line in Target file (stem) after line number i. */
/******************************************************************/
Insert: procedure expose Target.
parse arg i string
if i = Target.0 then k = Target.0 + 1
else do /* move lines below insert down 1 */
do j = Target.0 to i+1 by -1
k = j + 1
Target.k = Target.j
end
k = i + 1
end
Target.k = string
Target.0 = Target.0 + 1
/* say 'Inserted line' k ': "'Target.k'"' */
return
/******************************************************************/
/* Searches All or First or Last lines in Target starting */
/* with string. Returns the line number(s) found. */
/******************************************************************/
Whereis: procedure expose Target.
parse arg string,direction
stringlength=length(string)
ret = ''
do i = 1 to Target.0 by 1
T = translate(Target.i)
S = translate(string)
if left(T,stringlength)=S then
do
ret = ret i
if direction \= 'A' then leave
end
end
return ret
/******************************************************************/
/* Update Target file from Target. stem. */
/******************************************************************/
SaveFile:
'erase' Source_config
src = rc
if src = 0 then do
do i = 1 to Target.0
out = lineout(Source_config,Target.i)
end
rc = stream(Source_config,'C','CLOSE')
end
return src
/******************************************************************/
/* Save and return */
/******************************************************************/
END_ECFG:
src = SaveFile()
Return src
END:
'erase 'Prod_id_tmp' >>NUL 2>>&1'
'erase 'Prod_id_tmp2' >>NUL 2>>&1'
'erase 'SPak_vew' >>NUL 2>>&1'
'erase 'SPak_fnd' >>NUL 2>>&1'
EXIT x2d(final_rc)