MediaCheck = 2;$Job ProtMgrInstall

$PauseOff

$RestartLabel

; this is a floppy install of CTOS Protocol Manager
; to Localize, change messages at top and search for '$Command', then change.

; suppress video pause
		
	$PauseOff

	; nationalizable strings

InstDoneMsg = 'When installation is completed, please reboot your system.'
DoneMsg = 'done.'
UnAtndMsg1 = '          Unattended floppy installation is not supported.'
QicMsg = ' QIC Tape  installation is not supported.'
CancelMsg = '                  INSTALLATION IS CANCELLED'
AnyKeyMsg = '                  Press Any Key to Continue.'
GoMsg = '                       Press GO to Continue.'
MergeMsg = 'CEFUpdating request files.  This may take some time ... '
	NewPage = '\\0Ch'
	
; The following line defines this installation as a floppy installation.  You 
; will need to change this to [QIC]0 for tape installation.
; It is only necessary for the current Floppy Installation command when it
; is used instead of the Installation Manager command.  This will not be
; necessary in 12.1 or above.

;;  In fact, it must be absent in 12.1 or above

;	DeviceFrom = '[F0]'

$DisplayLine(NewPage)

; determine whether to install files to the server or to the local system

	$If Public 
	
; public installation should write the commands to the file on the 
; server [Sys]<Sys>Cluster.cmds rather than [Sys]<Sys>Sys.cmds which
; is the default
		DestSpec = '[Sys]<Sys>'
		DefVol = '[Sys]'
		CmdFileTo = '[Sys]<sys>Cluster.cmds'
		ReqFile = '[sys]<sys>Request.sys'

; if not a server or srp, the default is the local [Sys] directory

	$Else
		DestSpec = '[Sys]<Sys>'
		DefVol = '[Sys]'
		CmdFileTo = '[Sys]<sys>Sys.cmds'
		ReqFile = '[sys]<sys>Request.sys'
	$EndIf




; this parameter is set in case you are installing something on a local
; system but some files have to be on the server

;	$If Public AND (SystemType = CLSTRLFS)
;		CopyLocal = TRUE
;	$Else
;		CopyLocal = FALSE
;	$EndIf

; path to floppy 

	$Path ,DeviceFrom, Sys

; give the user the option to install basic software with all options
; this option will default to yes to accomodate unattended installation

; The UnAttended Mode is NOT SUPPORTED on floppy installations, therefore,
; only use this option on nonfloppy (tape or hard disk) installations

	$If Unattended
		$DisplayLine
		$DisplayLine
		$DisplayLine
		$DisplayLine
		$DisplayLine
		$DisplayLine (UnAtndMsg1)
		$DisplayLine
		$DisplayLine (CancelMsg)
		$DisplayLine (GoMsg)
		$DisplayLine
		$DisplayLine
		$DisplayLine
		$Path,Sys,Sys
		$DisplayAndWait
		$Cancel
	$EndIf

	$If InstallType = 1
		$DisplayLine (QicMsg)
		$DisplayLine (CancelMsg)
		$DisplayLine (AnyKeyMsg)
		$Path,Sys,Sys
		$DisplayAndWait
		$Cancel
	$EndIf

;	$If InstallType = 2
;		$DisplayLine (ServerMsg)
;		$DisplayLine (CancelMsg)
;		$DisplayLine (AnyKeyMsg)
;		$Path,Sys,Sys
;		$DisplayAndWait
;		$Cancel
;	$EndIf


;	$RestartLabel
;	$If VideoLevel>0
;		VidLev = 1
;	$EndIf

$RestartLabel
; check version of Protocol Manager already installed.
	HardDiskSpec = ConcatStrings (DestSpec, 'ProtocolManager.run')
	VerHardDisk = FILEVERSION (HardDiskSpec)
	$Deassign (HardDiskSpec)

	$If (VerHardDisk = '0')
		$Deassign (VerHardDisk)
		$Goto Done_Version
	$Endif

	VerTarget = ConcatStrings (DeviceFrom, '<CTOS>ProtocolManager.run')
	VerFloppy = FILEVERSION (VerTarget)
	$Deassign (VerTarget)

	iMarkHD = SubString('.', VerHardDisk)
	iMarkFD = SubString('.', VerFloppy)
	iMarkHD2 = iMarkHD  1
	iMarkFD2 = iMarkFD  1
	MarkHD = CopyString(VerHardDisk, 1, iMarkHD2)
	MarkFD = CopyString(VerFloppy, 1, iMarkFD2)
	$Deassign (iMarkHD2)
	$Deassign (iMarkFD2)
;	$Display (MarkHD)
;	$Display (MarkFD)
	MarkVerHD = StrToNum(MarkHD)
	MarkVerFD = StrToNum(MarkFD)
	$Deassign (MarkHD)
	$Deassign (MarkFD)
	$If (MarkVerHD > MarkVerFD)
		$ContinueOnError
		$Deassign (MarkVerHD)
		$Deassign (MarkVerFD)
		$Goto End_of_file
	$EndIf
	$If (MarkVerHD < MarkVerFD)
		$Deassign (MarkVerHD)
		$Deassign (MarkVerFD)
		$Goto Done_Version
	$EndIf
	$Deassign (MarkVerHD)
	$Deassign (MarkVerFD)

