home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 29 Fixes_o
/
29-Fixes_o.zip
/
updwebsu.exe
/
updwebx.cmd
< prev
Wrap
OS/2 REXX Batch file
|
1996-11-12
|
19KB
|
582 lines
/****************************************************************************/
/* UPDWEBX 1.3 PSP Fix Distribution, Austin 11/12/1996 */
/* */
/* Update IBM Web Explorer and/or Netscape Navigator to support RSU. */
/* */
/* IBM Web Explorer: */
/* Make sure EXPLORE.INI is in the ETC (SET ETC=) directory. */
/* Locate Mailcap and Extmap entries */
/* Exist - check Mailcap and Extmap for required entries. */
/* Exist - do nothing */
/* Need - Read in existing Mailcap/Extmap file, add our entry. */
/* R/O drive - write new Mailcap/Extmap file to ETC directory. */
/* update EXPLORE.INI to point to new file */
/* R/W drive - delete old Mailcap/Extmap file */
/* write new Mailcap/Extmap file */
/* Need - add Mailcap/Extmap entries to EXPLORE.INI */
/* write Mailcap/Extmap file with our required entries to the */
/* ETC directory */
/* */
/* Netscape Navigator: */
/* If Netscape entry in OS2.INI then it's installed. Pull the install */
/* path from the key entry. */
/* Change to Netscape directory */
/* Check NETSCAPE.INI for "Suffixes www/unknown" and "Viewers www/unknown" */
/* entries. If either there bail out and tell user to update manually. */
/* */
/* Add "Suffixes www/unknown rsu" and/or "Viewers www/unknown path" to */
/* NETSCAPE.INI as needed (path is the fully qualified path to where */
/* Netscape is installed. */
/****************************************************************************/
'@Echo off'
ver='v1.3'
Parse source whoami
Parse value whoami with . . whoami
call_path=Filespec('DRIVE',whoami)||Filespec('PATH',whoami)
me=Filespec('NAME',whoami)
Say me ver
curdir=Directory() /* remember where we are */
Arg op .
If op='-?' | op='/?' | op='?' then
Signal Tell
/***********************************/
/* Register all REXXUTIL functions */
/***********************************/
rc=RxFuncAdd('SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs')
If rc>1 then
Do
Say 'Unable to register REXXUTIL functions.'
Signal Done
End
Call SysLoadFuncs
/*****************************************************/
/* Ask what is to be updated, WebX, Netscape or both */
/* if Netscape is installed. Otherwise just do IBM */
/* WebX. */
/*****************************************************/
updwebx=1
updnetscape=0
netscape=0
x=SysIni('USER','ALL:','apps.')
Do j=1 to apps.0
If translate(apps.j)='NETSCAPE' then
Do
netscape=1
x=SysIni('USER',apps.j,'ALL:','key.')
netscape_source=SysIni('USER',apps.j,key.1) /* Where NS is installed */
Leave j
End
End
ans=''
If netscape then
Do
Say
Say 'Enter the number preceeding the Web browser you want to update.'
Say 'Press Enter without entering any data to exit now.'
Say
Say '1 IBM Web Explorer'
Say '2 Netscape Navigator'
Say '3 Both IBM Web Explorer and Netscape Navigator'
Do while ans=''
Pull ans .
If ans='' then
Signal Done
If wordpos(ans,'1 2 3')=0 then
Do
Say 'Invalid response ('ans'), try again.'
ans=''
Iterate
End
End
updwebx=ans=1 | ans=3
updnetscape=ans=2 | ans=3
End
/******************************/
/* Make sure WebX or Netscape */
/* are not running. */
/******************************/
bail=0
temp=SysTempFileName('@PSTAT@.???')
'@PSTAT /C > 'temp
Call Stream temp,'C','Open Read'
Do while lines(temp)
line=translate(linein(temp))
If updwebx & pos('EXPLORE.EXE',line)>0 then
Do
Call Beep 262,400
Say
Say 'Shutdown IBM Web Explorer then rerun this program.'
bail=1
End
If updnetscape & pos('NETSCAPE.EXE',line)>0 then
Do
Call Beep 262,400
Say
Say 'Shutdown Netscape Navigator then rerun this program.'
bail=1
End
End
Call Stream temp,'C','Close'
x=SysFileDelete(temp)
If bail then
Signal Done
/***********************************/
/* Setup some vars needed for both */
/* WebX and Netscape. */
/***********************************/
etc=value('ETC',,'OS2ENVIRONMENT') /* Get location of ETC directory */
If etc='' then
Do
Say 'SET ETC= not setup in your CONFIG.SYS.'me' cannot continue.'
Signal Done
End
bin=substr(etc,1,length(etc)-3)||'BIN'
rsuinst=bin||'\RSUINST.EXE'
rsu_source=call_path||'RSUINST.EXE'
unzip=bin||'\UNZIP.DLL'
unzip_source=call_path||'UNZIP.DLL'
rsuinst_done=0
unzipdll_done=0
/****************************************/
/* Update IBM Web Explorer if requested */
/****************************************/
If updwebx then
Do
Say
Say 'Checking IBM Web Explorer setup.'
Say
ini='EXPLORE.INI'
mailcap='MAILCAP'
extmap='EXTMAP'
Call Directory(etc) /* Change to etc directory */
If stream(ini,'C','Query Exists')='' then
Do
Say ini' not found in 'etc'. Cannot update IBM Web Explorer.'
Signal CheckNetscape
End
/************************************************/
/* Now look for the MAILCAP and EXTMAP entries. */
/* Not there, add: */
/* mailcap=etc\mailcap */
/* extmap=etc\extmap */
/* There, do nothing */
/************************************************/
chk1='MAILCAP='
chk2='EXTMAP='
Parse value '' with mcpath empath .
update=0
Call stream ini,'C','Open Read'
Do j=1 while lines(ini)
line.j=linein(ini)
If left(translate(line.j),length(chk1))=chk1 then /* Mailcap entry? */
Do
Parse value line.j with verb'='mcpath .
If mcpath='' then /* No path to Mailcap file? */
Do
mcpath=etc||'\MAILCAP' /* We will create one */
line.j=verb'='||mcpath
update=1
Iterate j
End
End
Else
If left(translate(line.j),length(chk2))=chk2 then /* Extmap entry? */
Do
Parse value line.j with verb'='empath .
If empath='' then
Do
empath=etc||'\EXTMAP'
line.j=verb'='||empath
update=1
Iterate j
End
End
End
Call stream ini,'C','Close'
/************************************/
/* Define paths if not already done */
/* If done check for R/W drive and */
/* create local copy if not. */
/************************************/
o=j-1
If mcpath='' then
Do
mcpath=etc||'\MAILCAP'
o=o+1
line.o='Mailcap='||mcpath
update=1
End
Else
If ChkRO(mcpath)<>0 then
Do
mcpathn=etc||'\MAILCAP'
Say mcpath 'located on R/O drive, creating local copy as'
Say mcpathn
'@COPY' mcpath mcpathn '>NUL'
mcpath=mcpathn
o=o+1
line.o='Mailcap='||mcpath
update=1
End
If empath='' then
Do
empath=etc||'\Extmap'
o=o+1
line.o='Extmap='||empath
update=1
End
Else
If ChkRO(empath)<>0 then
Do
empathn=etc||'\EXTMAP'
Say empath 'located on R/O drive, creating local copy as'
Say empathn
'@COPY' empath empathn '>NUL'
empath=empathn
o=o+1
line.o='Extmap='||empath
update=1
End
/**************************************/
/* Update (backup, delete, write new) */
/* the ini file if needed. */
/**************************************/
If update then
Do
backup=SysTempFileName('EXPLORE.???')
'@COPY 'ini backup' >NUL'
Say 'Saved 'ini' as 'backup
x=SysFileDelete(ini)
Call Stream ini,'C','Open Write'
Do j=1 to o
Call lineout ini,line.j
End
Call Stream ini,'C','Close'
Say 'Updated 'ini' with new/changed Mailcap and/or Extmap entries.'
End
Else
Say '"Mailcap" and "Extmap" entries already in 'ini
/************************************/
/* Now we need to create/update the */
/* Mailcap/Extmap files to point to */
/* RSUINST.EXE */
/************************************/
mailcap=mcpath /* Point to new or old file */
extmap=empath /* Ditto */
found=0
chk=translate('APPLICATION/RSU; 'rsuinst' %S')
o=0
If stream(mailcap,'C','Query Exists')<>'' then /* Exists? */
Do
Call Stream mailcap,'C','Open Read'
Do while lines(mailcap)
o=o+1
line.o=linein(mailcap)
If translate(space(line.o,1))=chk then
Do
found=1
Leave
End
End
Call Stream mailcap,'C','Close'
End
If \found then
Do
If stream(mailcap,'C','Query Exists')<>'' then
Do
backup=SysTempFileName('MAILCAP.???')
'@COPY 'mailcap backup' >NUL'
Say 'Saved 'mailcap' as 'backup
x=SysFileDelete(mailcap)
End
o=o+1
line.o=xlate(chk)
Call Stream mailcap,'C','Open Write'
Do j=1 to o
Call lineout mailcap,line.j
End
Call Stream mailcap,'C','Close'
Say 'Added 'xlate(chk)' to 'mailcap
End
Else
Say '"'xlate(chk)'" already in 'mailcap
found=0
o=0
chk='APPLICATION/RSU RSU'
If stream(extmap,'C','Query Exists')<>'' then
Do
Call Stream extmap,'C','Open Read'
Do while lines(extmap)
o=o+1
line.o=linein(extmap)
If translate(space(line.o,1))=chk then
Do
found=1
Leave
End
End
Call Stream extmap,'C','Close'
End
If \found then
Do
If stream(extmap,'C','Query Exists')<>'' then
Do
backup=SysTempFileName('EXTMAP.???')
'@COPY 'extmap backup' >NUL'
Say 'Saved 'extmap' as 'backup
x=SysFileDelete(extmap)
End
o=o+1
line.o=xlate(chk)
Call Stream extmap,'C','Open Write'
Do j=1 to o
Call lineout extmap,line.j
End
Call Stream extmap,'C','Close'
Say 'Added 'xlate(chk)' to 'extmap
End
Else
Say '"'xlate(chk)'" already in 'extmap
/*******************************************/
/* Now we copy RSUINST.EXE from the source */
/* directory to the target directory. */
/*******************************************/
replace=stream(rsuinst,'C','Query Exists')<>''
'@COPY' rsu_source bin '>NUL'
If replace then
Say 'Replaced 'rsuinst
Else
Say 'Created 'rsuinst
rsuinst_done=1
/*********************************************/
/* Finally we copy UNZIP.DLL from the source */
/* directory to the target directory. */
/*********************************************/
replace=stream(unzip,'C','Query Exists')<>''
'@COPY' unzip_source bin '>NUL'
If replace then
Say 'Replaced 'unzip
Else
Say 'Created 'unzip
unzipdll_done=1
/*******************************************/
/* Create an Icon on the Desktop to access */
/* Software Updates. */
/*******************************************/
Call directory curdir /* put us back where we started */
Call Rsuwp 'WEBX'
End /* Update Webx */
/**********************************/
/* Now update Netscape if allowed */
/**********************************/
CheckNetscape:
If updnetscape then
Do
Say
Say 'Checking Netscape Navigator setup.'
Say
Call Directory(netscape_source)
ini='netscape.ini'
If stream(ini,'C','Query Exists')='' then
Do
Say ini' not found, cannot update Netscape Navigator.'
Signal Done
End
If stream(ini,'C','Query Size')=0 then
Do
Say ini' size is 0. You must launch Netscape Navigator then'
Say 'shut it down once to create a complete 'ini' file.'
Signal Done
End
rsuinst='plugins\rsuinst.exe'
suffixes=0
x=SysIni(ini,'Suffixes','ALL:','apps.')
Do j=1 to apps.0
If translate(apps.j)='WWW/UNKNOWN' then
Do
If translate(SysIni(ini,'Suffixes',apps.j))='RSU' then
Do
Say 'Netscape "Suffixes www/unknown rsu" already',
'registered.'
suffixes=2
End
Else
Do
Say 'Netscape "Suffixes www/unknown" already registered.'
Say 'You need to change the definition to "rsu".'
suffixes=1
End
Iterate j
End
End
viewers=0
x=SysIni(ini,'Viewers','ALL:','apps.')
maxtype=0
typedone=0
Do j=1 to apps.0
If translate(apps.j)='WWW/UNKNOWN' then
Do
If translate(SysIni(ini,'Viewers',apps.j))=translate(rsuinst) then
Do
Say 'Netscape "Viewers www/unknown 'rsuinst'" already',
'registered.'
viewers=2
End
Else
Do
Say 'Netscape "Viewers www/unknown" already registered.'
Say 'You need to change the definition to "'rsuinst'".'
viewers=1
End
Iterate j
End
If left(translate(apps.j),4)='TYPE' then
Do
maxtype=max(maxtype,right(apps.j,1))
If translate(SysIni(ini,'Viewers',apps.j))='WWW/UNKNOWN' then
Do
Say 'Netscape "Viewers 'type' www/unknown" already registered.'
typedone=1
End
Iterate j
End
End
If suffixes=1 | viewers=1 then
Do
Say
Say 'Please follow the manual process outlined on the Web page'
Say 'if you want to use Service Updates with Netscape Navigator.'
Say
End
If suffixes=0 then
Do
x=Sysini(ini,'Suffixes','www/unknown','rsu')
Say 'Added "Suffixes www/unknown rsu" to 'ini
End
If viewers=0 then
Do
x=Sysini(ini,'Viewers','www/unknown',rsuinst)
Say 'Added "Viewers www/unknown 'rsuinst'" to 'ini
End
If \typedone then
Do
type='TYPE'||maxtype+1
x=Sysini(ini,'Viewers',type,'www/unknown')
Say 'Added "Viewers 'type' www/unknown" to 'ini
End
/*******************************************/
/* Now we copy RSUINST.EXE from the source */
/* directory to the PLUGINS directory. */
/*******************************************/
replace=stream(rsuinst,'C','Query Exists')<>''
'@COPY' rsu_source rsuinst' >NUL'
If replace then
Say 'Replaced 'rsuinst
Else
Say 'Created 'rsuinst
/*********************************************/
/* Finally we copy UNZIP.DLL from the source */
/* directory to the target directory. */
/*********************************************/
If \unzipdll_done then
Do
replace=stream(unzip,'C','Query Exists')<>''
'@COPY' unzip_source bin '>NUL'
If replace then
Say 'Replaced 'unzip
Else
Say 'Created 'unzip
End
/*******************************************/
/* Create an Icon on the Desktop to access */
/* Software Updates. */
/*******************************************/
Call directory curdir /* put us back where we started */
Call Rsuwp 'NETSCAPE'
End
/*********************/
/* Cleanup and leave */
/*********************/
x=SysFileDelete(rsu_source)
x=SysFileDelete('UPDWEBSU.EXE')
x=SysFileDelete(me)
x=SysFileDelete('RSUWP.CMD')
x=SysFileDelete('UNZIP.DLL')
/*******************************/
/* Only exit from this program */
/* Cleanup then exit */
/*******************************/
Done:
Call directory curdir /* put us back where we started */
Exit
/***************************/
/* Translate to lower case */
/***************************/
Xlate: Procedure
Arg input
lcase='abcdefghijklmnopqrstuvwxyz'
ucase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Return translate(input,lcase,ucase)
/***********************/
/* See if drive is R/W */
/***********************/
ChkRO: Procedure
Arg path
path=Filespec('DRIVE',path)||Filespec('PATH',path)
temp=SysTempFileName(path||'UPDWEBX.???')
Call Stream temp,'C','Open Write'
If Stream(temp,'S')<>'READY' then
retrc=1
Else
Do
Call Stream temp,'C','Close'
x=SysFileDelete(temp)
retrc=0
End
Return retrc
/**************************************/
/* Display help info for this program */
/**************************************/
Tell:
Say 'Form: UPDWEBX'
Say
Say 'Will update IBM Web Explorer and/or Netscape Navigator to add support for'
Say 'the Service Updates (RSU) tool for applying fixes from the Internet'
Say 'directly to your system.'
Say
Say 'IBM Web Explorer'
Say 'Adds/updates EXPLORE.INI and associated Mailcap/Extmap files.'
Say 'Adds/updates RSUINST.EXE to BIN directory.'
Say
Say 'Netscape Navigator'
Say 'Adds the Suffixes and Viewers entries to NETSCAPE.INI.'
Say 'Adds/updates RSUINST.EXE to PLUGINS directory.'
Say
Say 'Also creates a Program Object (Icon) on your Desktop for each of the'
Say 'above if they are updated.'
Signal Done