home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
netdor3.zip
/
DISK_12
/
IMAGE11.ZIP
/
ADMTOOLS
/
SRVINIT.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-11-25
|
44KB
|
1,212 lines
/*****************************************************************************
* SRVINIT - Start COU Server *
* CORE Development (CORE at WATSON) *
*****************************************************************************
* Licensed Materials-Property of IBM *
* 5604-472 (c) Copyright IBM Corporation, 1993 *
* All rights reserved. *
* US Government Users Restricted Rights - *
* Use, duplication or disclosure restricted *
* by GSA ADP Schedule Contract with IBM Corp. *
*****************************************************************************
* Dependencies: *
* RXUTILS *
*****************************************************************************
* Change History: *
* (Earlier changes can be found in \COREUTIL\HISTORY\CSRVUP.HST) *
* Version 3.0 - 22 Mar 93 *
* - New assumptions for product: *
* - Appropriate network protocol(s) is/are started. *
* - User has been logged on. *
* - Remote drive is accessed. *
*****************************************************************************/
/* Note
* Need to erase MTAB file on reboot if NFS server
*/
trace 'O'
TrVal = value('CORETRACE',,'OS2ENVIRONMENT')
if TrVal = '' then TrVal = 'O'
trace value TrVal
call on halt
signal on novalue
signal on syntax
'@ECHO OFF'
PgmVer = '3.0'
Globals = 'CDr UDr TrVal Ctl. Opt. File. Msg.'
parse upper source . . File.!Me
parse value stream(File.!Me, 'C', 'QUERY DATETIME') with PgmDate .
parse upper arg Args
call SetMsgClass 'M', 'X'
if wordpos('/DEBUG', Args) > 0
then call Debug
parse var Args PosParms '/' SlashParms
if PosParms <> ''
then signal Tell
/*
* Check what version of REXX is running, and abort or warn if neccessary.
* REXXVER specifies the minimum version of REXX required.
* REXXMIN specifies the minimum release date of REXX required.
* REXXCURR specifies the current release of REXX; preferred.
*/
RexxVer = '4.00' /* Required REXX version */
RexxMin = '16 Aug 1991' /* Minimum req'd REXX date */
RexxCurr = '16 Aug 1991' /* Desired REXX date */
RxUtilsMin = 1.71 /* Minimum RXUTILS version */
Msg.!Min = 2.14 /* Minimum message file version */
parse upper version . . RelDay RelMo RelYr .
if DateLess(RelDay RelMo RelYr, RexxMin) /* Old REXX running */
then call Report 3501, RexxVer, RelDay RelMo RelYr, RexxCurr
if DateLess(RelDay RelMo RelYr, RexxCurr) /* Middling old REXX */
then call Report 3502, RexxVer, RelDay RelMo RelYr, RexxCurr
/*****************************************************************************
* MAIN PROGRAM *
*****************************************************************************/
call Initialize
call StartNetwork
call GetAuxAliases
call StartPrograms
call UpdateLocal
call LastTasks
call CleanUp 0
exit 254 /* This exit should never happen! */
/*****************************************************************************
* GENERAL PURPOSE ROUTINES *
*****************************************************************************/
/*****************************************************************************
* DATELESS: Date1, Date2 *
* Returns 1 if Date1 is "less than" (earlier than) Date 2. Dates are in *
* REXX normal (14 Mar 1964) format. *
*****************************************************************************/
DateLess: procedure expose (Globals)
trace 'O';call Report 9996, 'DateLess' arg(1)','arg(2)
trace 'O'
parse upper arg D1 M1 Y1, D2 M2 Y2
Months='JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC'
M1 = right(wordpos(M1, Months), 2, 0)
M2 = right(wordpos(M2, Months), 2, 0)
return ShowReturn(right('19'Y1, 4) || M1 || D1 < right('19'Y2, 4) || M2 || D2)
/*****************************************************************************
* INIGET *
* Retrieves information from INI files, mapping error returns to null. *
*****************************************************************************/
IniGet: procedure expose (Globals)
trace 'O';call Report 9996, 'IniGet' arg(1)',' arg(2)',' arg(3)
trace 'O'
parse arg File, App, Key
Res = rxOs2Ini(File, App, Key)
if wordpos(Res, '$RXERROR $INIERROR $INI_ERROR') | abbrev(Res, 'ERROR:')
then Res = ''
else Res = strip(Res, 'T', '0'x)
return ShowReturn(Res)
/*****************************************************************************
* NORMALIZE dir *
* Convert the input directory into standard format: *
* - Remove any trailing backslash if not root drive. *
*****************************************************************************/
Normalize:
trace 'O';call Report 9996, 'Normalize' arg(1)','arg(2)
trace value 'O'
parse arg Dir, Opt
if length(Dir) > 3
then Dir = strip(Dir, 'T', '\')
if Opt = 'CORE' & right(Dir, 1) <> '\'
then Dir = Dir'\'
return ShowReturn(Dir)
/*****************************************************************************
* CHECKDRIVE *
* OK FREE - Arg is valid drive letter and is free *
* OK USED - Arg is valid drive letter and in use *
* BAD - Arg is invalid drive specification *
*****************************************************************************/
CheckDrive: procedure expose (Globals)
trace 'O';call Report 9996, 'CheckDrive' arg(1)
trace value TrVal
parse arg Dr
signal on syntax name CheckDrive2
if rxDriveInfo(Dr) = ''
then return ShowReturn('OK FREE')
else return ShowReturn('OK USED')
CheckDrive2:
if rc = 40
then return ShowReturn('BAD')
else call Syntax '<WHERE>', SigL
/*****************************************************************************
* CHECKPATH *
* Path must be fully qualified. *
* OK FREE - Arg is a valid path that does not exist. *
* OK USED - Arg is a valid path that exists. *
* BAD - Path is invalid. *
*****************************************************************************/
CheckPath: procedure expose(Globals)
trace 'O';call Report 9996, 'CheckPath' arg(1)
trace value TrVal
InPath = Normalize(arg(1))
parse var InPath Dr +2 Sl +1 Path
Res = CheckDrive(Dr)
if Res <> 'BAD'
then if Sl <> '\'
then Res = 'BAD'
else do while Path <> '' & Res <> 'BAD'
parse var Path Dir '\' Path
if Dir = ''
then Res = 'BAD'
end
if Res <> 'BAD'
then if rxDirExist(InPath)
then Res = 'OK USED'
else Res = 'OK FREE'
return ShowReturn(Res)
/*****************************************************************************
* DRIVEREADABLE *
* Return 1 if specified drive (or directory) is readable *
*****************************************************************************/
DriveReadable: procedure expose (Globals)
trace 'O';call Report 9996, 'DriveReadable' arg(1)
trace value TrVal
Dr = strip(arg(1), 'T', '\')
UC = 'ABCDEFGHIJKLMNOPQRSTUVQXYZ'
parse value 0 with Ok 1 Files 1 Dir 1 DirFound .
do until Ok | UC = ''
parse var UC Letter +1 UC
call rxTree Dr'\'Letter'*', 'DIR.', 'B'
if Dir.0 > 0
then do I = 1 to Dir.0 until Ok
if pos('D', word(Dir.I, 4)) > 0
then do
DirFound = 1
Files = 1
call rxTree subword(Dir.I, 5)'\*', 'SUB.', 'F'
Dir = (Sub.0 <> 0)
end
else Files = 1
Ok = Dir & Files
end I
if \DirFound
then Ok = Files
end
return ShowReturn(Ok)
/**::CLAM::1.05::*************************************************************
* CORE Log and Message subsystem *
* Globals = 'MSG.' *
*****************************************************************************/
/*****************************************************************************
* REPORT MsgNumb[Flags] [, MArg] [...] *
* Flags: S - Write to supplemental log file (must be previously opened) *
* or 1 MsgType override: *
* F - Fatal error *
* E - Error *
* W - Warning *
* I - Informational message *
* M - Message *
* D - Message (display only) *
* L - Message (log only) *
* X - Debug message *
*****************************************************************************/
Report: procedure expose (Globals)
trace value 'O'
if symbol('MSG.!PEND.0') = 'LIT'
then do
Esc = d2c(27)'[' /* Escape character (temp) */
Msg.!Pend.0 = 0 /* Pending message stack */
Msg.!Dull = Esc'0m' /* Dull white on black */
Msg.!Norm = Esc'1;37;40m' /* Intense white on black */
Msg.!Warn = Esc'0;30;43m' /* Black on yellow */
Msg.!Err = Esc'1;31;47m' /* Intense red on white */
Msg.!Eeol = Esc'K'Msg.!Norm /* Erase to end of line */
Msg.!Popup = 0 /* Use DBOXMGR to display warnings */
Msg.!PopList = 'FEW' /* Classes to popup if Popup = 1 */
Msg.!ClassLst = 'FEWIMDLX'
Msg.!ClassMap = '00246669'
if symbol('MSG.!DISPSET') = 'LIT'
then parse value 'I M' with Msg.!DispSet Msg.!LogSet .
call InitMsgs
end
parse value '' with Flags Sev
LogNum = 1
MsgN = arg(1)
P = verify(MsgN, '0123456789')
if P > 0
then if P = 1
then do
Flags = MsgN
MsgN = ''
end
else do
Flags = substr(MsgN, P)
MsgN = left(MsgN, P-1)
end
if MsgN = ''
then do
Sev = 'L'
Msg = arg(2)
end
else if symbol('MSG.'MsgN) = 'VAR'
then parse var Msg.MsgN Sev Msg
else do
Msg = 'Text for message number' MsgN||Sev 'not found.'
MsgN = '9999'
Sev = 'W'
end
do while Flags <> ''
parse var Flags 1 Flag 2 Flags
select
when Flag = 'S'
then LogNum = 2
when verify(Flag, Msg.!ClassLst) = 0
then Sev = Flag
otherwise do
say 'Error - Invalid message flag "'Flag'".'
call Cleanup 3
end
end
end
SayIt = Sev <> 'L' & (translate(Sev, Msg.!ClassMap, Msg.!ClassLst) <=,
translate(Msg.!DispSet, Msg.!ClassMap, Msg.!ClassLst))
LogIt = Sev <> 'D' & (translate(Sev, Msg.!ClassMap, Msg.!ClassLst) <=,
translate(Msg.!LogSet, Msg.!ClassMap, Msg.!ClassLst))
if rxUtilsVer() >= 1.70
then SayIt = SayIt & rxProcessType() <> 4
if \(SayIt | LogIt)
then return 0
if abbrev(Msg, '->') | abbrev(Msg, '<-')
then Msg = '['time('S')']' Msg
if \rxfuncquery('RXINSMESSAGE')
then Msg = rxInsMessage(Msg, arg(2), arg(3), arg(4), arg(5), arg(6), arg(7),,
arg(8), arg(9), arg(10))
else do I = 1 to 9
P = pos('%'I, Msg)
if P > 0
then do
L = length('%'I)
Msg = left(Msg, P-1)||arg(I+1)||substr(Msg, P+L)
end
end
if abbrev(Msg, '->') | abbrev(Msg, '<-')
then Msg = '['time('S')']' Msg
if MsgN <> ''
then Msg = 'COR'right(MsgN, 4, '0')||Sev Msg
if SayIt
then if Msg.!PopUp & pos(Sev, Msg.!PopList) > 0
then call PopUp Msg, Sev
else call FlowSay Msg, Sev
if LogIt
then if symbol('Msg.!LOG.1') = 'VAR'
then do
Temp.1 = Msg
Temp.0 = 1
call rxWrite Msg.!Log.LogNum, 'TEMP.',,,'A'
end
else if rxfuncquery('RXSTEMINSERT')
then do
Msg.!Pend.0 = Msg.!Pend.0 + 1
call value 'Msg.!PEND.'Msg.!Pend.0, Msg
end
else call rxStemInsert 'Msg.!PEND.', Msg.!Pend.0 + 1, Msg
if Sev = 'F'
then do
if symbol('Msg.!LOG.1') = 'VAR'
then do
say Msg.!Norm'Do you want to view the log file (Y/N)?'
do forever
parse upper linein Resp .
if abbrev('YES', Resp)
then do
Res = stream(Msg.!Log.1, 'C', 'CLOSE')
if \(abbrev(Res, 'READY') | Res = '')
then call Report 10, Res, Msg.!Log.1
'START "CORE Log" /F E' Msg.!Log.1
leave
end
if abbrev('NO', Resp)
then do
say 'The log file is in' Msg.!Log.1
leave
end
if abbrev('DEBUG', Resp)
then signal DebugExit '<SKIP>'
end
end
call CleanUp 2
end
return 0
/*****************************************************************************
* SETMSGCLASS DisplayClass, LogClass *
*****************************************************************************/
SetMsgClass: procedure expose (Globals)
trace value 'O'
parse arg Msg.!DispSet ., Msg.!LogSet .
return 0
/*****************************************************************************
* CLINITLOG LogName [Erase], [SecondaryLog [Erase]] *
*****************************************************************************/
ClInitLog: procedure expose (Globals)
trace value 'O'
parse arg Msg.!Log.1 Erase.1, Msg.!Log.2 Erase.2
do I = 1 to arg()
if Erase.I = 1 & rxFileExist(Msg.!Log.I)
then do
RetC = rxDelete(Msg.!Log.I)
if RetC <> 0
then call Report '9999W', RetC, Msg.!Log.1 /* error deleting file */
end
end
call rxWrite Msg.!Log.1, 'Msg.!PEND.',,,'A'
return 0
/*****************************************************************************
* POPUP *
*****************************************************************************/
Popup: procedure expose (Globals)
trace value 'O'
parse arg Msg, Style
call RegExtFuncs
call 'DBoxMgr'
select
when Style = 'INFO'
then Style = MB_INFORMATION
when Style = 'ERROR'
then Style = MB_ERROR
when Style = 'WARNING'
then Style = MB_WARNING
when Style = 'NONE'
then Style = MB_ICONNOICON
otherwise
Style = MB_WARNING
end
Dlg = dBoxCreate('CORE Message', 0, 0, 0, 0)
call dBoxCreateMbx Dlg, Msg, MB_OK + MB_MOVEABLE + Style
call dBoxDestroy Dlg
return 0
/*****************************************************************************
* FLOWSAY Msg, AnsiPre, AnsiPost *
* Display the message, breaking it on word boundries into lines less than *
* or equal to LLeng. *
*****************************************************************************/
FlowSay: procedure expose (Globals)
trace value 'O'
parse arg Msg, Sev
if rxfuncquery('RXSCREENSIZE')
then LLeng = 80
else parse value rxScreenSize() with ',' LLeng .
call MsgTune Sev
select
when Sev = 'E' | Sev = 'F'
then AnsiPre = Msg.!Err
when Sev = 'W'
then AnsiPre = Msg.!Warn
otherwise AnsiPre = Msg.!Norm
end
Msg = Msg' '
if rxfuncquery('RXSAY') = 0
then call rxSay AnsiPre
else Msg = AnsiPre||Msg
do while Msg <> ''
Break = lastpos(' ', left(Msg, LLeng))
if Break > 0
then do
DispLine = left(Msg, Break-1)
Msg = substr(Msg, Break+1)
end
else do
DispLine = left(Msg, LLeng-1)
Msg = substr(Msg, LLeng)
end
if Msg = ''
then say DispLine||Msg.!EEol
else say DispLine
end
return 0
/*****************************************************************************
* MSGTUNE class *
*****************************************************************************/
MsgTune: procedure expose (Globals)
trace 'O'
parse arg Class .
select
when Msg.!Popup
then nop
when wordpos(Class, 'E F') > 0
then do I = 300 to 100 by -100
call beep I, (100 * (I<>100) + 500 * (I=100))
do 300; end
end
when Class = 'W'
then call beep 300, 200
otherwise nop
end
return 0
/*****************************************************************************
* INITMSGS *
*****************************************************************************/
InitMsgs: procedure expose (Globals)
trace value 'O'
Msg.9999 = 'M %1'
Msg.!Ver = '1.00'
MsgFileName = 'SRVINIT.MSG'
parse source . . Me
MyPath = left(Me, max(3, lastpos('\', Me)-1))
call setlocal
call value 'DPATH', MyPath';'value('DPATH',,'OS2ENVIRONMENT'), 'OS2ENVIRONMENT'
MsgFile = stream(MsgFileName, 'C', 'QUERY EXISTS')
if MsgFile = '' & \rxFuncQuery('RXSEARCHPATH')
then MsgFile = rxSearchPath('DPATH', MsgFileName)
call endlocal
if MsgFile = ''
then do
say 'Error: Message file' MsgFile 'not found.'
return
end
Msgs = strip(charin(MsgFile, 1, stream(MsgFile, 'C', 'QUERY SIZE')), 'T', '1A'x)
call stream MsgFile, 'C', 'CLOSE'
CrLf = '0D0A'x
Lf = '0A'x
do while Msgs <> ''
if \abbrev(Msgs, '*')
then parse var Msgs MsgN Msg.MsgN (CrLf) Msgs
else do
parse var Msgs Key KArg (CrLf) Msgs
select
when Key = '*CONT'
then Msg.MsgN = Msg.MsgN||Lf||KArg
when Key = '*VERSION'
then Msg.!Ver = KArg
otherwise nop
end
end
end
if symbol('MSG.!MIN') = 'VAR'
then if Msg.!Min > Msg.!Ver
then call Report '9999W', MsgFileName Msg.!Min 'desired; ' Msg.!Ver 'found.'
return 0
/*****************************************************************************
* SHOWRETURN *
*****************************************************************************/
ShowReturn: procedure expose (Globals)
trace value 'O'
Res = arg(1)
Max = 400
XChar = (verify(arg(1), xrange('20'x, '7F'x)) > 0)
if XChar
then do
call Report 9997, translate(Res,, '0007090A0D'x, ' ')
Temp = c2x(Res)
if length(Temp) > Max
then Temp = left(Temp, Max-3)'...'
call Report '9999X', "= '"Temp"'x"
end
else call Report 9997, Res
return Res
/**::CLAM::end::**************************************************************/
/*****************************************************************************
* CSRVUP ROUTINES *
*****************************************************************************/
/*****************************************************************************
* CHECKENVIRONMENT *
* Retrieve environment information from the INI file, if available. *
* Otherwise, checks out the environment variables. *
* Set Parms.!LinkCore to indicate if CORE needs to be linked or not. *
* Switch to the run directory. *
*****************************************************************************/
CheckEnvironment: procedure expose (Globals)
trace 'O';call Report 9996, 'CheckEnvironment'
trace value TrVal
call Report 3503 /* checking env */
File.!CoreIni = rxCouInfo('GET', 'INIFILE')
UDr = rxCouInfo('GET', 'LOCAL')
CDr = rxCouInfo('GET', 'REMOTE')
UDr = CheckEnv2(UDr, 'Local')
CDr = CheckEnv2(CDr, 'Remote')
call Report 3504, CDr, UDr /* Env var report */
return ShowReturn(0)
/***** CheckEnv2 *************************************************************/
CheckEnv2:
trace 'O';call Report 9996, 'CheckEnvironment' arg(1)','arg(2)
trace value TrVal
parse arg EVal, EDesc
if abbrev(EVal, 'ERROR:')
then do
Ctl.!EnvError = 1
parse var EVal ':' ErrCode
call Report 3505, ErrCode, EDesc
EVal = ''
end
else do
Test = CheckPath(EVal, 'DIR')
select
when Test = 'OK USED'
then if \DriveReadable(EVal)
then call Report 3509, EVal /* unreadable */
when Test = 'OK FREE'
then call Report 3506, EVal /* does not exist */
when Test = 'BAD'
then call Report 3507, EVal /* bad spec */
otherwise
call Report 3508, Test, EVal /* something odd */
end
EVal = Normalize(EVal, 'CORE')
end
return ShowReturn(EVal)
/*****************************************************************************
* TRAPCMD OsCmd [,FailureString] *
* Execute an OS/2 command and store the result in the log file. *
* *
* If any lines beginning with the failure string are returned by the *
* command, the command is assumed to have failed even if the rc is zero. *
*****************************************************************************/
TrapCmd: procedure expose (Globals)
trace 'O';call Report 9996, 'TrapCmd' arg(1)','arg(2)','arg(3)
trace value TrVal
parse arg OsCmd
FailStr.0 = arg() - 1
do J = 1 to FailStr.0
FailStr.J = translate(arg(J+1))
end J
PreQueued = queued()
call Report 3532, OsCmd /* Log command */
'('OsCmd '2>&1) | RXQUEUE'
RetC = rc
do queued() - PreQueued
parse pull CmdRes
CmdRes = strip(CmdRes)
call Report 3533, CmdRes
CmdRes = translate(CmdRes)
do J = 1 to FailStr.0 while RetC = 0
if abbrev(translate(CmdRes), FailStr.J, 1) | wordpos(FailStr.J, CmdRes) > 0
then RetC = 99999
end
end
call Report 3533, 'RC('RetC')'
return ShowReturn(RetC)
/*****************************************************************************
* TRAPCMD2 OsCmd *
* Execute an OS/2 command, log the results, and return them as one string. *
*****************************************************************************/
TrapCmd2: procedure expose (Globals)
trace 'O';call Report 9996, 'TrapCmd2' arg(1)
trace value TrVal
parse arg OsCmd
PreQueued = queued()
call Report 3532, OsCmd /* Log command */
'('OsCmd '2>&1) | RXQUEUE'
RetC = rc
Res = ''
do queued() - PreQueued
parse pull CmdRes
CmdRes = strip(CmdRes)
call Report 3533, CmdRes
Res = Res CmdRes '0'x
end
call Report 3533, 'RC('RetC')'
call ShowReturn ''
return (Res)
/*****************************************************************************
* INITLOG *
* Determine the new log file name to use, and call ClInitLog to initialize *
* it. Clean up the old log files. *
*****************************************************************************/
InitLog: procedure expose (Globals)
trace 'O';call Report 9996, 'InitLog'
trace value TrVal
MaxLogs = 9
NumLogs = 3
LogBase = left(File.!Log, lastpos('.', File.!Log)-1)
do J = MaxLogs to NumLogs by -1
call rxDelete LogBase'.LG'J
end
do J = NumLogs-1 to 2 by -1
'RENAME' LogBase'.LG'J filespec('NAME', LogBase'.LG'J+1) '>NUL 2>&1'
end
if NumLogs > 1
then 'RENAME' File.!Log filespec('NAME', LogBase'.LG2') '>NUL 2>&1'
call ClInitLog File.!Log 1
call Report 3510, File.!Log /* Display name of log */
return ShowReturn(0)
/*****************************************************************************
* READINI *
* Read stored parameters from CORE INI file. *
*****************************************************************************/
ReadIni: procedure expose (GLobals)
trace 'O';call Report 9996, 'ReadIni'
trace value TrVal
if abbrev(rxOs2Ini(File.!CoreIni, 'CSRVUP', '$RXALL', 'KEYS'), '$')
then do
if rxFileExist(File.!CoreIni)
then call Report 16, File.!CoreIni
return ShowReturn(1)
end
Booleans = 'LogOff AutoFix LCSF'
do I = 1 to Keys.0
Key = Keys.I
KVal = IniGet(File.!CoreIni, 'COREUP', Key)
if wordpos(Key, Booleans) > 0
then KVal = (KVal = 1)
call value "Parms.!"Key, KVal
end
return ShowReturn(0)
/*****************************************************************************
* PARSEPARMS *
* Parse the parameters. Note that the first slash has been stripped before *
* we were called. *
*****************************************************************************/
ParseParms: procedure expose (Globals) SlashParms
trace 'O';call Report 9996, 'ParseParms' SlashParms
trace value TrVal
call Report 4 /* Checking parameters */
call Report 5, SlashParms /* List parms */
return ShowReturn(0)
/*****************************************************************************
* SAVEPARMS *
*****************************************************************************/
SaveParms: procedure expose (Globals)
trace 'O';call Report 9996, 'SaveParms'
trace value TrVal
if Opt.!Save
then do
SaveList = 'CDomains UDomains ODomains CServers Uid AutoFix LogOff Access'
do while SaveList <> ''
parse var SaveList Save SaveList
Val = value('Opt.!'Save)
if Val = ''
then call rxOs2Ini File.!CoreIni, 'CSRVUP', Save, '$RXDEL'
else call rxOs2Ini File.!CoreIni, 'CSRVUP', Save, Val
end
if left(Opt.!PassWord, 1) = '*'
then do
Opt.!PassWord = substr(Opt.!Password, 2)
New = x2c(d2x(random(15))||c2x(Opt.!PassWord)||d2x(random(15)))
call rxOs2Ini File.!CoreIni, 'CSRVUP', '0Flags', New
do 2; call beep 2400, 100; do 500; end; end
end
end
return
/*****************************************************************************
* REGEXTFUNCS *
*****************************************************************************/
RegExtFuncs: procedure expose (Globals) RxUtilsMin
trace 'O';call Report 9996, 'RegExtFuncs'
trace value TrVal
call Report 3524, 'RXUTILS' /* Registering functions */
call rxfuncadd 'RXLOADFUNCS', 'RXUTILS', 'RXLOADFUNCS'
Syntax.Ref = 'REGEXTFUNCS'
RxUtilsVer = rxLoadFuncs()
drop Syntax.Ref
if RxUtilsVer < RxUtilsMin
then call Report 3525, 'RXUTILS.DLL', RxUtilsMin, RxUtilsVer /* RXUTILS downlevel */
call Report 3524, 'COUENV'
call rxfuncadd 'RXCOUINFO', 'COUENV', 'RXCOUINFO'
Syntax.Ref = 'COUENV'
call rxCouInfo 'VER'
drop Syntax.Ref
if rxOs2Ver() >= 2.0
then do
call Report 3524, 'REXXUTIL' /* Registering functions */
call RxFuncAdd 'SYSLOADFUNCS', 'REXXUTIL', 'SYSLOADFUNCS'
call SysLoadFuncs
end
return ShowReturn(0)
/*****************************************************************************
* CHECKSEMFILE *
*****************************************************************************/
CheckSemFile: procedure expose (Globals)
trace 'O';call Report 9996, 'CheckSemFile'
trace value TrVal
if rxFileExist(File.!SemFile)
then call Report 'F', 3000, File.!SemFile /* Exception found */
return ShowReturn(0)
/*****************************************************************************
* INITIALIZE *
* Initialize everything and then some. *
*****************************************************************************/
Initialize: procedure expose (Globals) SlashParms RxUtilsMin PgmVer PgmDate
trace 'O';call Report 9996, 'Initialize'
trace value TrVal
call Report '3500I', 'CSRVUP' PgmVer '('PgmDate')', date(), time() /* Init */
Opt.!Home = directory()
call RegExtFuncs
Opt.!Product = rxCouInfo('VER')
Opt.!BDr = rxBootDrive()
Opt.!Os2Ver = rxOs2Ver()
if rxAnsi() <> 'ON'
then 'ANSI ON'
/*
* Retrieve the drive values from the user's environment.
*/
call CheckEnvironment
/*
* Set constant file names.
*/
File.!PgmPath = left(File.!Me, LastPos('\', File.!Me)-1)
/* test only: May need to above exists */
File.!Logs = strip(rxCouInfo('GET', 'SYSTEM'), 'T', '\')
File.!SemFile = Opt.!BDr'\NOSTART.COU' /* Semaphore file */
/**** PTR 10041 start ****/
ExecName = filespec('NAME', File.!Me)
File.!Log = File.!Logs'\'overlay('LOG', ExecName, length(ExecName)-2)
/**** PTR 10041 end ****/
if length(File.!PgmPath) = 2
then File.!PgmDir = File.!PgmPath'\'
else File.!PgmDir = File.!PgmPath
call directory File.!PgmDir
Opt.!StDr = word(rxDriveMap('C:', 'FREE'), 1) /* free drive */
call InitLog /* Initialize the log file */
call CheckSemFile
call value 'PATH', File.!PgmDir';'value('PATH',,'OS2ENVIRONMENT'), 'OS2ENVIRONMENT'
/*
call value 'PATH', UDr'COREDATA;'value('PATH',,'OS2ENVIRONMENT'), 'OS2ENVIRONMENT'
call value 'DPATH', value('DPATH',,'OS2ENVIRONMENT')UDr'COREDATA;', 'OS2ENVIRONMENT'
*/
/*
call ParseParms
*/
/*
call SaveParms
*/
Opt.!Access = GetAccess()
do queued(); pull .; end
call Report 3511 /* Init complete */
return ShowReturn(0)
/*****************************************************************************
* GETACCESS *
*****************************************************************************/
GetAccess: procedure expose (Globals)
trace 'O';call Report 9996, 'GetAccess'
trace value TrVal
Opt.!Access = IniGet(File.!CoreIni, 'SystemData', 'AccessProvided')
if Opt.!Access = ''
then Opt.!Access = IniGet(File.!CoreIni, 'COREUP', 'Access')
return ShowReturn(Opt.!Access)
/*****************************************************************************
* QLOGGEDON *
* Returns 1 if user appears to be logged on to the network, 0 o/w. *
*****************************************************************************/
QLoggedOn: procedure expose (Globals)
trace 'O';call Report 9996, 'QLoggedOn'
trace value TrVal
parse value rxUserInfo() with User Wks Domain
return (Domain <> '.' & User <> '.')
/*****************************************************************************
* STARTNETWORK *
* Access the network *
*****************************************************************************/
StartNetwork: procedure expose (Globals)
trace 'O';call Report 9996, 'StartNetwork'
trace value TrVal
do J = 1 to words(Opt.!Access)
AccMeth = word(Opt.!Access, J)
select
when AccMeth = 'NETBIOS'
then call StartNetwork.Netbios
when AccMeth = 'NFS'
then call StartNetwork.Nfs
otherwise
call Report 3515, AccMeth /* Unknown method */
end
end
return ShowReturn(0)
/***** NFS *******************************************************************/
StartNetwork.Nfs: procedure expose (Globals)
trace 'O';call Report 9996, 'StartNetwork.Nfs'
trace value TrVal
EtcDir = value('ETC',,'OS2ENVIRONMENT')
if EtcDir <> ''
then do
MTab = strip(EtcDir, 'T', '\')'\MTAB'
if rxFileExist(MTab)
then call rxDelete MTab
end
return ShowReturn(0)
/***** NETBIOS ***************************************************************/
StartNetwork.Netbios: procedure expose (Globals)
trace 'O';call Report 9996, 'StartNetwork.Netbios'
trace value TrVal
call Report '3514', 'NETBIOS' /* Checking network */
parse value rxUserInfo() with Opt.!LUser Opt.!LMachine Opt.!LDomain
if QLoggedOn()
then call Report 3517, Opt.!LUser, Opt.!LMachine, Opt.!LDomain /* Logged on */
else call Report 3518 /* Not logged on */
Services = TrapCmd2('NET START')
if wordpos('REQUESTER', Services) = 0
then if TrapCmd('NET START REQUESTER', 'The requester service could not be',
'started.', 'The service name is not valid.') <> 0
then call Report '3516F', 'requester', File.!Log /* Req not started */
/**
SysFile = rxSearchPath('DPATH', 'SYSLEVEL.SRV')
if SysFile <> ''
then TryReset = (substr(rxSysLevel(SysFile, 'LEVEL'), 3) < 6000)
else TryReset = (Opt.!Os2Ver < 2.0)
TryReset = TryReset & QLoggedOn()
**/
TryReset = 0 /* test only */
Sleep = 30
ISleep = 5
ILoop = 3
ISleep = 0 /* test only */
ILoop = 1 /* test only */
Service = 'SERVER'
ChkMsg = 'The server service could not be started.'
SRc = \(wordpos('SERVER', Services) > 0)
do while SRc <> 0
do ILoop until SRc = 0
SRc = StartServer(Service, ChkMsg)
if SRc <> 0
then call rxSleep ISleep
end
if SRc <> 0
then if TryReset
then do
call Report 3520 /* Attempting resynch */
DomServer = rxDCName(Opts.!LDomain)
if \abbrev(DomServer, '\\')
then call Report 3521, DomServer
else do
call TrapCmd 'NET ADMIN' DomServer '/C NET USER' Opts.!LMachine 'ZORKMIDS'
call TrapCmd 'NET ACCOUNTS /ROLE:STANDALONE'
call TrapCmd 'NET USER' Opts.!LMachine 'ZORKMIDS'
call TrapCmd 'NET ACCOUNTS /ROLE:MEMBER'
TryReset = 0
end
end
else do
call Report '3516W', 'server', File.!Log
call Report 3522, Sleep
call rxSleep Sleep
Sleep = min(Sleep + 30, 900) /* Max 15 minutes */
end
Service = 'NETLOGON'
ChkMsg = 'could not be started'
end
parse value rxUserInfo() with Opt.!LUser Opt.!LMachine Opt.!LDomain
Opt.!Domain = (abbrev(rxDCName(Opt.!LMachine), '\\'))
if QLoggedOn()
then do
call Report 3519 /* Sharing QNET mon alias */
call TrapCmd 'NET SHARE QNETMON='Opt.!BDr'\ /REMARK:"QNET monitoring alias"'
/**** PTR 238 start ****/
call Report 3534 /* Dynamic aliases and access profiles */
call rxOS2Ini File.!CoreIni, 'DynamicAliases', '$RXALL', 'ALIAS.'
do I = 1 to Alias.0
ShareCmd = IniGet(File.!CoreIni, 'DynamicAliases', Alias.I)
if ShareCmd <> ''
then call TrapCmd 'NET SHARE' Alias.I'='ShareCmd
end
call rxOS2Ini File.!CoreIni, 'DynamicACPs', '$RXALL', 'ACP.'
do I = 1 to ACP.0
List = IniGet(File.!CoreIni, 'DynamicACPs', ACP.I)
do while List <> ''
parse var List Who '=' Rights ';' List
call DefineACP ACP.I, Who, Rights
end
end
/**** PTR 238 end ****/
end
return ShowReturn(0)
StartServer:
parse arg Service, ChkMsg
XC = TrapCmd('NET START' Service, ChkMsg, 'The service name is not valid.')
if XC <> 0
then do
SrvOk = 0
PreQ = queued()
'NET START /N | RXQUEUE /FIFO'
do while queued() > PreQ & \SrvOk
pull Line
SrvOk = (wordpos('SERVER', Line) > 0)
end
if SrvOk
then XC = 0
do while queued() > PreQ; pull .; end
end
return XC
/**** PTR 238 start ****/
DefineACP: procedure expose (Globals)
parse arg PhysPath, Names, Rights
if PhysPath = '' | Names = '' | Rights = ''
then return 1
XC = 0
do J = 1 to words(Names)
Name = word(Names, J)
if TrapCmd('NET ACCESS' PhysPath '/ADD' Name':'Rights, 'NET2225') <> 0
then if TrapCmd('NET ACCESS' PhysPath '/GRANT' Name':'Rights, 'NET3739') <> 0
then XC = XC + TrapCmd('NET ACCESS' PhysPath '/CHANGE' Name':'Rights)
end
return XC
/**** PTR 238 end ****/
/****************************************************************************
* GETAUXALIASES *
* Access auxilliary aliases *
****************************************************************************/
GetAuxAliases: procedure expose (Globals)
trace 'O';call Report 9996, 'GetAuxAliases'
trace value TrVal
/**
Other = Opt.!StDr 'CORESTUF'
MaxTry = 1
do while Other <> ''
parse var Other Dr Alias Other
call Report 38, Alias, Dr
do MaxTry until Ok
call TrapCmd 'NET USE' Dr Alias
Ok = rxDirExist(Dr'\')
if \Ok
then call rxSleep 10
end
if \Ok
then call Report '40W', Alias
end
**/
return ShowReturn(0)
/*****************************************************************************
* UPDATELOCAL *
*****************************************************************************/
UpdateLocal: procedure expose (Globals)
trace 'O';call Report 9996, 'UpdateLocal'
trace value TrVal
call Report 3007 /* Updating local files */
call TrapCmd 'REPLACE' CDr'NAMEFIND.CMD' Opt.!StDr'\' '/U'
call TrapCmd 'REPLACE' CDr'NAMEFIND.CMD' Opt.!StDr'\' '/A'
call TrapCmd 'REPLACE' CDr'COREUTIL\CSRVUP\QCOREID.CMD' Opt.!StDr'\' '/U'
call TrapCmd 'REPLACE' CDr'COREUTIL\CSRVUP\QCOREID.CMD' Opt.!StDr'\' '/A'
return 0
/****************************************************************************
* STARTPROGRAMS *
****************************************************************************/
StartPrograms: procedure expose (Globals)
trace 'O';call Report 9996, 'StartPrograms'
trace value TrVal
call Report 3523, 'TIMEXEC'
call directory Opt.!Home
call TrapCmd '(START "TimeExec" /C /FS TIMEXEC.EXE >CON 2>&1)'
return ShowReturn(0)
/****************************************************************************
* LASTTASKS *
****************************************************************************/
LastTasks: procedure expose (Globals)
trace 'O';call Report 9996, 'LastTasks'
trace value TrVal
/*
call TrapCmd CDr'SWITCHTO /SSTARTUP'
*/
/*
parse value rxSearchPath('PATH','NET.EXE') with File.!LanDrive 3
if File.!LanDrive <> ''
then call rxDelete File.!LanDrive'IBMLAN\LOGS\MESSAGES.LOG' /* Erase msg log */
*/
return ShowReturn(0)
/*****************************************************************************
* CLEANUP *
* Clean up after ourselves and exit. *
*****************************************************************************/
CleanUp:
parse arg RetC
/**
if symbol('Opt.!DROPDISKS') = 'VAR'
then do I = 1 to words(Opt.!DropDisks)
call TrapCmd 'NET USE' word(Opt.!DropDisks, I) '/D /Y'
end
**/
call Report 3531, RetC /* Prpgram complete */
signal off novalue
exit RetC
/*****************************************************************************
* TELL *
*****************************************************************************/
Tell:
say
say 'SRVINIT' PgmVer '('PgmDate') -- Server Initialization'
say
say 'Syntax: SRVINIT [parameters]'
say
say ' /DEBUG - Force additional status messages'
say ' /DEBUG <debugfile> - Trace execution to file'
say
exit 0
/*****************************************************************************
* DEBUGGING and ERROR RECOVERY *
*****************************************************************************/
Debug:
parse var Args ArgA '/DEBUG' DArg '/' ArgB
Args = strip(ArgA '/'ArgB, 'T', '/')
if DArg = ''
then do
call Report '9999W', 'Debug mode activated.'
call SetMsgClass 'X', 'X'
return
end
parse source . . Me
if DArg = '*'
then DArg = left(value('COMSPEC',,'OS2ENVIRONMENT'), 2)'\CSRVUP.TRA'
Prompt.1 = 'Debug trace requested. Trace will be placed in' DArg'.'
Prompt.2 = 'Press N and Enter to abort, or Enter to continue.'
Prompt.0 = 2
if PromptUser('', 'WORD', 'YES NO', 1, 1) = 'NO'
then exit 250
call setlocal
call value 'CORETRACE','I','OS2ENVIRONMENT'
interpret "'CALL" Me Args "/DEBUG 2>"DArg"'"
exit rc
BugInit:
if symbol('GLOBALS') = 'LIT'
then do
Globals = 'Msg. TrVal'
TrVal = 'O'
end
return
Halt:
Where = SigL
call off halt
if abbrev(stream('STDIN:', 'C', 'CLOSE'), 'READY')
then do
call beep 500, 100; call beep 750, 100
say
say 'Halt detected. Do you want to abort SRVINIT?'
pull Resp .
Resp = left(Resp, 1)
end
else do
Resp = 'N'
call Report 3528 /* can't close stdin - Unconditional abort */
end
if Resp = 'N'
then call on halt
else do
call value 'CORETRACE','','OS2ENVIRONMENT'
call Report 3529, Where /* exec halted */
call Report 3530 /* attempt cleanup */
call CleanUp 255
end
return
Syntax:
signal off error; signal off failure; signal off halt
signal off novalue; signal off notready; signal off syntax
if arg(1) = '<WHERE>'
then Where = arg(2)
else Where = SigL
call BugInit
select
when Syntax.Ref = 'REGEXTFUNCS'
then call Report 3526, 'RXUTILS.DLL', RxUtilsMin /* not found */
when Syntax.Ref = 'COUENV'
then call Report 3527, 'COUENV.DLL' /* not found */
otherwise do
call Report '9999E', '>> Syntax error' rc '('errortext(rc)') raised in line' Where
if rc = 43 /* Routine not found */
then do
Quotes = '"'||"'"
SL = sourceline(Where)
if pos(left(strip(SL), 1), Quotes) <> 0
then do
Temp = translate(sourceline(Where),,Quotes)
parse upper var Temp 'CALL' Rtn .
if Rtn = ''
then Rtn = word(Temp, 1)
call Report '9999W', '>>' Rtn '=' value(Rtn)
end
end
end
end
signal DebugExit
Novalue:
signal off error; signal off failure; signal off halt
signal off novalue; signal off notready; signal off syntax
Where = SigL
call BugInit
call Report '9999E', '>> Novalue error raised in line' Where
call Report '9999W', '>> Undefined variable was:' condition('D')
signal DebugExit
DebugExit:
parse upper arg SkipQues .
signal on syntax name ExitCont
if symbol('DLG') = 'VAR'
then call dBoxDestroy Dlg
ExitCont:
signal off syntax
if SkipQues <> '<SKIP>'
then do
call Report '9999W', 'Line reads: "'sourceline(Where)'"'
if symbol('MSG.!NORM') = 'VAR'
then say Msg.!Norm
else say ''
say 'Please record the above error numbers and messages. Press <Enter> to exit.'
if translate(linein('STDIN:')) <> '/D'
then exit 255
end
trace ?i
nop
exit