home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
lan
/
21ripl.zip
/
IBMLS.ZIP
/
RPLSETD.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-05-28
|
54KB
|
1,576 lines
/*****************************************************************************/
/* RPLSETD.CMD - REXX program to convert an existing OS/2 Remote IPL client */
/* to use the 32-bit VGA, XGA, and 8514 device drivers. */
/* */
/* Copyright: (C) Copyright IBM Corp. 1993 */
/* */
/* External rexx procedures used: RPLUCC20.CMD */
/* RPLUCFIT.CMD */
/* RPLSDMSG.CMD */
/* */
/* External EXE file used: RPLRXUTL.EXE */
/* */
/* Note 1: Most variables are global to all subroutines. */
/* */
/* Note 2: All NLS message strings are centrally located in the */
/* external rexx procedure RPLSDMSG.CMD. */
/* */
/* Note 3: This procedure must also be compatable with OS/2 1.30.2. */
/* For this reason, none of the OS/2 2.0 unique rexx function */
/* calls can be used. */
/* */
/*****************************************************************************/
driver = ''
client = ''
Logfile = ''
Rspfile = ''
os2csdlevel = ''
Bustype = ''
swaptarget = ''
lantype = ''
inputcurOS2 = ''
inputnewOS2 = ''
defcurrentOS2 = ''
defnewOS2 = 'OS2.21'
currentOS2 = ''
newOS2 = 'OS2.21'
CRLF = '0A0D'X
nulsufix = '1>nul 2>nul'
ERROR_INFO_type = 1
SYNTAX_type = 2
changeOS2 = 0
basedevflag = 1
clientlist.0 = 0
msgdata = ''
syntaxhelpflag = 0
/* initialize NLS error and informational message strings */
Call Initialize_NLS_Messages
Parse Arg parm.1 parm.2 parm.3 parm.4 parm.5 parm.6 parm.7 parm.8 .
/* Check for help request (parm.1 = ? or '') */
If parm.1 = '?' | parm.1 = '' Then Call Syntax_Help
Call Process_Input_Parameters
If result <> 0 Then Call Error_Exit
/* if logfile specified, delete old log file (if it exists) & log header */
If Logfile <> '' Then Do
Call Delete_File Logfile
msgdata = 'RPLSETD ' || message.3 || Date('U') Time()
Call Lineout Logfile, msgdata
If result <> 0 Then Do
Say message.4 || Logfile
exit 4
end
Call Lineout Logfile, ' '
end
/* if necessary, verify existance of response file */
If Rspfile <> '' Then Do
If File_Exist(Rspfile) = 0 Then Do
/* response file not found */
Call Display_Log_Msg Rspfile || message.10, ''
end
end
Call Determine_RIPL_Directory
If result <> 0 Then Call Error_Exit
/* get LAN Server version */
Call Get_LAN_Server_Version
if result <> 0 Then Exit
/* build list of directories in RPL\IBMCOM to process */
lanlist.0 = 6
lanlist.1 = 'TOKENRNG'
lanlist.2 = 'ETHERNET'
lanlist.3 = 'PCNETA'
lanlist.4 = 'PCNET'
lanlist.5 = 'ELNKII'
lanlist.6 = 'ELNKMC'
datainput = 1
Do while datainput = 1
If Rspfile <> '' Then Do
Call Read_Rspfile
If result > 2 Then Do
msgdata = errprefix || message.1 Rspfile || CRLF || message.2
Call Display_Log_Msg msgdata, ''
Call Error_Exit
end
else If result = 2 Then Leave /* no more input */
end
else datainput = 0 /* only process command line inputs */
/* was required parameter entered? */
If clientlist.0 = 0 Then Do
Call Display_Log_Msg errprefix || message.30, ''
Call Error_Exit
end
/* was at least one other parameter entered? */
If clientlist.0 <> 0 Then Do
If driver = '' & Bustype = '' & swaptarget = '' & inputnewOS2 = '' Then Do
Call Display_Log_Msg errprefix || message.31, ''
Call Error_Exit
end
end
/* if currentOS2 entered, make sure newOS2 was also */
If inputcurOS2 <> '' Then Do
If inputnewOS2 = '' Then Do
Call Display_Log_Msg errprefix || message.26
Call Error_Exit
end
end
If Bustype <> '' Then Do
Call Validate_Bustype
If result <> 0 Then Call Error_Exit
end
If swaptarget <> '' Then Do
Call Validate_swaptarget
If result <> 0 Then Call Error_Exit
end
/* If OS/2 2.1 is in RIPL tree, check to see if 2.1 migration has been run. */
If version21 = 1 & File_Exist(rpldir'\RPLMIG21.$$$') = 0 Then Do
msgdata = errprefix || message.23
Call Display_Log_Msg msgdata, ''
Call Error_Exit
end
do clnum = 1 to clientlist.0
/* update each client in list */
client = clientlist.clnum
/* verify client does exist by checking for FIT file */
If client <> 'DEFALT20' Then Do
If File_Exist(rpldir'\FITS\'client'.FIT') = 0 Then Do
Call Display_Log_Msg errprefix || client || message.24, ''
return 2
end
end
/* get client bootdrive id and target OS */
Call get_client_bootdrv_target_OS(client)
rcode = 0
/* check for DEFALT21 */
If client = 'DEFALT21' Then Do
Call Display_Log_Msg errprefix || message.36, ''
rcode = 4
end
else Do
/* if current OS not specified, use OS of client */
If currentOS2 = '' Then currentOS2 = clientOS2
else Do
/* current OS is specified, does it match OS of client */
If currentOS2 <> clientOS2 Then Do
/* does not match, display error */
msgdata = errprefix || message.33
Call Display_Log_Msg msgdata, currentOS2, clientOS2, client
rcode = 4
end
end
end
If rcode = 0 Then Do
If currentOS2 = 'OS2' Then Do
/* 1.3.2 client, can not upgrade 1.3.2 clients */
Call Display_Log_Msg errprefix || client || message.35, ''
rcode = 4
end
else Do
/* if new OS specified, check for attempt to downgrade from 2.1 */
If changeOS2 = 1 Then Do
If clientOS2 = 'OS2.21' & newOS2 <> 'OS2.21' Then Do
/* downgrade from 2.1 is not allowed */
msgdata = errprefix || client || message.32
Call Display_Log_Msg msgdata, ''
rcode = 4
end
end
end
If rcode = 0 Then Do
/* get version of OS/2 in target OS/2 RIPL directory */
Call Get_RIPL_OS2_Version
if result = 0 Then Do
If driver <> '' Then Do
/* validate driver ids */
Call Validate_Display_DriverID
If result <> 0 Then rcode = result
else Do
/* determine if desired device driver is installed */
If changeOS2 = 1 Then ddpath = rpldir'\'newOS2'\OS2\DLL\'
else ddpath = rpldir'\'currentOS2'\OS2\DLL\'
filename = ddpath||driver||'.DLL'
if File_Exist(filename) = 0 Then Do
ddpath = substr(ddpath, 1, length(ddpath) - 1)
msgdata = errprefix || message.5
Call Display_Log_Msg msgdata, driver, ddpath
rcode = 4
end
end
end
If rcode = 0 Then Do
/* all inputs okay, update client files */
If Rspfile <> '' Then Do
/* display response file inputs */
msgdata = '/C:'client ' /D:'driver ' /O:'inputcurOS2 ' /N:'inputnewOS2,
' /B:'Bustype ' /S:'swaptarget
Call Display_Log_Msg msgdata, ''
end
Call Update_Client_Files
end
end
end
end
end
end
If Logfile <> '' Then Call Lineout Logfile
If Rspfile <> '' Then Call Lineout Rspfile
exit
/* end of main routine */
/*************** Start of subroutines ***************************/
/* Subroutine Error_Exit */
/* This subroutine cleans up on an error exit. */
Error_Exit:
If Logfile <> '' Then Do
Call Lineout Logfile
Say message.7 || Logfile
end
If Rspfile <> '' Then Call Lineout Rspfile
exit 4
/* Subroutine Get_LAN_Server_Version */
/* This subroutine determines the version of LAN Server installed on */
/* the Remote IPL server. */
Get_LAN_Server_Version:
/* Read the first 60 bytes of SYSLEVEL.SRV and check the current server level*/
filename = lanpath'\SYSLEVEL.SRV'
syslevel = ''
/* read syslevel file, try to get it with a single linein call */
syslevel = Linein(filename)
Call Lineout filename /* close file */
If Length(syslevel) < 60 Then Do
/* single linein did not get enought of file, get syslevel */
/* character at a time */
syslevel = ''
Do i = 1 to 60
syslevel = syslevel || charin(filename)
end
Call Charout filename
end
verp = pos('IP', syslevel)
If verp <> 0 Then LS_version = substr(syslevel, verp+3, 4)
If LS_version = '' Then Do
msgdata = errprefix || message.8
Call Display_Log_Msg msgdata, ''
return 4
end
return 0
Get_RIPL_OS2_Version:
/* Read the first 60 bytes of RIPL SYSLEVEL.OS2 and get the current */
/* OS/2 CSD level and version id */
If changeOS2 = 1 Then spath = rpldir'\'newOS2
else spath = rpldir'\'currentOS2
filename = spath'\OS2\INSTALL\SYSLEVEL.OS2'
syslevel = ''
If File_Exist(filename) = 1 Then Do
/* read syslevel file, try to get it with a single linein call */
syslevel = Linein(filename)
Call Lineout filename
If Length(syslevel) < 60 Then Do
/* single linein did not get enought of file, get syslevel */
/* character at a time */
Do i = 1 to 60
syslevel = syslevel || charin(filename)
end
Call Charout filename
end
verp = pos('XR', syslevel)
end
else verp = 0
If verp <> 0 Then os2csdlevel = substr(syslevel, verp, 8)
else os2csdlevel = unknown
If os2csdlevel = unknown | substr(os2csdlevel, 4, 4) = '2000' Then Do
msgdata = errprefix || client || message.9
Call Display_Log_Msg msgdata, spath, os2csdlevel
return 4
end
/* the following is to differentiate between 2.0+SP, 2.00.1, and 2.1 */
version21 = 0
If substr(os2csdlevel, 4, 4) = '6055' Then basedevflag = 1
else If substr(os2csdlevel, 4, 4) = '2010' & substr(syslevel, 41, 1) = '20'x,
Then basedevflag = 0
else Do
/* 2.1 or 2.0+SP2 (treat like 2.1) */
basedevflag = 1
version21 = 1
end
return 0
/* subroutine to determine bootdrive id and target OS of client */
get_client_bootdrv_target_OS:
parse arg clientname
If clientname = '' Then Do
/* no client passed, use first valid client in clientlist */
do clnum = 1 to clientlist.0
/* find first valid client in list */
clientname = clientlist.clnum
If clientname <> 'DEFALT20' Then Do
filename = rpldir'\FITS\'clientname'.FIT'
If File_Exist(filename) = 1 Then Leave
end
end
end
clientOS2 = ''
filename = rpldir'\FITS\'clientname'.FIT'
If File_Exist(filename) = 1 Then Do
/* scan FIT looking for :\OS2 entry */
Do while lines(filename) <> 0
data = translate(Linein(filename))
dpos = pos(':\OS2 ', data)
If dpos <> 0 Then Do
/* get client bootdrive id */
clientbootdrv = substr(data, dpos-1, 1)
/* extract target OS directory */
data = strip(substr(data, dpos+6))
dpos = pos('\', data)
If dpos <> 0 Then Do
clientOS2 = substr(data, 1, dpos-1);
end
else clientOS2 = data
Leave
end
end
Call Lineout filename /* close file */
end
return
/* Subroutine Update_Client_Files */
/* This subroutine calls the subroutines to update each client file. */
Update_Client_Files:
result = 0
If driver <> '' Then Do
/* update the client copy of OS2INI.20 */
Call Update_Client_Ini
If result = 0 Then Do
msgdata = client || message.11
Call Display_Log_Msg msgdata, 'OS2INI.20'
end
end
If result = 0 Then Do
If driver <> '' | Bustype <> '' | swaptarget <> '' Then Do
/* update the client CONFIG.20 file. If the client is DEFALT20, */
/* then there is special processing to update each of the master */
/* CONFIG.20 files in the RPL\IBMCOM tree. */
if client = 'DEFALT20' Then Do
/* for DEFALT20 update each of the lantype CONFIG.20 and CONFIGRI.20 files */
Do lli = 1 to lanlist.0
lantype = lanlist.lli
configfilename = rpldir'\IBMCOM\'lantype'\CONFIG.20'
If File_Exist(configfilename) <> 0 Then Do
/* a CONFIG.20 file is present, update it */
/* Call Update_Client_Config_20 */
Call RPLUCC20.CMD driver,client,Bustype,swaptarget,rpldir,lantype,version21,basedevflag
If result = 0 Then Do
msgdata = lantype || message.11
Call Display_Log_Msg msgdata, 'CONFIG.20'
end
else Do
If result = 2 Then Do
/* could not update to 3.0 format */
msgdata = errprefix || message.16
Call Display_Log_Msg msgdata, rpldir, lantype
end
else Do
msgdata = errprefix || client || lantype || message.12
Call Display_Log_Msg msgdata, 'CONFIG.20'
end
end
end
configfilename = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
If File_Exist(configfilename) <> 0 Then Do
/* a CONFIGRI.20 file is present, update it */
Call Update_Client_Configri_20
If result = 0 Then Do
msgdata = lantype || message.11
Call Display_Log_Msg msgdata, 'CONFIGRI.20'
end
else Do
msgdata = errprefix || client || lantype || message.12
Call Display_Log_Msg msgdata, 'CONFIGRI.20'
end
end
end
end
else Do
/* not the DEFALT20 client */
/* Update the RIPL Client Config.20 */
Call RPLUCC20.CMD driver,client,Bustype,swaptarget,rpldir,lantype,version21,basedevflag
If result = 0 Then Do
msgdata = client || message.11
Call Display_Log_Msg msgdata, 'CONFIG.20'
end
else Do
If result= 2 Then Do
/* could not update to 3.0 format */
msgdata = errprefix || message.16
Call Display_Log_Msg msgdata, rpldir, lantype
end
else Do
msgdata = errprefix || client || message.12
Call Display_Log_Msg msgdata, 'CONFIG.20'
end
end
Call Update_Client_Configri_20
If result = 0 Then Do
msgdata = client || message.11
Call Display_Log_Msg msgdata, 'CONFIGRI.20'
end
else Do
msgdata = errprefix || client || message.12
Call Display_Log_Msg msgdata, 'CONFIGRI.20'
end
end
end
If driver <> '' | changeOS2 = 1 Then Do
/* Call RPLUCFIT to update the client.FIT file */
Call RPLUCFIT.CMD client, rpldir, driver, Bustype, currentOS2, ,
newOS2, changeOS2, clientbootdrv, version21
If result = 0 Then Do
msgdata = client||message.13
Call Display_Log_Msg msgdata, ''
end
else If result = 2 Then Do
/* ignore return code 2 case, FIT did not need updating */
nop
end
else Do
/* error updating client fit */
msgdata = errprefix || client || message.14
Call Display_Log_Msg msgdata, ''
end
end
/* if OS/2 2.1 and if client copy of SYSTEM.INI and PROGMAN.INI is */
/* old format, copy new format INI and GRP files to client tree */
If version21 = 1 Then Do
srcpath = rpldir'\'newOS2'\OS2\MDOS\WINOS2\'
trgpath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
If File_Exist(trgpath'SYSTEM.INI') = 0 Then Do
/* assume *.INI, *.GRP, or directories do not exist, set up to */
/* copy masters from OS2.21 directory tree */
dpos = 0
backup = 0
end
else Do
/* file exists, check to see if SYSTEM.INI is old or new format */
srcfile = trgpath'SYSTEM.INI'
dpos = 0
Do while lines(srcfile) <> 0
data = translate(linein(srcfile))
dpos = pos('[XGA_DISPLAY]', data)
If dpos <> 0 Then Leave
end
Call Lineout srcfile
backup = 1
end
If dpos = 0 Then Do
/* old format, must replace all *.INI and *.GRP with 2.1 versions */
srcfile = srcpath'*.INI'
srcfile2 = trgpath'*.INI'
trgfile2 = substr(srcfile2, 1, length(srcfile2)-3) || 'IBK'
If backup = 1 Then Do
/* backup originals */
'@COPY 'srcfile2 trgfile2 nulsufix
end
/* copy new INI files to RPLUSER\client tree */
'@XCOPY 'srcfile trgpath nulsufix
srcfile = srcpath'*.GRP'
srcfile2 = trgpath'*.GRP'
trgfile2 = substr(srcfile2, 1, length(srcfile2)-3) || 'GBK'
If backup = 1 Then Do
/* backup original */
'@COPY 'srcfile2 trgfile2 nulsufix
end
/* copy new GRP files to RPLUSER\client tree */
'@XCOPY 'srcfile trgpath nulsufix
/* display information message */
Call Display_Log_Msg message.34, ''
end
end
If driver <> '' | swaptarget <> '' Then Do
If version21 = 1 Then Do
/* update client SYSTEM.INI file to use correct display */
/* settings and PagingFile target */
Call Update_SYSTEM_INI
If result = 0 Then Do
msgdata = client || message.11
Call Display_Log_Msg msgdata, 'SYSTEM.INI'
end
else Do
msgdata = errprefix || client || message.12
Call Display_Log_Msg msgdata, 'SYSTEM.INI'
end
If driver <> '' Then Do
/* update client PROGMAN.INI file to use correct display */
/* settings and bootdrive */
Call Update_PROGMAN_INI
If result = 0 Then Do
msgdata = client || message.11
Call Display_Log_Msg msgdata, 'PROGMAN.INI'
end
else Do
msgdata = errprefix || client || message.12
Call Display_Log_Msg msgdata, 'PROGMAN.INI'
end
end
end
end
If client <> 'DEFALT20' Then Do
/* not DEFALT20, check for RPL.MMAP update */
If changeOS2 = 1 Then Do
/* update workstation record in RPL.MAP */
Call Update_Workstation_Record
If result = 0 Then Do
msgdata = client||message.27
Call Display_Log_Msg msgdata, ''
end
else Do
/* error updating workstation record */
msgdata = errprefix||client||message.28
Call Display_Log_Msg msgdata, ''
end
end
end
end
else Do
/* INI update failed, skip CONFIG.20, FIT, RPL.MAP update & INI copy */
msgdata = errprefix || client || message.15 || client '.'
Call Display_Log_Msg msgdata, ''
end
msgdata = ' '
Call Display_Log_Msg msgdata, ''
return 0
/* Subroutine Update_Client_Ini */
/* This subroutine updates the OS2INI.20 file for a client workstation */
/* to add the required profile data to support the specified device driver. */
Update_Client_Ini:
rc = 0
/* build fully qualified path name for OS2INI.20 */
ininame = lanpath'\RPLUSER\'client'\OS2\OS2INI.20'
/* OS2 may leave INI files read-only, play safe, remove read-only attributes */
'@ATTRIB -r 'ininame'OS2*.20 1>nul'
/* Execute RPLRXUTL to update client copy of OS2.INI (OS2INI.20) */
'@RPLRXUTL.EXE /D:'driver ' /C:'ininame '1>nul'
return rc
/* Subroutine Update_Client_Configri_20 */
/* This subroutine creates a new CONFIGRI.20 for the client that has the */
/* appropriate family 1/family 2 statements enabled/disabled (if /B */
/* specified). If also will add the DRIVER=x:\OS2\TESTCFG.SYS statement */
/* if it is missing. */
Update_Client_Configri_20:
/* build fully qualified path names for client CONFIGRI.20 */
If client = 'DEFALT20' Then Do
/* DEFALT20 is special case, it must be called for each lantype */
configname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20T'
bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20B'
end
else Do
configname = rpldir'\MACHINES\'client'\CONFIGRI.20'
tmpconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20T'
bakconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20B'
end
/* delete temp file names */
Call Delete_File tmpconfigname
Call Delete_File bakconfigname
If File_Exist(configname) = 1 Then Do
tmpbustype = Bustype
If tmpbustype = 'EISA' Then tmpbustype = 'ISA'
/* copy records looking for TESTCFG.SYS statement */
dpos = copy_records_until_str(configname, tmpconfigname, 'SET PATH=')
If dpos <> 0 Then Do
/* get bootdrive id from SET PATH statement */
dpos = pos(':\OS2;', ucdata)
if dpos <> 0 Then riclientbootdrv = substr(ucdata, dpos-1, 1)
Call Lineout tmpconfigname, data
end
flag = 0
do until lines(configname) = 0
data = linein(configname)
ucdata = translate(data)
If tmpbustype <> '' Then Do
/* check for family 1/family 2 BASEDEV statements */
dpos = pos('BASEDEV=', ucdata)
If dpos <> 0 Then Do
basedev = word(substr(ucdata, dpos+8), 1)
If basedev = 'PRINT01.SYS' | basedev = 'IBM1FLPY.ADD' |,
basedev = 'IBM1S506.ADD' Then Do
/* enable/disable family one */
Call enable_disable_record tmpbustype, 'ISA', 'REM '
end
else If basedev = 'PRINT02.SYS' | basedev = 'IBM2FLPY.ADD' |,
basedev = 'IBM2SCSI.ADD' Then Do
/* enable/disable family 2 */
Call enable_disable_record tmpbustype, 'MCA', 'REM '
end
end
end
/* check for DEVICE statements */
dpos = pos('DEVICE=', ucdata)
If dpos <> 0 Then Do
If pos('\OS2\TESTCFG.SYS', ucdata, dpos+7) <> 0 Then Do
/* TESTCFG.SYS DEVICE statement already present */
If word(ucdata, 1) = 'REM' Then Do
/* statement REMed out, un-REM it */
newdata = substr(data, dpos)
data = newdata
end
flag = 1
end
end
Call lineout tmpconfigname, data
end
If flag = 0 Then Do
/* add DEVICE statement to end of file */
Call lineout tmpconfigname, 'DEVICE='riclientbootdrv':\OS2\TESTCFG.SYS'
end
Call Lineout tmpconfigname /* close file */
Call Lineout configname /* close file */
/* rename original CONFIGRI.20 */
'@rename 'configname' CONFIGRI.20B'
if rc = 0 Then Do
/* rename CONFIGRI.20T to be CONFIGRI.20 */
'@rename 'tmpconfigname' CONFIGRI.20'
if rc = 0 Then Do
/* delete orginal CONFIGRI.20 */
Call Delete_File bakconfigname
end
else Do
/* rename error, try to restore original */
'@rename 'bakconfigname' CONFIGRI.20'
end
end
else return 4 /* rename error */
end
else return 4 /* file not found */
return 0
/* subroutine to update client SYSTEM.INI file to change display type */
/* and/or Pagingfile path */
Update_SYSTEM_INI:
/* build path to client SYSTEM.INI file */
inipath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
srcfile = inipath || 'SYSTEM.INI'
trgfile = inipath || 'SYSTEM.TMP'
Call Delete_File trgfile
Call Delete_File inipath || 'SYSTEM.BAK'
If File_Exist(srcfile) = 1 Then Do
If driver <> '' Then Do
/* copy records looking for vga.drv statement */
dpos = copy_records_until_str( srcfile, trgfile, 'VGA.DRV')
If dpos <> 0 Then Do
/* vga.drv found */
/* process records until [keyboard] entry */
flag = 0
Do until lines(srcfile) = 0
/* bypass read on first pass, already have data */
If flag = 0 Then flag = 1
else Do
data = linein(srcfile)
ucdata = translate(data)
end
/* check for loop exit */
dpos = pos('[KEYBOARD]', ucdata)
If dpos <> 0 Then Do
Call Lineout trgfile, data
Leave
end
dpos = pos('VGA', ucdata)
if dpos <> 0 Then Do
Call enable_disable_record driver, 'IBMVGA32', ';'
end
else Do
/* check for XGA entry */
dpos = pos('XGA', ucdata)
if dpos <> 0 Then Do
dpos = pos(' NEXT ', ucdata)
If dpos = 0 Then Do
/* not comment entry */
Call enable_disable_record driver, 'IBMXGA32', ';'
end
end
else Do
/* check for 8514 entry */
dpos = pos('8514', ucdata)
if dpos <> 0 Then Do
dpos = pos(' NEXT ', ucdata)
if dpos = 0 Then Do
/* not comment entry */
Call enable_disable_record driver, '8514_32', ';'
end
end
end
end
Call Lineout trgfile, data
end
end
end
/* if swaptarget specified, check PagingFile */
If swaptarget <> '' Then Do
/* process local pagingfile entry */
dpos = copy_records_until_str(srcfile, trgfile, 'PAGINGFILE=')
If dpos <> 0 Then Do
/* record found */
Call enable_disable_record swaptarget, 'L', ';'
end
Call Lineout trgfile, data
/* process server pagingfile entry */
dpos = copy_records_until_str(srcfile, trgfile, 'PAGINGFILE=')
If dpos <> 0 Then Do
/* record found */
Call enable_disable_record swaptarget, 'S', ';'
/* update RIPL boot drive id */
dpos = pos('=', data)
If dpos <> 0 Then Do
newdata = substr(data, 1, dpos) || clientbootdrv ||,
strip(substr(data, dpos+1))
end
end
Call Lineout trgfile, data
end
If driver <> '' Then Do
/* copy records to XGA_DISPLAY */
dpos = copy_records_until_str( srcfile, trgfile, '[XGA_DISPLAY]')
If dpos <> 0 Then Do
/* record found */
Call enable_disable_record driver, 'IBMXGA32', ';'
end
Call Lineout trgfile, data
dpos = copy_records_until_str(srcfile, trgfile, 'XGA_RES')
If dpos <> 0 Then Do
/* record found */
Call enable_disable_record driver, 'IBMXGA32', ';'
end
Call Lineout trgfile, data
end
/* copy any remaining records */
do while lines(srcfile) <> 0
data = linein(srcfile)
Call Lineout trgfile, data
end
/* close files */
Call Lineout srcfile
Call Lineout trgfile
/* rename files */
'@RENAME 'srcfile 'SYSTEM.BAK'
If rc = 0 Then Do
'@RENAME 'trgfile 'SYSTEM.INI'
If rc = 0 Then Do
Call Delete_File inipath || 'SYSTEM.BAK'
end
else Do
/* rename error, try to restore original */
'@RENAME 'inipath || 'SYSTEM.BAK SYSTEM.INI'
return 4
end
end
else return 4 /* rename error */
end
else return 4 /* file not found */
return 0
/* subroutine to update client PROGMAN.INI file to change display type */
/* and bootdrive */
Update_PROGMAN_INI:
/* build path to client PROGMAN.INI file */
inipath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
srcfile = inipath || 'PROGMAN.INI'
trgfile = inipath || 'PROGMAN.TMP'
Call Delete_File trgfile
Call Delete_File inipath || 'PROGMAN.BAK'
If File_Exist(srcfile) = 1 Then Do
/* copy records looking for vga.drv statement */
dpos = copy_records_until_str( srcfile, trgfile, 'VGA.DRV')
If dpos <> 0 Then Do
/* vga.drv found */
Call enable_disable_record driver, 'IBMVGA32', ';'
end
Call Lineout trgfile, data
/* copy records looking for xga.drv statement */
dpos = copy_records_until_str( srcfile, trgfile, 'XGA.DRV')
If dpos <> 0 Then Do
If driver = 'IBMXGA32' Then Do
/* xga.drv found, enable/disable for XGA */
Call enable_disable_record driver, 'IBMXGA32', ';'
end
else If driver = '8514_32' Then Do
/* xga.drv found, enable/disable for 8514 */
Call enable_disable_record driver, '8514_32', ';'
end
end
Call Lineout trgfile, data
/* copy records looking for [Groups] */
dpos = copy_records_until_str( srcfile, trgfile, 'GROUPS')
Call Lineout trgfile, data
/* update group records to use correct boot drive id */
do while lines(srcfile) <> 0
data = linein(srcfile)
ucdata = translate(data)
dpos = pos('GROUP', ucdata)
If dpos <> 0 Then Do
/* this may be a group record */
dpos = pos(':\OS2\', ucdata)
dpos2 = dpos
If dpos <> 0 Then Do
/* partial path data found, assume valid record */
dpos = pos('=', ucdata)
If dpos <> 0 Then Do
newdata = substr(data, 1, dpos) || clientbootdrv ||,
substr(data, dpos2)
data = newdata
end
end
end
Call Lineout trgfile, data
end
/* close files */
Call Lineout srcfile
Call Lineout trgfile
/* rename files */
'@RENAME 'srcfile 'PROGMAN.BAK'
If rc = 0 Then Do
'@RENAME 'trgfile 'PROGMAN.INI'
If rc = 0 Then Do
Call Delete_File inipath || 'PROGMAN.BAK'
end
else Do
/* rename error, try to restore original */
'@RENAME 'inipath || 'PROGMAN.BAK PROGMAN.INI'
return 4
end
end
else return 4 /* rename error */
end
else return 4 /* file not found */
return 0
/* subroutine to copy records from one file to another until a specified */
/* character string is encountered. The postion of the character string */
/* within the record is returned. */
copy_records_until_str:
parse arg srcfile1, trgfile1, teststring
Do while lines(srcfile1) <> 0
data = linein(srcfile1)
ucdata = translate(data)
tspos = pos(teststring, ucdata)
If tspos <> 0 Then Do
If pos('NEXT ', ucdata) = 0 Then Leave
else tspos = 0
end
Call Lineout trgfile1, data
end
return tspos
/* subroutine to enable/disable records based on specified criteria */
enable_disable_record:
parse arg testvar, testvalue, disablestr
lendisablestr = length(disablestr)
If testvar = testvalue Then Do
/* make sure record is enabled */
If substr(ucdata, 1, lendisablestr) = disablestr Then Do
newdata = strip(substr(data, lendisablestr+1))
data = newdata
end
end
else Do
/* make sure record is disabled */
If substr(ucdata, 1, lendisablestr) <> disablestr Then Do
data = disablestr || data
end
end
return
/* subroutine to delete a file */
Delete_File:
arg delfilename
If stream(delfilename, C, 'query exists') <> '' Then Do
'@DEL 'delfilename
end
return 0
/* subroutine to display/log messages */
/* This routine attempts to format the message line based on format */
/* controls imbedded in each line. */
Display_Log_Msg:
Parse Arg msgstring, parm.1, parm.2, parm.3, parm.4, parm.5, parm.6
if parm.1 <> '' Then Do
/* substitution data supplied */
startpoint = 1
newmsg = ''
sdpos = pos('%', msgstring, startpoint)
Do while sdpos <> 0
j = substr(msgstring, sdpos+1, 1)
newmsg = newmsg || substr(msgstring, startpoint, sdpos-startpoint) || parm.j
startpoint = sdpos+2
sdpos = pos('%', msgstring, startpoint)
end
newmsg = newmsg || substr(msgstring, startpoint)
msgstring = newmsg
end
If substr(msgstring, 1, length(errprefix)) = errprefix Then errprefixflag = 1
else errprefixflag = 0
/* display/log message 1 line at a time, max line length is 75 characters */
dataflag = 1
msgline = ''
tablength = 0
indentlength = 0
indentvalue = 0
Do while dataflag = 1
/* look for special formatting commands at start of line */
do formati = 1 to 2
testword = word(msgstring, 1)
If substr(testword, 1, 2) = '%T' Then Do
/* special tab command at start of line */
tablength = substr(testword, 3)
indentvalue = 0
/* remove tab command from line */
tabp = pos('%T', msgstring)
msgstring = strip(substr(msgstring, tabp+length(testword)+1), 'L')
end
else Do
If substr(testword, 1, 2) = '%I' Then Do
/* special indent command at start of line */
indentlength = substr(testword, 3)
/* remove indent command from line */
tabp = pos('%I', msgstring)
msgstring = strip(substr(msgstring, tabp+length(testword)+1), 'L')
end
else Leave
end
end
startscanpos = 75 - tablength - indentvalue
lenmsgstring = length(msgstring)
If lenmsgstring <> 0 Then Do
If lenmsgstring > startscanpos Then Do
/* check for CRLF in string */
crlfp = pos(CRLF, msgstring)
If crlfp <> 0 Then Do
If crlfp <= startscanpos Then Do
If crlfp <> 1 Then Do
/* force end of line at CRLF and discard CRLF */
msgline = msgline || substr(msgstring, 1, crlfp-1)
msgstring = strip(substr(msgstring, crlfp+2), 'L')
end
end
else crlfp = 0
end
If crlfp = 0 Then Do
/* find last blank prior to startscanpos */
endline = lastpos(' ', msgstring, startscanpos)
If endline > 0 Then Do
msgline = msgline || substr(msgstring, 1, endline)
msgstring = substr(msgstring, endline+1)
If substr(msgstring, 1, 2) = CRLF Then Do
/* special case, this CRLF can be ignored */
msgstring = strip(substr(msgstring, 3), 'L')
end
end
else Do
/* no space, break word */
msgline = substr(msgstring, 1, startscanpos)
msgstring = substr(msgstring, startscanpos+1)
end
end
end
else Do
/* line less than max length allowed */
crlfp = pos(CRLF, msgstring)
If crlfp <> 0 Then Do
/* get message up to CRLF, discard CRLF */
msgline = substr(msgstring, 1, crlfp-1)
msgstring = substr(msgstring, crlfp+2)
end
else Do
/* only thing left if message */
msgline = msgline || msgstring
msgstring = ''
end
end
If tablength <> 0 Then Do
/* insert required number of spaces at start of line */
msgline = copies(' ',tablength) || msgline
end
If indentvalue <> 0 Then Do
/* add in indentation value blanks */
msgline = copies(' ', indentvalue) || msgline
end
If Logfile = '' Then Do
/* display message locally */
Say msgline
If syntaxhelpflag = 1 Then Do
nummsglines = nummsglines + 1
If nummsglines >= maxmsglines Then Do
/* prompt user to press Enter to see next part of message */
Say message.22
Pull dummy .
/* clear screen */
'CLS'
Say ' ' /* dummy first line */
/* redisplay last line of last screen */
Say msgline
nummsglines = 2
end
end
If indentlength <> 0 Then Do
indentvalue = indentlength
indentlength = 0
end
end
else Do
/* log message */
Call lineout Logfile, msgline
nummsglines = nummsglines+1
end
msgline = ''
If length(msgstring) = 0 Then dataflag = 0
else Do
/* if errprefix present, insert blanks at start of next msg line */
If errprefixflag = 1 then msgline = copies(' ', length(errprefix))
end
end
else dataflag = 0
end
return 0
/* subroutine to test for existance of a file */
File_Exist:
Arg testfilename
If stream(testfilename, C, 'query exists') <> '' Then rc = 1
else rc = 0
return rc
Determine_RIPL_Directory:
/* find out where IBMLAN is installed */
os2path = value('PATH',,'OS2ENVIRONMENT')
ibmlanp = pos(':\IBMLAN', translate(os2path))
if ibmlanp = 0 Then Do
msgdata = errprefix || message.17
Call Display_Log_Msg msgdata, ''
return 4
end
landrv = substr(os2path, ibmlanp-1, 1)
lanpath = landrv':\IBMLAN'
fname = lanpath'\IBMLAN.INI'
/* read IBMLAN.INI looking for the RPLDIR entry */
do until lines(fname) = 0
data = linein(fname)
rpldirp = pos('RPLDIR', translate(data))
if rpldirp <> 0 then do
rpldirp = pos('=', data)
rpldir = strip(substr(data, rpldirp+1))
Leave
end
end
Call stream fname,C,'close'
if rpldir = '' then do
msgdata = errprefix || message.18
Call Display_Log_Msg msgdata, ''
return 4
end
return 0
/* subroutine to verify that the display driver id is valid */
Validate_Display_DriverID:
/* initialize display driver ids */
displaydrv.0 = 4
displaydrv.1 = 'IBMVGA32'
displaydrv.2 = 'IBMXGA32'
displaydrv.3 = 'IBM8514' /* 2.0+Service Pak or 2.00.1 */
displaydrv.4 = '8514_32' /* 2.1 only */
/* validate driver parameter */
flag = 0
Do i=1 to displaydrv.0
If driver=displaydrv.i Then Do
flag = 1
leave
end
end
if flag = 0 Then Do
Call Display_Log_Msg message.19, ''
return 4
end
/* if IBM8514 and OS/2 2.1, convert to 32 bit name */
If driver = 'IBM8514' & version21 = 1 Then driver = '8514_32'
return 0
/* subroutine to validate the Bustype parameter */
Validate_Bustype:
If Bustype <> 'MCA' Then Do
If Bustype <> 'ISA' Then Do
If Bustype <> 'EISA' Then Do
Call Display_Log_Msg message.6, ''
return 4
end
end
end
return 0
/* subroutine to validate the swaptarget parameter */
Validate_swaptarget:
swaptarget = translate(swaptarget)
If swaptarget <> 'L' Then Do
If swaptarget <> 'S' Then Do
Call Display_Log_Msg message.29, ''
return 4
end
end
return 0
/* subroutine to update client workstation record in RPL.MAP */
Update_Workstation_Record:
rplmap = rpldir'\RPL.MAP'
tmprplmap = rpldir'\RPLMAP.TMP'
updateerr = 0
Call Delete_File tmprplmap
Do until lines(rplmap) = 0
data = linein(rplmap)
field2 = translate(word(data, 2))
If field2 = client Then Do
/* may be a client record, check field 4 for FIT */
field4 = word(data,4)
If translate(substr(field4, 1, 5)) = 'FITS\' Then Do
/* this is an OS/2 client workstation record */
field12 = word(data, 12)
f12p = pos(field12, data)
ucnewos2 = translate(newOS2)
/* determine OS type for field 12 */
Select
when ucnewos2 = 'OS2.20' Then os2type = '20'
when ucnewos2 = 'OS2.20A' Then os2type = '20A'
when ucnewos2 = 'OS2.21' Then os2type = '21'
otherwise Do
os2type = ''
updateerr = 1
end
end
If os2type <> '' Then Do
/* update field 12 for correct OS type */
newdata = substr(data, 1, f12p+1) || os2type
f12p = pos('_', data, f12p+2)
if f12p <> 0 Then newdata = newdata || substr(data, f12p)
else Do
/* error, use original record */
newdata = data
updateerr = 1
end
data = newdata
end
end
end
Call lineout tmprplmap, data
end
Call lineout rplmap
Call lineout tmprplmap
If updateerr = 0 Then Do
/* no error, replace RPL.MAP with new RPL.MAP */
'@copy 'rplmap rpldir'\RPLMAP.BAK 1>nul 2>nul'
Call Delete_File rplmap
'@rename 'tmprplmap 'RPL.MAP 1>nul 2>nul'
end
else Do
/* update error, delete tmp file, return error */
Call Delete_File tmprplmap
return 4
end
return 0
/* subroutine to read user provided response file and set keyword variables */
Read_Rspfile:
/* reset selected variables to defaults for each new group */
driver = ''
inputcurOS2 = ''
inputnewOS2 = ''
currentOS2 = defcurrentOS2
newOS2 = defnewOS2
Bustype = ''
swaptarget = ''
/* read response file and get keyword values for next group */
keydata = 0
clientlist.0 = 0
Do while lines(Rspfile) <> 0
data = translate(linein(Rspfile))
If data <> '' Then Do
If substr(data, 1, 1) <> ';' Then Do
/* not a comment */
data = strip(data) /* eliminate any leading blanks */
If substr(data, 1, 10) = 'CLIENTLIST' | ,
substr(data, 1, 6) = 'CLIENT' Then Do
/* multiple CLIENT and/or CLIENTLIST entries are permitted */
epos = pos('=', data)
clientdata = strip(substr(data, epos+1))
cpos = pos(',', clientdata)
if cpos = 0 Then Do
/* only one client specified */
clnum = clientlist.0 + 1
clientlist.clnum = clientdata
clientlist.0 = clnum
end
else Do
/* list of clients provided */
startpoint = 1
clnum = clientlist.0 + 1
cpos = pos(',', clientdata, startpoint)
/* scan list and put each name in clientlist array */
Do while (cpos <> 0)
clientlist.clnum = strip(substr(clientdata, startpoint, cpos-startpoint))
clientlist.0 = clnum
startpoint = cpos+1
clnum = clnum + 1
cpos = pos(',', clientdata, startpoint)
end
if startpoint < length(clientdata) Then Do
/* last name in list */
clientlist.clnum = strip(substr(clientdata, startpoint))
clientlist.0 = clnum
end
end
keydata = 1
end
else If substr(data, 1, 13) = 'DISPLAYDRIVER' Then Do
epos = pos('=', data)
driver = strip(substr(data, epos+1))
keydata = 1
end
else If substr(data, 1, 13) = 'CURRENTOS2DIR' Then Do
/* optional, current OS/2 root directory parameter */
epos = pos('=', data)
currentOS2 = strip(substr(data, epos+1))
inputcurOS2 = currentOS2
changeOS2 = 1
keydata = 1
end
else If substr(data, 1, 9) = 'NEWOS2DIR' Then Do
/* optional, new OS/2 root directory parameter */
epos = pos('=', data)
newOS2 = strip(substr(data, epos+1))
inputnewOS2 = newOS2
changeOS2 = 1
keydata = 1
end
else If substr(data, 1, 7) = 'BUSTYPE' Then Do
/* Bustype parameter */
epos = pos('=', data)
Bustype = strip(substr(data, epos+1))
keydata = 1
end
else If substr(data, 1, 10) = 'SWAPTARGET' Then Do
/* swaptarget parameter */
epos = pos('=', data)
swaptarget = strip(substr(data, epos+1))
keydata = 1
end
else If substr(data,1, 12) = '[GROUP]' Then Do
/* start of new group, any keywords entered? */
If keydata = 1 Then Leave
else Do
/* no keywords, ignore entry */
nop
end
end
else Do
/* invalid entry */
msgdata = errprefix || word(data, 1) || message.25
Call Display_Log_Msg msgdata, ''
end
end
end
end
If keydata = 1 Then Do
/* at least one keyword entered */
/* check for required keywords */
If clientlist.0 = 0 Then Do
/* invalid/incomplete response file */
return 4
end
If clientlist.0 <> 0 Then Do
If driver = '' & Bustype = '' & swaptarget = '' & changeOS2 = 0 Then Do
/* invalid/incomplete response file */
return 4
end
end
end
If Lines(Rspfile) = 0 & keydata = 0 Then return 2
else return 0
/* subroutine to process command line parameters */
Process_Input_Parameters:
Do i = 1 to 8
If parm.i = '' Then Leave
parmtype = translate(substr(parm.i,1,2))
select
when parmtype = '/H' Then Call Syntax_Help
when parmtype = '/h' Then Call Syntax_Help
when parmtype = '/D' Then Do
if substr(parm.i, 3, 1) = ':' Then driver = substr(parm.i, 4)
else driver = substr(parm.i, 3)
driver = translate(driver)
end
when parmtype = '/C' Then Do
if substr(parm.i, 3, 1) = ':' Then clientdata = substr(parm.i, 4)
else clientdata = substr(parm.i, 3)
clientdata = translate(clientdata)
cpos = pos(',', clientdata)
if cpos = 0 Then Do
clientlist.0 = 1
clientlist.1 = clientdata
end
else Do
/* list of clients provided */
startpoint = 1
clnum = 1
cpos = pos(',', clientdata, startpoint)
/* scan list and put each name in clientlist array */
Do while (cpos <> 0)
clientlist.clnum = substr(clientdata, startpoint, cpos-startpoint)
clientlist.0 = clnum
startpoint = cpos+1
clnum = clnum + 1
cpos = pos(',', clientdata, startpoint)
end
if startpoint < length(clientdata) Then Do
/* last name in list */
clientlist.clnum = substr(clientdata, startpoint)
clientlist.0 = clnum
end
end
end
when parmtype = '/O' Then Do
if substr(parm.i, 3, 1) = ':' Then currentOS2 = substr(parm.i, 4)
else currentOS2 = substr(parm.i, 3)
inputcurOS2 = currentOS2
changeOS2 = 1
end
when parmtype = '/N' Then Do
if substr(parm.i, 3, 1) = ':' Then newOS2 = substr(parm.i, 4)
else newOS2 = substr(parm.i, 3)
inputnewOS2 = newOS2
changeOS2 = 1
end
when parmtype = '/L' Then Do
if substr(parm.i, 3, 1) = ':' Then Logfile = substr(parm.i, 4)
else Logfile = substr(parm.i, 3)
end
when parmtype = '/R' Then Do
if substr(parm.i, 3, 1) = ':' Then Rspfile = substr(parm.i, 4)
else Rspfile = substr(parm.i, 3)
end
when parmtype = '/B' Then Do
if substr(parm.i, 3, 1) = ':' Then Bustype = substr(parm.i, 4)
else Bustype = substr(parm.i, 3)
Bustype = translate(Bustype)
end
when parmtype = '/S' Then Do
if substr(parm.i, 3, 1) = ':' Then swaptarget = substr(parm.i, 4)
else swaptarget = substr(parm.i, 3)
swaptarget = translate(swaptarget)
end
otherwise Do
msgdata = errprefix || message.20
Call Display_Log_Msg msgdata, parm.i
return 4
end
end
end
return 0
Determine_Installed_OS2_Levels:
syslevel = '\OS2\INSTALL\SYSLEVEL.OS2'
If File_Exist(rpldir'\OS2'syslevel) = 1 Then os213 = 1
else os213 = 0
If File_Exist(rpldir'\OS2.20'syslevel) = 1 Then os220 = 1
else os220 = 0
If File_Exist(rpldir'\OS2.20a'syslevel) = 1 Then os220a = 1
else os220a = 0
If File_Exist(rpldir'\OS2.21'syslevel) = 1 Then os221 = 1
else os221 = 0
return
/* Subroutine Syntax_Help */
/* This subroutine displays the syntax help panel. */
Syntax_Help:
If Logfile = '' Then Do
'CLS'
syntaxhelpflag = 1
maxmsglines = 22
nummsglines = 0
Do i = 40 to 50
Call Display_Log_Msg message.i, ''
end
exit
end
else Do
Call Display_Log_Msg message.21, p1, p2, p3, p4, p5, p6, p7, p8
Call Error_Exit
end
Initialize_NLS_Messages:
/* call RPLNLMSG to stack all NLS messages in queue in FIFO order */
Call RPLSDMSG.CMD 1
/* extract messages from queue and assign to appropriate message string */
Pull errprefix
Pull unknown
do i = 1 to 50
Parse Pull message.i
end
/* make sure nothing else is left in queue */
do while queued()
Pull dummy
end
return