; the mark release versions are equal.
	sVerHD	= StringLength(VerHardDisk)
	sVerFD	= StringLength(VerFloppy)
	iMarkHD2 = iMarkHD + 1							
	iMarkFD2 = iMarkFD + 1						
	sVerHDx	= sVerHD  iMarkHD2						;Vish 1693
	sVerFDx	= sVerFD  iMarkFD2						;Vish 1693
	$Deassign (iMarkHD)
	$Deassign (iMarkFD)
;	VerHD2	 = CopyString(VerHardDisk, iMarkHD2, sVerHD) ;Vish 1693
;	VerFD2	 = CopyString(VerFloppy,   iMarkFD2, sVerFD) ;Vish 1693
	VerHD2	 = CopyString(VerHardDisk, iMarkHD2, sVerHDx) ;Vish 1693
	VerFD2	 = CopyString(VerFloppy,   iMarkFD2, sVerFDx) ;Vish 1693

	$Deassign (sVerHD)
	$Deassign (sVerFD)
	$Deassign (VerHardDisk)
	$Deassign (VerFloppy)
	$Deassign (iMarkHD2)
	$Deassign (iMarkFD2)
	iPointHD = SubString('.', VerHD2)
	iPointFD = SubString('.', VerFD2)
	PointHD = CopyString(VerHD2, 0, iPointHD)
	PointFD = CopyString(VerFD2, 0, iPointFD)
;	$Display (PointHD)
;	$Display (PointFD)
	PointVerHD = StrToNum(PointHD)
	PointVerFD = StrToNum(PointFD)
	$Deassign (PointHD)
	$Deassign (PointFD)
	$If (PointVerHD > PointVerFD)
		$ContinueOnError
		$Deassign (PointVerHD)
		$Deassign (PointVerFD)
		$Goto End_of_file
	$EndIf
	$If (PointVerHD < PointVerFD)
		$Deassign (PointVerHD)
		$Deassign (PointVerFD)
		$Goto Done_Version
	$EndIf
	$Deassign (PointVerHD)
	$Deassign (PointVerFD)

; the mark and point release versions are equal
	iPointHD2 = iPointHD + 1
	iPointFD2 = iPointFD + 1
	$Deassign (iPointHD)
	$Deassign (iPointFD)
	VerHD3	 = CopyString(VerHD2, iPointHD2, 4)
	VerFD3	 = CopyString(VerFD2, iPointFD2, 4)
	$Deassign (VerHD2)
	$Deassign (VerFD2)
	$Deassign (iPointHD2)
	$Deassign (iPointFD2)
;	$Display (VerHD3)
;	$Display (VerFD3)
	PatchVerHD = StrToNum(VerHD3)
	PatchVerFD = StrToNum(VerFD3)
	$Deassign (VerHD3)
	$Deassign (VerFD3)
	$If (PatchVerHD >= PatchVerFD)
		$ContinueOnError
		$Deassign (PatchVerHD)
		$Deassign (PatchVerFD)
		$Goto End_of_File
	$EndIf
	$Deassign (PatchVerHD)
	$Deassign (PatchVerFD)

; GO HERE as exit point for above logic
; should only get here if file on floppy has a higher version number
; than the file on the hard disk
Done_Version:

	$DisplayLine
	$DisplayLine
	$DisplayLine
;	$Display (RemCmdMsg)
$If Public
; remove Data Link Manager commands and run files.
	$Run ([Sys]<Sys>CmdFileEditor.run,, 'RC'), 
			('Install Data Link Manager', 
			 'Deinstall Data Link Manager', 
			 'Data Link Manager Monitor'), 
			 CmdFileTo, yes
$Else
	$Run ([Sys]<Sys>CmdFileEditor.run,, 'RC'), 
			('Install Data Link Manager', 
			 'Deinstall Data Link Manager', 
			 'Data Link Manager Monitor'), 
			 CmdFileTo
$Endif
;	$DisplayLine (Donemsg)

; Localize the command in the line below.
	$Command Delete, ([Sys]<Sys>DLM.Run, [Sys]<Sys>DLMDeinstall.run, 
				[Sys]<Sys>DLMMonitor.Run, [Sys]<Sys>DLMMsg.Bin,
				[Sys]<Sys>DLMStatMsg.Bin)

$RestartLabel
; copy standard files from floppy

	$DisplayLine
	$DisplayLine
	$DisplayLine
;	$Display (FloppyFiles)
	$Run [Sys]<Sys>Lcopy.run,(ProtocolManager.run,  
		PM.E_CommonConfig.sys, PM.E_CommonConfig.hlp, 
		ProtocolManagerMonitor.run, ProtocolManagerMsg.bin),  
		<CTOS>,DestSpec,,y,,n,y
	HardDiskSpec = ConcatStrings (DestSpec, 'DLM.Run')
	$Command Copy, <CTOS>ProtocolManager.Run, HardDiskSpec
	$Deassign (HardDiskSpec)
