$JOB RAFSInstall
;Install.jcl (RAF Source Installation for 3 12 diskette)

; SWD version 
; Notes on using SWD 3.0 or greater:
;	Change SwdVer (below) to 3 (or 4)
;	In Software Registration Object Registration (or Package Registration)
;		specify RAFS321 for SRDIR
;	In Software Registration
;		select B25RAFS$3_2_1
;	In Prepare Software Distribution
;		select B25RAFS$3_2_1
;		specify RFS for Release ID
;		specify RFSRAFS321 for SWD Installation Directory
;	In Software Distribution
;		select RFS
; If installing both RAF Source and RAF Target to the same node, if
; you change the defaults for RAFConfig.sys, make the SAME change
; in both packages, as the second package will overwrite the first.
SwdVer = 3

fInstalled = 0
fRAFSrcInst = 0
fMPInst     = 0
fCopyFiles = 1
Floppy     = 0
Tape       = 1
FromServer = 2
NotFound   = 65535
DoneMsg    = ' done.'
SrcYesNoMsg = 'Do you want to install RAF Source?'  ;ganti
MPYesNoMsg = 'Do you want to install Message Posting?' ;ganti
NumberOfPack = 1

; If using SWD, select packages desired
$IF (InstallType = 4)
	RAFpackage = 1
	mpPackage = 1
	ddPackage = 1
	spPackage = 1
	Srvpackage3 = 1
	Srvpackage4 = 1
$ELSE
	RAFpackage = NotFound
	mpPackage = NotFound
	ddPackage = NotFound
	spPackage = NotFound
	Srvpackage3 = NotFound
	Srvpackage4 = NotFound
$ENDIF
; SendEvent = 1


CopyRtMsg1 = 'Copyright  1993 Unisys Corporation.'
CopyRtMsg2 = 'All rights reserved.'
CopyRtMsg3 = 'UNISYS PROPRIETARY'

FileSpec   ='[sys]<sys>SysImage.sys'
SvrSysType = FileVersion(FileSpec)
FileSpec1   ='[sys]<sys>SysImage.sys'
ClstrSysType =  FileVersion(FileSpec1)

$IF (InstallType <> 4)	;	all InstallTypes except SWD
	$DISPLAYLINE
	$DISPLAYLINE(CopyRtMsg1)
	$DISPLAYLINE(CopyRtMsg2)
	$DISPLAYLINE(CopyRtMsg3)
	$DISPLAYLINE
	$DEASSIGN (CopyRtMsg1)
	$DEASSIGN (CopyRtMsg2)
	$DEASSIGN (CopyRtMsg3)
$ENDIF	;	all InstallTypes except SWD

$IF (InstallType=FromServer) AND (Public OR (SvrSysType=ClstrSysType))
	$IF VideoLevel = 2
		$DisplayLine
		$DisplayLine
$Displayline('AE Public installation from server is invalid.      AA')
$Displayline('AE                                Press GO to exit  AA')
		$DisplayLine
		$DisplayLine
	$ENDIF   ; end if videolevel
	$DisplayAndWait
	$Cancel
$ENDIF

$Deassign(SvrSysType)
$Deassign(ClstrSysType)

$IF (InstallType = Tape) OR RunningonSRP   ;if installation type is TAPE
	$IF VideoLevel = 2
		$DisplayLine
		$DisplayLine
$Displayline('AE Installation from TAPE is invalid.               AA')
$Displayline('A                                 Press GO to exit  AA')
		$DisplayLine
		$DisplayLine
	$ENDIF   ; end if videolevel
	$DisplayAndWait
	$Cancel
$ENDIF   ; end of if type is TAPE

$IF Unattended AND (InstallType = Floppy)
	$IF VideoLevel = 2
		$DisplayLine
		$DisplayLine
$Displayline('AEUnattended mode is not supported on floppy installation.AA')
$Displayline('AE                                    Press GO to exit    AA')
		$DisplayLine
		$DisplayLine
	$ENDIF   ; end if videolevel
	$DisplayAndWait
	$Cancel
$ENDIF
	
$RestartLabel

; SWD ( Software Distribution ) variables
$ASSIGNLOCAL SWD, 4
$IF (SwdVer = 2)
   $ASSIGNLOCAL SwdSpec, DeviceFrom                         ; SWD 2.0
