home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
lansystk.zip
/
MPTSUTIL
/
APPLETS
/
CASINST.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-05-08
|
16KB
|
590 lines
/* Stripped by STRIPRX.EXE */
CASINST:
parse upper arg inparms
signal ON HALT NAME stopit
goodrc = 0
badrc = 1
stdout = "STDOUT:"
target = ""
source = ""
logfile= ""
first = ""
last = ""
writeit = 0
badparmf = 0
parse source . . srccmd
srcdrv = strip(filespec('drive',srccmd),"B","\")
srcpath = strip(filespec('path',srccmd),"B","\")
srcdir = srcdrv"\"srcpath
if srcpath <> ""
then msgfile = srcdrv||"\"||srcpath||"\CASSETUP.MSG"
else msgfile = srcdrv||"\CASSETUP.MSG"
StartingDir = Directory()
xrc = badrc
if testparms() = goodrc THEN do
if testenv() = goodrc THEN do
if chkdrive() = goodrc THEN do
if installit() = goodrc THEN do
xrc = UpdateConfigSys()
end
end
end
end
"@ERASE " errfile ">NUL 2>NUL"
if logfile <> stdout & logfile <> "" then
rc = stream(logfile,'c','close')
CALL Directory(savetardir)
CALL DIRECTORY StartingDir
exit xrc
TESTPARMS:
xrc = 0
inparms = strip(inparms,"B")
if inparms = "?" | inparms = "/?" then signal givehelp
rc = RxFuncAdd("SYSLOADFUNCS","REXXUTIL","SYSLOADFUNCS")
rc = SysLoadFuncs()
syslvl = SysOS2Ver()
head = "--------------------------------------------------------------------"
if syslvl = "" then do
rc = lineout(logfile,head)
rc = lineout(logfile," Date: "date("L")" Time:" time())
rc = lineout(logfile,"Unable to load RexxUtils which is required for the install.")
rc = lineout(logfile,"Terminating install processing.")
rc = lineout(logfile,head)
return badrc
end
parmt_ckt = 0
parms_ckt = 0
parml_ckt = 0
DO WHILE badparmf<>1 & inparms <> ""
PARSE VAR inparms iphead inparms
badparms = iphead
iphead = TRANSLATE(iphead)
sep = SUBSTR(iphead,3,1)
IF sep <> ":" & sep <> "=" THEN
DO
badparmf = 1
ITERATE
END
SELECT
WHEN LEFT(iphead,2) = "/T" THEN
DO
parmt_ckt = parmt_ckt+1
target = SUBSTR(iphead,4)
IF target = "" | target = "\" | target = " " THEN
badparmf = 1
END
WHEN LEFT(iphead,2) = "/S" THEN
DO
parms_ckt = parms_ckt+1
source = SUBSTR(iphead,4)
IF source = "" | source = "\" | source = " " THEN
badparmf = 1
END
WHEN LEFT(iphead,2) = "/L" THEN do
parml_ckt = parml_ckt+1
logfile = SUBSTR(iphead,4)
end
OTHERWISE
badparmf = 1
END
END
if parml_ckt > 1 then do
badparmf = 1
badparms = "Multiple /L= parameters"
end
if parms_ckt > 1 then do
badparmf = 1
badparms = "Multiple /S= parameters"
end
if parmt_ckt > 1 then do
badparmf = 1
badparms = "Multiple /T= parameters"
end
IF logfile = "" THEN
logfile = stdout
xrc = stream(logfile,'c','open write')
if xrc <> "READY:" then do
say "Unable to open logfile ("logfile")."
say "Return code from open file attempt ("xrc")".
logfile = ""
return badrc
end
IF badparmf <> 1 THEN do
source = STRIP(source,'t','\')
target = STRIP(target,'t','\')
IF source = "" THEN
source = STRIP(srcdir,'t','\')
IF target = "" THEN
target = source
IF IsFullyQualifiedPath(source,0) = 0 THEN
DO
CALL LINEOUT logfile, "Bad Source parameter."
badparmf = 1
badparms = "/S="source
RETURN goodrc
END
IF IsFullyQualifiedPath(target,1) = 0 THEN
DO
CALL LINEOUT logfile, "Bad Target parameter."
badparmf = 1
badparms = "/T="target
RETURN goodrc
END
qrc = SysFileTree(source||"\*.*","stemv","F")
if stemv.0 = 0 then do
CALL LINEOUT logfile,"No files found in source directory."
badparmf = 1
badparms = "/S="||strip(source,"T","\")
end
end
return goodrc
IsFullyQualifiedPath: PROCEDURE
parse arg pathname,create
ThisDir = DIRECTORY()
IF DATATYPE(SUBSTR(pathname,1,1),"M") = 0 THEN
RETURN 0
IF SUBSTR(pathname,2,1) <> ":" THEN
RETURN 0
IF LENGTH(pathname) > 2 & SUBSTR(pathname,3,1) <> "\" THEN
RETURN 0
IF LENGTH(pathname) = 2 THEN
pathname = pathname"\"
IF create = 1 THEN
CALL CreateDir pathname
PathDrive = FILESPEC("D",pathname)
PathDriveHome = DIRECTORY(pathdrive)
NewDir = DIRECTORY(pathname)
IF TRANSLATE(pathname) <> TRANSLATE(NewDir) THEN
DO
CALL DIRECTORY PathDriveHome
CALL DIRECTORY ThisDir
RETURN 0
END
CALL DIRECTORY PathDriveHome
CALL DIRECTORY ThisDir
RETURN 1
TESTENV:
xrc = 0
dummy = Logmsg(1","msgfile)
title = LogMsg(92","msgfile)
terminate = LogMsg(94","msgfile)
rc = lineout(logfile," ")
rc = lineout(logfile," ")
rc = lineout(logfile,head)
rc = lineout(logfile," Date: "date("L")" Time: "time())
rc = lineout(logfile," "title)
rc = lineout(logfile,head)
parse var syslvl first"."level
if first < 2 then do
msg = LogMsg(93","msgfile","syslvl)
rc = lineout(logfile,msg)
msg = terminate
rc = lineout(logfile,94)
rc = lineout(logfile,head)
xrc = badrc
end
else do
if badparmf = 1 then do
msg = LogMsg(107","msgfile","badparms)
rc = lineout(logfile,msg)
rc = lineout(logfile,terminate)
rc = lineout(logfile,head)
xrc = badrc
end
end
return xrc
CHKDRIVE:
xrc = 0
drivemap = SysDriveMap()
drive = Filespec("drive",target)
parse upper var drive drive
if translate(drive) = "A:" | translate(drive) = "B:" then do
msg = LogMsg(124","msgfile","target)
rc = lineout(logfile,msg)
rc = lineout(logfile,terminate)
rc = lineout(logfile,head)
xrc = badrc
end
else do
if wordpos(drive,drivemap) = 0 | drive = "" then do
msg = LogMsg(97","msgfile","target)
rc = lineout(logfile,msg)
rc = lineout(logfile,terminate)
rc = lineout(logfile,head)
xrc = badrc
end
end
return xrc
INSTALLIT:
tardrive = FILESPEC("D",target)
savetardir = DIRECTORY(tardrive)
CALL DIRECTORY target
if logfile <> stdout then do
xpath = filespec("path",logfile)
xdrive = filespec("drive",logfile)
errfile = SysTempFileName(xdrive||xpath||"XX????.TMP")
end
xrc = 0
IF TRANSLATE(source) <> TRANSLATE(target) THEN DO
msg = LogMsg(100","msgfile)
rc = lineout(logfile,msg)
target = target"\"
source = source"\"
if logfile = stdout
then "@copy " source||"CAS*.* >>NUL"
else "@copy " source||"CAS*.* >>"errfile "2>&1"
xrc = chkcopy(rc)
if xrc = 0 then do
if logfile = stdout
then "@copy " source||"*.pro >>NUL"
else "@copy " source||"*.pro >>"errfile "2>&1"
xrc = chkcopy(rc)
if xrc = 0 then do
if logfile = stdout
then "@copy " source||"*.scr >>NUL"
else "@copy " source||"*.scr >>"errfile "2>&1"
xrc = chkcopy(rc)
if xrc = 0 then do
if logfile = stdout
then "@copy " source||"CMSGBOX.EXE >>NUL"
else "@copy " source||"CMSGBOX.EXE >>"errfile "2>&1"
xrc = chkcopy(rc)
end
end
end
END
if xrc = 0 then do
msg = LogMsg(101","msgfile)
rc = lineout(logfile,msg)
keypath = target
keypath = STRIP(keypath,'t','\')
profile = "CASSETUP.DAT"
zrc = stream(profile,"c","open read")
if zrc <> "READY:" then do
msg = LogMsg(102","msgfile","zrc)
rc = lineout(logfile,msg)
end
z = 0
do while lines(profile) > 0
z = z+1
line.z = linein(profile)
line.z = strip(line.z,"B")
if substr(line.z,1,8) = "NISTDIR=" then do
line.z = "NISTDIR="||keypath
end
end
rc = stream(profile,"c","close")
"@ERASE " profile ">>NUL"
rc = stream(profile,"c","open write")
do i = 1 to z
rc = lineout(profile,line.i)
end
rc = stream(profile,"c","close")
msg = LogMsg(103","msgfile)
rc = lineout(logfile,msg)
parms = "PROGTYPE=PM;",
||"OBJECTID=<WP_SURI>;",
||"EXENAME="||keypath||"\CASSETUP.EXE;",
||"STARTUPDIR="keypath||";",
||"ICONFILE=CASSETUP.ICO;"
zrc = SysCreateObject(,
"WPProgram",,
"Code Server^Setup",,
"<WP_DESKTOP>",,
parms,,
"replace")
if zrc = 1 then do
msg = LogMsg(104","msgfile)
rc = lineout(logfile,msg)
end
else do
msg = LogMsg(105","msgfile","zrc)
rc = lineout(logfile,msg)
xrc = badrc
end
rc = lineout(logfile,head)
msg = LogMsg(106","msgfile)
rc = lineout(logfile,msg)
end
return xrc
UpdateConfigSys:
CALL LINEOUT logfile,"Updating config.sys..."
nowdir = Directory()
ADDRESS CMD "@casbootd"
bootd = SUBSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ",rc,1)
configsys = bootd":\CONFIG.SYS"
path_found = 0
dpath_found = 0
libpath_found = 0
config_updated = 0
IF STREAM(configsys,'c','query exists') = "" THEN
DO
CALL LINEOUT logfile, "Unable to find" configsys"."
CALL LINEOUT logfile, "You should manually add "nowdir" to PATH and LIBPATH."
RETURN x2d('0816')
END
tempfile = SysTempFileName(bootd":\XX????.TMP")
DO WHILE LINES(configsys) > 0
line = LINEIN(configsys)
sline = TRANSLATE(STRIP(line))
PARSE VAR sline first rest
first = TRANSLATE(STRIP(first))
rest = TRANSLATE(STRIP(rest))
IF LEFT(first,8) = "LIBPATH=" THEN
DO
libpath_found = 1
line = UpdateLine(line,nowdir)
END
ELSE
IF first = "SET" THEN
IF LEFT(rest,5) = "PATH=" THEN
DO
path_found = 1
line = UpdateLine(line,nowdir)
END
ELSE
IF LEFT(rest,6) = "DPATH=" THEN
DO
dpath_found = 1
line = UpdateLine(line,nowdir)
END
CALL LINEOUT tempfile,line
END
CALL STREAM configsys,'c','CLOSE'
CALL STREAM tempfile,'c','CLOSE'
badcs = 0
IF path_found = 0 THEN
DO
CALL LINEOUT logfile,"No SET PATH= statement was found in config.sys"
badcs = 1
END
IF dpath_found = 0 THEN
DO
CALL LINEOUT logfile,"No SET DPATH= statement was found in config.sys"
badcs = 1
END
IF libpath_found = 0 THEN
DO
CALL LINEOUT logfile, "No LIBPATH= statement was found in config.sys"
badcs = 1
END
IF badcs = 0 & config_updated = 1 THEN
DO
bkpfile = SysTempFileName(bootd":\config.???")
IF bkpfile = "" THEN
DO
CALL LINEOUT logfile,"Unable to back up your existing config.sys."
CALL LINEOUT logfile,"The updated config.sys is in file "tempfile
RETURN x2d('0816')
END
CALL ON ERROR NAME ucsError
ADDRESS CMD "@COPY "configsys bkpfile
xrc = rc
CALL OFF ERROR
IF xrc <> 0 THEN
DO
CALL LINEOUT logfile, "Unable to back up your existing config.sys."
CALL LINEOUT logfile, "The updated config.sys is in file "tempfile
RETURN x2d('0816')
END
CALL ON ERROR NAME ucsError
ADDRESS CMD "@COPY "tempfile configsys
xrc = rc
CALL OFF ERROR
IF xrc <> 0 THEN
DO
CALL LINEOUT logfile, "Unable to write the updated config.sys."
CALL LINEOUT logfile, "A backup copy of your original config.sys is in file "bkpfile
CALL LINEOUT logfile, "The updated config.sys is in file "tempfile
RETURN
END
CALL LINEOUT logfile, "Your original config.sys was backed up in file "bkpfile
CALL LINEOUT logfile, "Your config.sys has been updated. Reboot before running CASSETUP."
CALL SysFileDelete(tempfile)
END
ELSE
IF badcs = 1 THEN
DO
CALL LINEOUT logfile, configsys" was not updated."
CALL LINEOUT logfile, "You should manually add "nowdir" to PATH and LIBPATH, then reboot."
END
ELSE
DO
CALL LINEOUT logfile, "Your config.sys was already correct. It was not updated."
CALL LINEOUT logfile, "You may use CASSETUP without rebooting."
CALL SysFileDelete(tempfile)
CALL SysFileDelete(bkpfile)
END
RETURN x2d('ff00')
ucsError:
nop
RETURN
UpdateLine: PROCEDURE EXPOSE config_updated
parse arg line,dir
PARSE VAR line first"="rest
rest = strip(rest,'t')
trest = TRANSLATE(rest)
tdir = TRANSLATE(dir)
DO WHILE trest <> ""
PARSE VAR trest ThisPath";"trest
IF ThisPath = tdir THEN
RETURN line
END
rest = strip(rest,'t',';')||";"||STRIP(dir,'t',';')||';'
config_updated = 1
RETURN first"="rest
GIVEHELP:
"@CLS"
say ""
say ""
say "------------------------------------------------------------------ "
say " Name: CASINST Version: 1.2 "
say " Function: CASSETUP installation program "
say " - Creates user inputted <target_path> "
say " directory structure. "
say " - Copies the following files from source directory"
say " . CAS*.* (CASSETUP source files) "
say " . *.PRO (Application profiles) "
say " . *.SCR (Appl create disk scripts) "
say " . CMSGBOX.EXE (Message box routine) "
say " - Updates CASSETUP.DAT (GUI profile) to reflect "
say " user target path information. "
say " - Creates WorkPlace shell program object. "
say " - Updates config.sys "
say " "
say " Syntax: CASINST /T=<fully qualified drive and path> "
say " /S=<fully qualified drive and path> "
say " /L=<fully qualified file specification> "
say " "
say " Dependencies: REXX & REXUTILS, OS/2 version 2.+ "
say " CASSETUP.MSG, casbootd.exe CASSETUP Images "
say " Return code: 0 = successful, non-zero = ended in error "
say "------------------------------------------------------------------ "
exit goodrc
CHKCOPY: procedure expose badrc logfile errfile msgfile terminate head xdrive xpath stdout
parse arg zrc
xrc = 0
if zrc <> 0 then do
msg = LogMsg(99","msgfile","zrc)
rc = lineout(logfile,msg)
rc = lineout(logfile,terminate)
rc = lineout(logfile,head)
xrc = badrc
if logfile <> stdout then do
rc = lineout(logfile)
tmpfile = SysTempFileName(xdrive||xpath||"XX????.TMP")
"@TYPE " errfile ">" tmpfile
"@COPY " logfile" /A + "tmpfile logfile " /B >>NUL"
"@ERASE " tmpfile ">>NUL"
end
end
return xrc
LogMsg: procedure expose logfile
parse arg inparms
Parse var inparms msgno","msgfile","parm.1","parm.2","parm.3","parm.4","parm.5","parm.6","parm.7","parm.8","parm.9 .
msgfile = strip(msgfile,"B")
msg = ""
msgno = strip(msgno,"B")
if STREAM(msgfile, 'c', 'query exists') == "" then do
rc = lineout(logfile,'Log Message File' msgfile 'not found.')
rc = lineout(logfile,'Can not log message number' msgno'. Message parms were:')
do i = 1 to 9
if parm.i == ""
then LEAVE
else rc = lineout(logfile," "parm.i)
end
msg = ""
end
else do
xrc = STREAM(msgfile, 'c', 'open read')
if xrc = "READY:" then do
if DATATYPE(msgno) == 'NUM' then do
OffsetX = CHARIN(msgfile, 32 + (msgno * 2), 2)
wkvar = SUBSTR(OffsetX, 2, 1) || SUBSTR(OffsetX, 1, 1)
StartingOffsetD = C2D(wkvar)
OffsetX = CHARIN(msgfile, 32 + ((msgno+1) * 2), 2)
wkvar = SUBSTR(OffsetX, 2, 1) || SUBSTR(OffsetX, 1, 1)
EndingOffsetD = C2D(wkvar)
startchar = StartingOffSetD
endchar = EndingOffSetD
lin=CHARIN(msgfile, startchar+1, endchar-startchar)
do i = 1 to 9
n = POS("%" || i, lin)
if (n <> 0) then do
lin = DELSTR(lin, n, 2)
temp = STRIP(parm.i)
lin = INSERT(temp, lin, n-1)
end
end
header = "CAS"
n = LENGTH(msgno)
do i = 4 to (7-n)
header = header || '0'
end
msgt = substr(lin,1,1)
lin = substr(lin,2)
msg = lin
end
else do
rc = lineout(logfile,'Invalid log message number' msgno'. Message parms were:')
do i = 1 to 9
if parm.i == ""
then LEAVE
else rc = lineout(logfile," "parm.i)
end
msg = ""
end
rc = stream(msgfile,'c','close')
end
else do
rc = lineout(logfile,'Unable to open Message file ('msgfile'), rc('xrc').')
msg = ""
end
end
RETURN msg
CreateDir: PROCEDURE
arg path
workpath = path
segments.0 = 0
CALL SysMkDir workpath
MyStem.0 = 0
CALL SysFileTree workpath,"MYSTEM","D"
IF MyStem.0 > 0 THEN
RETURN 0
DO while workpath <> ""
PARSE VAR workpath ThisSeg"\"workpath
i = segments.0 + 1
segments.i = ThisSeg
segments.0 = i
END
workpath = segments.1
CALL SysMkDir workpath
DO i = 2 to segments.0
workpath = workpath || "\" || segments.i
CALL SysMkDir workpath
END
RETURN 0
DIRECTORY: procedure
parse arg indir
whereami = ""
getflag = 1
if indir <> "" then do
whereami = "DIRECTORY"(indir)
if whereami = "" then getflag = 0
end
if getflag = 1 then do
temp = RXQUEUE("DELETE","DIRQUE1")
nq = RXQUEUE("CREATE","DIRQUE1")
oq = RXQUEUE("SET",nq)
do i =1 to queued()
pull zzz
end
"@CD |" RXQUEUE nq
parse pull whereami
temp = RXQUEUE("DELETE",nq)
nq = RXQUEUE("SET",oq)
end
return whereami
STOPIT:
exit 1