$Job CMInstall
;
; Installation JCL for Context Manager II for use with 
;	Standard Software 12.1 and greater.
;
;
;
TRUE  = 255
FALSE = 0


;  Installation options
;


ASSIGN ClearScreen, '\\0Ch'

ErrorMsgFile = 'Cannot access message file'

; GLOBAL DECLARATIONS

FromFloppy = 0
FromTape   = 1
FromServer = 2
FromSWD    = 4
FromCDRom  = 5

SWDVersion = 2

RestoreFrom  = '\'<*>*\''
UnisysDir    = '<Unisys>'

$IF (SWDVersion = 2)
	SWDDir = DeviceFrom                       ; For SWD 2.2
$ELSE
	SWDDir = '[Sys]<CM65.1>'                  ; For SWD 3.0
$ENDIF

$IF PUBLIC

	FileSpec     = '[Sys]<sys>SysImage.Sys'
	SvrSysType   = FileVersion(FileSpec)
	ClstrSysType = FALSE
	
$ELSE

	FileSpec1    = '[Sys]<sys>SysImage.Sys'
	ClstrSysType = FileVersion(FileSpec1)
	SvrSysType   = FALSE
	
$ENDIF

; END GLOBAL DECLARATIONS

$IF (VideoLevel = 0)
	$PAUSEON 
$ENDIF; of Verbosity

$IF (VideoLevel = 2)
	$ECHOOFF
	;$ECHOSOME
$ENDIF; of Video Level

$IF Unattended
	$ECHOOFF
	$PAUSEOFF
$ENDIF; of Unattended


InitErc = InitMsgFile(MsgFile)
$IF InitErc > 0
	$DISPLAYLINE(ErrorMsgFile)
	$CANCEL
$ENDIF

ContinueMsg = GetMsg(3)
DoneMsg     = GetMsg(24)
RebootMsg   = GetMsg(48)
CM2of2Msg   = GetMsg(50)


$IF (InstallType = FromFloppy) and Unattended

	Msg1 = GetMsg(1)
	Msg2 = GetMsg(2)

	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE(Msg2)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)
	
	$DISPLAYANDWAIT
	
	$CANCEL
	
$ENDIF ; Invalid floppy installation

$IF (InstallType = FromServer) and (Public or (SvrSysType=ClstrSysType))

	Msg1 = GetMsg(4)

	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)
	
	$DISPLAYANDWAIT
	
	$CANCEL ; abort...abort
	
$ENDIF ; Invalid public installation

$DEASSIGN (ClstrSysType)
$DEASSIGN (SvrSysType)

$IF InstallType = FromTape

	Msg1 = GetMsg(52)

	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)
	
	$DISPLAYANDWAIT
	
	$CANCEL
	
$ENDIF ; Invalid tape installation


$IF PUBLIC  
	
	SysToSpec    = '[Sys]<Sys>'
	RstoretoSpec = '\'[Sys]<Sys>*\''

$ELSE
	
	SysToSpec    = '[Sys]<Sys>'
	RstoretoSpec = '\'[Sys]<Sys>*\''

$ENDIF

ToSpec = ConcatStrings(VolumeTo, '<Sys>')

;*******************  START INSTALLATION HERE  *********************

Msg1  = GetMsg(5)
Msg2  = GetMsg(6)
Msg3  = GetMsg(7)
Msg4  = GetMsg(8)
Msg5  = GetMsg(9)
Msg6  = GetMsg(10)
Msg7  = GetMsg(11)
Msg8  = GetMsg(12)
Msg9  = GetMsg(13)
Msg10 = GetMsg(51)

$IF (InstallType <> FromSWD) AND (InstallType <> FromCDRom) AND  
    (NOT Unattended)

	$DISPLAYLINE(ClearScreen)

	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(Msg2)
	$DISPLAYLINE(Msg3)
	$DISPLAYLINE
	$DISPLAYLINE(Msg4)
	$DISPLAYLINE(Msg5)
	$DISPLAYLINE
	$DISPLAYLINE(Msg6)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg10)
	$DISPLAYLINE(Msg8)
	$DISPLAYLINE
	$DISPLAYLINE(Msg7)
	$DISPLAYLINE(Msg8)
	$DISPLAYLINE(Msg9)

	$DISPLAYANDWAIT

	Msg1 = GetMsg(14)
	Msg2 = GetMsg(15)
	Msg3 = GetMsg(16)
	Msg4 = GetMsg(17)
	Msg5 = GetMsg(18)
	Msg6 = GetMsg(19)
	Msg7 = GetMsg(20)
	Msg8 = GetMsg(21)

	DISPLAYLINE(ClearScreen)

	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(Msg2)
	$DISPLAYLINE(Msg3)
	$DISPLAYLINE
	$DISPLAYLINE(Msg4)
	$DISPLAYLINE(Msg5)
	$DISPLAYLINE
	$DISPLAYLINE(Msg6)
	$DISPLAYLINE(Msg7)
	$DISPLAYLINE
	$DISPLAYLINE(Msg8)

	$DISPLAYANDWAIT

$ENDIF