$ELSE
   $ASSIGNLOCAL SwdSpec, '[Sys]<RFSRAFS321>'               ; SWD 3.0 or above
$ENDIF
; SWD variables end

$IF PUBLIC
	$Path,		
		sys,	
		Sys

	ToSpec = '[sys]<sys>'
	DefVol = '[Sys]'
	ToInst = '[sys]<installed>RAFSource>3.2>'
    $IF (InstallType = SWD)
    	FromSys = SwdSpec
		$Command LCopy,Request.RAF.sys,FromSys,ToInst,,yes,no,no    
    $ELSE
    	CmdFileTo = '[Sys]<sys>Cluster.cmds'
	    FromSys = ConcatStrings(DeviceFrom, '<Sys>')
    $ENDIF
	$Command LCopy,(Install,DirectD,ProfileU,MessageP),		
				FromSys,ToInst,.cmds,yes,no,no    
	$Command LCopy,(Install.jcl, Install.ctrl),FromSys,ToInst,,yes,no,no
	$Deassign (ToInst)
	$Deassign (FromSys)
$ELSE
	$Path,	
		sys,	
		Sys
	ToSpec = '[sys]<sys>'
	DefVol = '[Sys]'
$ENDIF ; of Public

$IF (InstallType = SWD)  ; if installation is SWD
	ddpackage = 1
	sppackage = 1
	InstallFrom = SwdSpec
	CmdSpec = ConcatStrings(SwdSpec, 'Install.cmds')
$ENDIF ; if SWD

$IF (InstallType = Floppy)  ; if installation is FLOPPY
	InstallFrom = ConcatStrings(DeviceFrom, '<Unisys>')
	CmdSpec = ConcatStrings(DeviceFrom, '<Sys>Install.cmds')
$ENDIF   ; end of IF installtype = floppy

$IF (InstallType = FromServer)  ; if installation is From the Server
	InstallFrom = '[sys]<sys>'
	CmdSpec = '[Sys]<installed>RAFSource>3.2>Install.cmds'

	SrvMenu1	= 'Server Installation Menu'
	Option1		= 'RAF Source Installation'
	Option2		= 'Message Posting Installation'

	Srvpkgs	= $userselectmultiple(SrvMenu1,Option1,Option2)
	RAFPackage	= substring(Option1, Srvpkgs)
	mppackage	= substring(Option2, Srvpkgs)

	$IF (RAFPackage = NotFound) AND (mppackage = NotFound)
		$Cancel
	$ELSE
		SrvMenu2	= 'Select Type of Installation'
		Option3		= 'Use Files and Commands from Server'
		Option4		= 'Copy All Commands and Files Locally'

		SrvInstType	= $userselectsingle(SrvMenu2,Option3,Option4)
		Srvpackage3	= substring(Option3, SrvInstType)
		Srvpackage4	= substring(Option4, SrvInstType)

		$IF (Srvpackage3	< NotFound)
			fCopyFiles	= 0
			fInstalled	= 1
		$ENDIF
	$ENDIF

	$IF (RAFPackage	< NotFound)
		fRAFSrcInst = 1
	$ENDIF

	$IF (mppackage	< NotFound)
		fMPInst = 1;
	$ENDIF

	$Deassign (SrvInstType)
	$Deassign (SrvMenu1)
	$Deassign (SrvMenu2)
	$Deassign (Srvpkgs)
	$Deassign (Option1)
	$Deassign (Option2)
	$Deassign (Option3)
	$Deassign (Option4)
	$Deassign (Srvpackage3)
	$Deassign (Srvpackage4)

$ENDIF   ; end of IF installtype = from Server

$RestartLabel

$IF (fCopyFiles = 1)

RAFMenu		= 'RAF Source Menu'
RAFSrc		= 'RAF Source Installation'
mpUtil		= 'Message Posting Utilities'
selected	= 0
Temp1		= 0
		
$IF (InstallType = Floppy)

$While (selected = 0)
	RAFpkgs	= $userselectmultiple(RAFMenu,RAFSrc,mpUtil)
	RAFpackage	= substring(RAFSrc, RAFpkgs)
	mppackage	= substring(mpUtil, RAFpkgs)
		
	$IF (RAFpackage = NotFound) and (mppackage = NotFound)
		Temp1 = $UserSelectYesNo ('No selection was made. Do you want to select from the menu again?', 'No')
		$IF Temp1
			selected = 0
		$ELSE
			Temp1 = 0
			selected = 1
		$ENDIF
	$ELSE
		Temp1 = 255
		Selected = 1
	$ENDIF