;; Below for Public installation
	$If Public
		$Run [Sys]<Sys>Lcopy.run,ProtMgr.Cmds, <Sys>, DestSpec,,y,,n,y
		InstalldSpec = ConcatStrings (DefVol, '<Installed>')
		$Run [Sys]<Sys>Lcopy.run,ProtMgr.Cmds, <Sys>, InstalldSpec,,y,,n,y
	$EndIf
;	$DisplayLine (Donemsg)

;	Show advertisement while merging request files 

$Display(NewPage)
$DisplayLine('Unisys Round Valley Engineering introduces AEDIRECT ACCESSAA')
$DisplayLine
$DisplayLine('This Custom Service puts you in direct contact with engineering')
$DisplayLine('expertise for')
$DisplayLine('	Enterprisewide Mail Network Planning and Integration')
$DisplayLine('	Windows NT Integration and LAN Consolidation')
$DisplayLine('	Assistance with ClientServer Application Development')
$DisplayLine('	Customized Network Enhancements')
$DisplayLine('	Application Development utilizing APIs such as SNA, OSI, EMail')
$DisplayLine('	Network Training such as SNA, LANce')
$DisplayLine('	Site Audits, including Upgrade Recommendations')
$DisplayLine('	Network Performance Evaluation and Analysis')
$DisplayLine('	Installation, Configuration, and Network Performance Tuning')
$DisplayLine
$DisplayLine('For more information, or to request services not listed above,')
$DisplayLine('contact your Unisys Representative or call the Round Valley Custom')
$DisplayLine('Services hotline')
$DisplayLine('Tel:19082365199 or FAX: 19082365065')

; merge request files with local request file

	$Display (MergeMsg)
	$If Public
		$Run [Sys]<sys>ListRqSet.run,ReqFile,[scr]<$>x,
		ReqTarget = ConcatStrings (DeviceFrom, '<Sys>Request.ProtMgr.Sys')
		$Run [Sys]<sys>ListRqSet.run, ReqTarget, [scr]<$>y,
		$Run [Sys]<sys>MakeRqset.run, ([scr]<$>x,[scr]<$>y), 
			 		ReqFile
	$Else
		$Run [Sys]<sys>ListRqSet.run,ReqFile,[scr]<$>x,
		ReqTarget = ConcatStrings (DeviceFrom, '<Sys>Request.ProtMgr.Sys')
		$Run [Sys]<sys>ListRqSet.run, ReqTarget, [scr]<$>y,
		$Run [Sys]<sys>MakeRqset.run, ([scr]<$>x,[scr]<$>y), 
			 		ReqFile
	$EndIf
$Display (DoneMsg)

; merge standard command file with user selected command file

	$Displayline
;	$Display (CommandMsg)

	$If Public
		$Run ([Sys]<Sys>CmdFileEditor.run,, 'MC'), 
			<Sys>ProtMgr.cmds, CmdFileTo, yes, DefVol
	$Else
		$Run ([Sys]<Sys>CmdFileEditor.run,, 'MC'), 
			<Sys>ProtMgr.cmds, CmdFileTo, yes, DefVol
	$EndIf
;	$Displayline (DoneMsg)

; make some space on the screen so the message is more noticable

	$DisplayLine(NewPage)
	$Displayline (InstDoneMsg)
	$DisplayLine (GoMsg)

	i = 0
	$While i < 8
		i = i + 1
		$DisplayLine
	$EndWhile

; The use of display and wait will cause a hang in attended or SWD mode so
; those conditions must be tested for.  (SWD not yet supported)

;$If InstallType <> SftwrDist 

	$If Not Unattended
		$DisplayAndWait
	$EndIf
;$EndIf

	$Path ,Sys, Sys

End_of_file:
 
; $Deassign (i)
; $Deassign (RemCmdMsg)
 $Deassign (InstDoneMsg)
; $Deassign (DoneMsg)
; $Deassign (No)
; $Deassign (Yes)
; $Deassign (CommandMsg)
; $Deassign (FloppyFiles)
; $Deassign (MergeMsg)
 $Deassign (UnAtndMsg1)
; $Deassign (ServerMsg)
 $Deassign (QicMsg)
 $Deassign (CancelMsg)
 $Deassign (AnyKeyMsg)
 $Deassign (GoMsg)
; $DeAssign (TRUE)
; $DeAssign (FALSE)
; $DeAssign (CLSTRLFS)
 $DeAssign (DeviceFrom)
 $DeAssign (DefVol)
 $DeAssign (CmdFileTo)
 $DeAssign (ReqFile)
; $DeAssign (CopyLocal)
 $DeAssign (DestSpec)

$END
String(VerHD2, iPointHD2, 4)
	VerFD3	 = CopyString(VerFD2, iPointFD2, 4)
	$Deassign (VerHD2)
	$Deassign (VerFD2)
	$Deassign (iPointHD2)
	$D