Msg1 = GetMsg(22)
Msg2 = GetMsg(23)
Msg3 = GetMsg(26)

$DISPLAYLINE(ClearScreen)  ; clear the screen
$DISPLAYLINE
$DISPLAYLINE
$DISPLAYLINE
$DISPLAYLINE(Msg1)
$DISPLAYLINE

			
$RESTARTLABEL
$DISPLAY(Msg2)

DelSpec1 = ConcatStrings(SysToSpec,'cmconfigeditor.run')
DelSpec2 = ConcatStrings(SysToSpec,'request.7.sys')
DelSpec3 = ConcatStrings(SysToSpec,'cmcalls.obj')
DelSpec4 = ConcatStrings(SysToSpec,'cmrqlabl.obj')

$COMMAND Delete,(DelSpec1,DelSpec2,DelSpec3,DelSpec4)

$DEASSIGN(DelSpec1)
$DEASSIGN(DelSpec2)
$DEASSIGN(DelSpec3)
$DEASSIGN(DelSpec4)

$DISPLAYLINE(DoneMsg)

$IF InstallType = FromFloppy
	CopyFrom = ConcatStrings('[B25CM61]',UnisysDir)
$ENDIF

$IF InstallType = FromSWD
	CopyFrom = SWDDir
$ENDIF

$IF InstallType = FromCDRom
	CDSpecFrom = ConcatStrings(DeviceFrom,'<CM65.1.0>')
$ENDIF

$RESTARTLABEL
$DISPLAYLINE
$DISPLAYLINE(Msg3)

$DISPLAYLINE
$ECHOSOME

$IF InstallType = FromServer

    $COMMAND LCopy                                     ,
                                                       ,
              @[Scr]<$>InstallOverwriteOkFrom.fls      ,
              @[Scr]<$>InstallOverwriteOkTo.fls        ,
                                                       ,
              Yes                                      ,
              No                                       ,
              No

	$DISPLAYLINE
	
    $COMMAND LCopy                                     ,
                                                       ,
              @[Scr]<$>InstallOverwriteNoFrom.fls      ,
              @[Scr]<$>InstallOverwriteNoTo.fls        ,
                                                       ,
              No                                       ,
              No                                       ,
              No
              
$ENDIF

$IF (InstallType = FromFloppy) OR (InstallType = FromSWD)

	$COMMAND LCopy,(CmInstall.Run,CmInvoker.Run,CmEditor.Run,CmInstallMsg.Bin,CmConfigMsg.Bin,Request.Cm.Sys,CmConfigFrm.Lib,CmAPI.Lib),CopyFrom,ToSpec,,yes,no,no
	
	$DISPLAYLINE
	
	$COMMAND LCopy,(CmConfig.Sys,Cm.User),CopyFrom,SysToSpec,,no,no,no
	
$ENDIF
	
$IF InstallType = FromCDRom

	$COMMAND LCopy,(CmInstall.Run,CmInvoker.Run,CmEditor.Run,CmVm.Run,CmScreen.Run,CmNull.Run,ICMS.Run,CmInstallMsg.Bin,CmConfigMsg.Bin,CmScreenMsg.Bin,CmVmMsg.Bin,Request.Cm.Sys,CmConfigFrm.Lib,CmAPI.Lib),CDSpecFrom,ToSpec,,yes,no,no
	
	$DISPLAYLINE
	
	$COMMAND LCopy,(CmConfig.Sys,Cm.User),CDSpecFrom,SysToSpec,,no,no,no
	
$ENDIF
	
$ECHOOFF


; Add Context Manager commands to the default command file
;

Msg1 = GetMsg(27)

$RESTARTLABEL
$DISPLAYLINE
$DISPLAYLINE(Msg1)

$DISPLAYLINE
$ECHOSOME

$COMMAND Merge Command Files, CmdFileFrom, CmdFileTo, yes, VolumeTo

$IF PUBLIC

	CmdFile = '[Sys]<Sys>Install>English.Cmds'

	$COMMAND New Command,                                     
	'CM Add Application',                                     
	[Sys]<Sys>CmEditor.Run,                                  
	('[Config File Name]','Application','Run File','Memory Required','[Abbreviation]','[Function Key]','[Command Case]','[Volume]','[Directory]','[Prefix]','[Password]','[Node]','[Autostart ordering]','[Needs Invoker?]','[Overwrite OK?]','[More Information]','[Color]','[Resolution]','[Partition name]'),   
	'Add an application to the CM Configuration File.',       
	yes,                                                      
	01,                                                       
	CmdFile,                                                  
	no

				
	$COMMAND New Command,                                     
	'CM Remove Application',                                  
	[Sys]<Sys>CmEditor.Run,                                  
	('Application','[Config File Name]'),                     
	'Remove an application from the CM Configuration File.',  
	yes,                                                      
	02,                                                       
	CmdFile,                                                  
	no
	
	$DEASSIGN(CmdFile)
	
$ENDIF

$ECHOOFF