$EndWhile	

$IF NOT Temp1  
	$IF VideoLevel = 2
		$DisplayLine
		$DisplayLine
		$Displayline('AE No RAF Menu selection was made.           AA')
		$Displayline('AE                       Press GO to exit    AA')
		$DisplayLine
		$DisplayLine
	$ENDIF   ; end if videolevel
	$DisplayAndWait
	$Cancel
$ENDIF

$Deassign(selected)
$Deassign(Temp1)
$Deassign (RAFpkgs)
$Deassign (RAFMenu)
$Deassign (RAFSrc)
$Deassign (mpUtil)

$ELSE
	ddPackage = 1
	spPackage = 1

$ENDIF	

$Restartlabel
	
$IF RAFPackage < NotFound

	$DisplayLine
$Displayline('AE The existing RAF Source User profile on your system will AA')
$Displayline('AE be overwritten by the default file.                      AA')
$Displayline('AE                                                          AA')
$Displayline('AE At the end of the installation, please modify the        AA')
$Displayline('AE default file to your requirements  specifications.      AA')
$Displayline('AE                                                          AA')
	$IF (InstallType = Floppy) OR (InstallType = FromServer)
$Displayline('AE              Press any key to continue                   AA')

	$DisplayLine
	$DisplayAndWait
	$ENDIF	
	
	$IF (InstallType = 4)  ; if installation is SWD
		$DisplayLine
$Displayline('AE Users must take care in using SWD to install RAF.        AA')
$Displayline('AE If the installation and subsequent activation of RAF is  AA')
$Displayline('AE not successful, it will not be possible to use RAF to    AA')
		$Displayline('AE correct the problem.                             AA')
		$Displayline('AE                                                          AA')
;		$Displayline('AE              Press any key to ;continue                    AA')
;		$DisplayLine
;		$DisplayAndWait
	$ENDIF ; if SWD

	
	$DisplayLine
	$Displayline('Copying IPM.font, B27IPM.font, AGPIPM.font, SG3IPM.font,')
	$Displayline('        RAFSource.run, RAFSourceProfile.Sys,')
	$Display	('        RAFConfig.Sys ...')
	$Command LCopy,(IPM.Font, B27IPM.Font, AGPIPM.Font, SG3IPM.Font, RAFSource.run, RAFSourceProfile.Sys, RAFConfig.Sys),InstallFrom,ToSpec,,yes,no,no
	$DisplayLine (DoneMsg)
	$DisplayLine

	$Display('Creating RAF Source command ...')
	$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
	$DisplayLine (DoneMsg)

	$Displayline
	fRAFSrcInst = 1 ;ganti
	fInstalled = 1 ;ganti
	$Display('Copying the necessary request files ...') ;ganti
	$IF (InstallType = Floppy)  ; if installation is FLOPPY
		NewReqSys = ConcatStrings(DeviceFrom, '<Unisys>Request.RAF.Sys')
		$IF PUBLIC
			ToInst = '[sys]<installed>RAFSource>3.2>'
			$Command LCopy,NewReqSys,,ToInst,,yes,no,no
			$Deassign (ToInst)
		$ENDIF ; of Public
		$Deassign (NewReqSys);
	$ENDIF   ; end of IF installtype = floppy
	$DisplayLine (DoneMsg)
	$DisplayLine
	
	$Restartlabel

	SourceMenu	= 'Select the RAF Source Utilities to install'
	ddUtil		= 'RAF RS232 Source'
	spUtil		= 'Source Profile Utilities'
	selected	= 0
		
	$IF (InstallType = Floppy) OR (InstallType = FromServer)
		$While (selected = 0)
			Sourcepkgs	= $userselectmultiple(Sourcemenu, ddUtil, spUtil)
			ddpackage	= substring(ddUtil, Sourcepkgs)
			sppackage	= substring(spUtil, Sourcepkgs)
		
			$IF (ddPackage = NotFound) and (sppackage = NotFound)
				Temp1 = $UserSelectYesNo ('No selection was made. Do you want to select from the menu again?', 'No')
				$IF Temp1
					selected = 0
				$ELSE
					Temp1 = 0
					selected = 1
				$ENDIF
			$ELSE
				Temp1 = 255
				Selected = 1
			$ENDIF
		$EndWhile	

		$Deassign(selected)
		$Deassign(Temp1)
		$Deassign (Sourcepkgs)
		$Deassign (SourceMenu)
		$Deassign (ddUtil)
		$Deassign (spUtil)
	ENDIF   ; end of IF installtype = floppy

	$Restartlabel

	$IF ddPackage < NotFound
		$Display('Creating RAF RS232 Source command ...')
		$IF (InstallType = Floppy)  ; if installation is FLOPPY
			CmdSpec = ConcatStrings(DeviceFrom, '<Sys>DirectD.cmds')
		$ENDIF   ; end of IF installtype = floppy
		$IF (InstallType = FromServer)  ; if installation is From the Server
			CmdSpec = '[Sys]<installed>RAFSource>3.2>DirectD.cmds'
		$ENDIF   ; end of IF installtype = from Server
		$IF (InstallType = 4)  ; if installation is SWD
			CmdSpec = ConcatStrings(SwdSpec, 'DirectD.cmds')
		$ENDIF ; if SWD
		$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
		$DisplayLine (DoneMsg)
		$DisplayLine
	$ENDIF   ; end ddPackage

	$Restartlabel
	$IF spPackage < NotFound
		$Display('Copying RAFProfile.run ...')
		$Command LCopy,RAFProfile.run,InstallFrom,ToSpec,,yes,no,no
		$DisplayLine (DoneMsg)
		$DisplayLine
		$DisplayLine('Creating RAF Source User Profile, RAF Script')
		$Display('     and RAF Telephone Directory commands ...')
		$IF (InstallType = Floppy)  ; if installation is FLOPPY
			CmdSpec = ConcatStrings(DeviceFrom, '<Sys>ProfileU.cmds')
		$ENDIF   ; end of IF installtype = floppy
		$IF (InstallType = FromServer)  ; if installation is From the Server
			CmdSpec = '[Sys]<installed>RAFSource>3.2>ProfileU.cmds'
		$ENDIF   ; end of IF installtype = from Server
		$IF (InstallType = 4)  ; if installation is SWD
			CmdSpec = ConcatStrings(SwdSpec, 'ProfileU.cmds')
		$ENDIF ; if SWD
		$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
		$DisplayLine (DoneMsg)
		$DisplayLine
	$ENDIF   ; end spPackage
	
	$Display('Removing old commands RAFS and RS232 RAF Source ...')
	$Command 'Remove Command',('RAFS', 'RS232 RAF Source'),CmdFileTo
;	$Command 'Remove Command','RS232 RAF Source',CmdFileTo
	$DisplayLine (DoneMsg)
	$DisplayLine
	
$ENDIF ; of IF RAFPackage < NotFound ; ganti


$Restartlabel

$IF mpPackage < NotFound
	mpdirspec = ConcatStrings(DefVol, '<MP>')
	$DisplayLine
	$Displayline('Copying MPSrvr.run, MPBrdg.run, MPTerm.run, ')
	$Displayline('        DeinstMPSrvr.run, DeinstMPBrdg.run,')
	$Display	('        MPSrvr.Msg, MPBrdg.Msg, MPTerm.Msg ...')
	$Command LCopy,(MPSrvr.run, MPBrdg.run, MPTerm.run, DeinstMPSrvr.run, DeInstMPBrdg.run, MPSrvr.Msg, MPBrdg.Msg, MPTerm.Msg ),InstallFrom,ToSpec,,yes,no,no
	$DisplayLine (DoneMsg)
	$DisplayLine

	$DisplayLine('Creating MP Load Service, MP Load Bridge,')
	$DisplayLine('         MP Notification, MP Unload Service,')
	$Display('         and MP Unload Bridge commands ...')
	$IF (InstallType = Floppy)  ; if installation is FLOPPY
		CmdSpec = ConcatStrings(DeviceFrom, '<Sys>MessageP.cmds')
	$ENDIF   ; end of IF installtype = floppy
	$IF (InstallType = FromServer)  ; if installation is From the Server
		CmdSpec = '[Sys]<installed>RAFSource>3.2>MessageP.cmds'
	$ENDIF   ; end of IF installtype = from Server
	$IF (InstallType = 4)  ; if installation is SWD
		CmdSpec = ConcatStrings(SwdSpec, 'MessageP.cmds')
	$ENDIF ; if SWD
	$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
	$DisplayLine (DoneMsg)
	$DisplayLine

	$Display('Creating <MP> directory...')
	$Command 'Create Directory', mpdirspec
	$DisplayLine (DoneMsg)
	fMPInst = 1 ;ganti
	fInstalled   = 1 ;ganti
	$Displayline
	$Restartlabel
	$Display('Copying the necessary request files ...')
	$IF (InstallType = Floppy)  ; if installation is FLOPPY
		NewReqSysMP = ConcatStrings(DeviceFrom, '<Unisys>MPRqst.Sys')
		$IF PUBLIC
			ToInst = '[sys]<installed>RAFSource>3.2>'
			$Command LCopy,NewReqSysMP,,ToInst,,yes,no,no
			$Deassign (ToInst)
		$ENDIF ; of Public
	$ENDIF   ; end of IF installtype = floppy
		
	$If InstallType = SWD
		$IF PUBLIC
			ToInst = '[sys]<installed>RAFSource>3.2>'
			FromSys = SwdSpec
			$Command LCopy,MPRqst.sys,FromSys,ToInst,,yes,no,no    
			$Deassign (ToInst)
			$Deassign (FromSys)
		$ENDIF ; of Public
	$EndIf ; of InstallType = SWD
	$DisplayLine (DoneMsg)