$IF InstallType = FromFloppy

	DiskType = FileVersion('[B25CM61]<Sys>Context Manager II Diskette 1 of 1')
	
	$IF DiskType = '0'
	
		;The above file is not present, therefore the installation is 
		;from 5 media.
	
		$DISPLAYLINE(ClearScreen)  ; clear the screen

		$NEXTFLOPPY(CM2of2Msg)
		
		CopyFrom = ConcatStrings('[B25CM62]',UnisysDir)
		
	$ENDIF
	
$ENDIF

$IF (InstallType = FromFloppy) OR (InstallType = FromSWD)

	Msg1 = GetMsg(28)

	$RESTARTLABEL
	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE(Msg1)

	$DISPLAYLINE
	$ECHOSOME

	$COMMAND LCopy,(CmNull.Run,ICMS.Run,CmScreenMsg.Bin,CmScreen.Run,CmVmMsg.Bin,CmVm.Run),CopyFrom,ToSpec,,yes,no,no
	
$ENDIF

; 			
;  INSTALL THE CM REQUESTS
;

Msg1 = GetMsg(29)
Msg2 = GetMsg(30)
Msg3 = GetMsg(31)


$RESTARTLABEL
$DISPLAYLINE
$DISPLAYLINE
$DISPLAYLINE(Msg1)
$DISPLAYLINE

CmRequests = ConcatStrings(ToSpec,'Request.CM.Sys')
ReqFile    = ConcatStrings(SysToSpec,'Request.Sys')
TempFile   = ConcatStrings(SysToSpec,'NewRequestFile.tmp')

$DISPLAYLINE
$DISPLAYLINE(Msg2)

$DISPLAYLINE
$ECHOSOME

$COMMAND List Request Set,(CmRequests, ReqFile),TempFile
	
$DISPLAYLINE
$DISPLAYLINE(Msg3)
$DISPLAYLINE
	
$COMMAND Make Request Set,TempFile,ReqFile

; Remove the temp file
$DISPLAYLINE
$COMMAND Delete,TempFile 

$ECHOOFF


$IF (InstallType <> FromSWD) AND (InstallType <> FromCDRom) AND   
    (NOT Unattended)

	Msg1 = GetMsg(32)

	$DISPLAYLINE(ClearScreen)  ; clear the screen
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)
	$DISPLAYLINE

	$DISPLAYANDWAIT
	
$ENDIF

Msg1  = GetMsg(33)
Msg2  = GetMsg(34)
Msg3  = GetMsg(35)
Msg4  = GetMsg(36)
Msg5  = GetMsg(37)
Msg6  = GetMsg(38)
Msg7  = GetMsg(39)
Msg8  = GetMsg(40)
Msg9  = GetMsg(42)
Msg10 = GetMsg(43)

$IF (InstallType <> FromSWD) AND (InstallType <> FromCDRom) AND  
    (NOT Unattended)

	$DISPLAYLINE(ClearScreen)  ; clear the screen

	$DISPLAYLINE(Msg1)
	$DISPLAYLINE(Msg2)
	$DISPLAYLINE(Msg3)
	$DISPLAYLINE
	$DISPLAYLINE(Msg4)
	$DISPLAYLINE(Msg5)
	$DISPLAYLINE(Msg6)
	$DISPLAYLINE(Msg7)
	$DISPLAYLINE
	$DISPLAYLINE(Msg8)
	$DISPLAYLINE
	$DISPLAYLINE(Msg9)
	$DISPLAYLINE(Msg10)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)
	
	$DISPLAYANDWAIT

	Msg1 = GetMsg(44)
	Msg2 = GetMsg(45)
	Msg3 = GetMsg(46)
	Msg4 = GetMsg(47)

	$DISPLAYLINE(ClearScreen)  ; clear the screen
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE(Msg2)
	$DISPLAYLINE(Msg3)
	$DISPLAYLINE(Msg4)
	$DISPLAYLINE									
	$DISPLAYLINE(ContinueMsg)
	$DISPLAYLINE

	$DISPLAYANDWAIT
	
$ENDIF
		
$IF (InstallType = FromServer) AND (NOT Unattended)

	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(RebootMsg)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)

	$DISPLAYANDWAIT
	
$ENDIF

$IF InstallType = FromFloppy

	Msg1 = GetMsg(49)

	$DISPLAYLINE(ClearScreen)
	$DISPLAYLINE
	$DISPLAYLINE
	$DISPLAYLINE(Msg1)
	$DISPLAYLINE
	$DISPLAYLINE(RebootMsg)
	$DISPLAYLINE
	$DISPLAYLINE(ContinueMsg)

	$DISPLAYANDWAIT
	
$ENDIF


$END
Invoker.Run,CmEditor.Run,CmInstallMsg.Bin,CmConfigMsg.Bin,Request.Cm.Sys,CmConfigFrm.Lib,CmAPI.Lib),CopyFrom,ToSpec,,yes,no,no
	
	$DISPLAYLINE
	
	$COMMAND LCopy,(CmConfig.Sys,Cm.User),CopyFrom,SysToSpec,,no,no,no
	
$ENDIF
	
$IF InstallType = FromCDRom

	$COMMAND LCopy,(CmInstall.Run,CmInvoker.Run,CmEditor.Run,CmVm.Ru