$ENDIF   ; end mpPackage

$ENDIF   ; end (fCopyFiles = 1)


$Restartlabel
$IF (fInstalled > 0)
	$Displayline
	$Displayline('Merging the following request files ...')
	$IF (InstallType = FromServer)  ; if installation is From the Server
		NewReqSysRAF = '[Sys]<installed>RAFSource>3.2>Request.RAF.Sys'
		NewReqSysMP  = '[Sys]<installed>RAFSource>3.2>MPRqst.Sys'
	$ENDIF   ; end of IF installtype = from Server
	$IF (InstallType = 4)  ; if installation is SWD
		NewReqSysRAF = ConcatStrings(SwdSpec, 'Request.RAF.Sys')
		NewReqSysMP  = ConcatStrings(SwdSpec, 'MPRqst.Sys')
	$ENDIF ; if SWD
	$IF (InstallType = Floppy)  ; if installation is FLOPPY
		NewReqSysRAF = ConcatStrings(DeviceFrom, '<Unisys>Request.RAF.Sys')
	$ENDIF   ; end of IF installtype = floppy
	ReqSysSpec = ConcatStrings(ToSpec, 'Request.Sys')
	ReqTxtSpec = ConcatStrings(ToSpec, 'Request.txt')
	$IF (fRAFSrcInst > 0) AND (fMPInst > 0)
		$Displayline(NewReqSysMP,' and ',NewReqSysRAF)
		$Command List Request Set, (NewReqSysRAF,NewReqSysMP,ReqSysSpec),ReqTxtSpec
	$ELSE
		$IF (fRAFSrcInst > 0)
			$Displayline(NewReqSysRAF)
			$Command List Request Set, (NewReqSysRAF,ReqSysSpec),ReqTxtSpec
		$ENDIF ;of IF (fRAFSrcInst > 0)
		$IF (fMPInst > 0)
			$Displayline(NewReqSysMP)
			$Command List Request Set, (NewReqSysMP,ReqSysSpec),ReqTxtSpec
		$ENDIF;of IF (fMPInst > 0)
	$ENDIF ;of IF (fRAFSrcInst > 0) AND (fMPInst > 0)
	$Displayline
	$Displayline('There will be a short delay as Request.Sys is created')
	$Command Make Request Set, ReqTxtSpec, ReqSysSpec
	
	$Command Delete,ReqTxtSpec
	
	InstDoneMsg = 'When installation is completed, please reboot your system.'
		$Displayline
		$Displayline(InstDoneMsg)
		$Displayline

$ENDIF   ; IF (fInstalled > 0)


$IF Erc > 0
	$DisplayLine
	$DisplayLine('Error in RAF Source installation')
	$DisplayLine('Status code ', ERC)
	$Cancel
$ENDIF
$RestartLabel

$End     ; end of file
ge

	$Restartlabel
	$IF spPackage < NotFound
		$Display('Copying RAFProfile.run ...')
		$Command LCopy,RAFProfile.run,InstallFrom,ToSpec,,yes,no,no
	