$JOB RAFTInstall
;Install.jcl (RAF Target Installation for 3 12 diskette)

; SWD version 
; Notes on using SWD 3.0:
;	Change swdver (below) to 3 (or 4)
;	In Software Registration Object Registration (Package Registration)
;		specify RAFT321 for SRDIR
;	In Software Registration Object Instance Maintanence
;		select B25RAFT$3_2_1
;	In Prepare Software Distribution
;		select B25RAFT$3_2_1
;		specify RFT for Release ID
;		specify RFTRAFT321 for SWD Installation Directory
;	In Software Distribution
;		select RFT
; 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
fRAFTgtInst = 0
fMPInst     = 0
fCopyFiles = 1
Floppy     = 0
Tape       = 1
FromServer = 2
NotFound   = 65535
DoneMsg    = ' done.'
TgtYesNoMsg = 'Do you want to install RAF Target?'  ;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
	buPackage = NotFound
	ddPackage = NotFound
	tpPackage = 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('AEPublic 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('AE                                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]<RFTRAFT321>'             ; SWD 3.0 or above
$ENDIF

$IF PUBLIC
	$Path,		
		sys,	
		Sys
	ToSpec = '[sys]<sys>'
	DefVol = '[Sys]'
	ToInst = '[sys]<installed>RAFTarget>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,BridgeU,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 = 4)  ; if installation is SWD
	bupackage = 1
	ddpackage = 1
	tppackage = 1
;	mppackage = 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>RAFTarget>3.2>Install.cmds'

	SrvMenu1	= 'Server Installation Menu'
	Option1		= 'RAF Target 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)
		fRAFTgtInst = 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 Target Menu'
RAFTgt		= 'RAF Target Installation'
mpUtil		= 'Message Posting Utilities'
selected	= 0
		
$IF (InstallType = Floppy)

$While (selected = 0)
	RAFpkgs	= $userselectmultiple(RAFMenu,RAFTgt,mpUtil)
	RAFpackage	= substring(RAFTgt, 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 (RAFTgt)
$Deassign (mpUtil)
	
$ENDIF

$Restartlabel
	
$IF RAFPackage < NotFound

	$DisplayLine
$Displayline('AE The existing RAF Target 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 RAFTarget.run, RAFDeInstallTarget.run, PGS.run,')
	$Display    ('        DeInstallPGS.run, RAFConfig.sys ...')
	$Command LCopy,(RAFTarget.run, RAFDeInstallTarget.run, PGS.run, DeInstallPGS.run, RAFConfig.sys),InstallFrom,ToSpec,,yes,no,no
	$DisplayLine (DoneMsg)
	$DisplayLine

	$DisplayLine('Creating RAF Load Target, RAF Load PGS, ')
	$Display('RAF Unload Target, and RAF Unload PGS commands ...')
	$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
	$DisplayLine (DoneMsg)
	$Displayline
	fRAFTgtInst = 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>RAFTarget>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
	
	TargetMenu	= 'Select the RAF Target Utilities to install'
	buUtil		= 'Bridge Utilities'
	ddUtil		= 'RAF RS232 Target'
	tpUtil		= 'Target Profile Utilities'
	selected	= 0
		
	$IF (InstallType = Floppy) OR (InstallType = FromServer)
		$While (selected = 0)
			Targetpkgs = $userselectmultiple(Targetmenu, buUtil, ddUtil, tpUtil)
			bupackage	= substring(buUtil, Targetpkgs)
			ddpackage	= substring(ddUtil, Targetpkgs)
			tppackage	= substring(tpUtil, Targetpkgs)
		
			$IF (bupackage = NotFound) and (ddpackage = NotFound) and 
			(tppackage = 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 (Targetpkgs)
		$Deassign (TargetMenu)
		$Deassign (buUtil)
		$Deassign (ddUtil)
		$Deassign (tpUtil)
	ENDIF   ; end of IF installtype = floppy

	$Restartlabel
	$IF bupackage < NotFound
		$Displayline('Copying RAFBridge.run, RAFDeInstallBridge.run ...')
		$Command LCopy,(RAFBridge.run, RAFDeInstallBridge.run),InstallFrom,ToSpec,,yes,no,no
		$DisplayLine (DoneMsg)
		$DisplayLine
		$DisplayLine('Creating RAF Load Bridge')
		$Display('     and RAF Unload Bridge commands ...')
		$IF (InstallType = Floppy)  ; if installation is FLOPPY
			CmdSpec = ConcatStrings(DeviceFrom, '<Sys>BridgeU.cmds')
		$ENDIF   ; end of IF installtype = floppy
		$IF (InstallType = FromServer)  ; if installation is From the Server
			CmdSpec = '[Sys]<installed>RAFTarget>3.2>BridgeU.cmds'
		$ENDIF   ; end of IF installtype = from Server
		$IF (InstallType = 4)  ; if installation is SWD
			CmdSpec = ConcatStrings(SwdSpec, 'BridgeU.cmds')
		$ENDIF ; if SWD
		$Command 'Merge Command Files', CmdSpec, CmdFileTo, yes, DefVol
		$DisplayLine (DoneMsg)
		$DisplayLine
	$ENDIF   ; end bupackage

	$Restartlabel
	$IF ddPackage < NotFound
		$Displayline('Copying RS232Target.run, DeInstallRS232Target.run ...')
		$Command LCopy,(RS232Target.run, DeInstallRS232Target.run),InstallFrom,ToSpec,,yes,no,no
		$DisplayLine (DoneMsg)
		$DisplayLine
		$DisplayLine('Creating RAF Load RS232 Target Interface')
		$Display('     and RAF Unload RS232 Target Interface commands ...')
		$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>RAFTarget>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 tppackage < NotFound
		$DisplayLine
		$Displayline('Copying RAFProfile.run, RAFTargetProfile.Sys')
		$Display    ('        RAFQueryChangeTime.run, RAFLog.run ...')
		$Command LCopy,(RAFProfile.run, RAFTargetProfile.Sys, RAFQueryChangeTime.run, RAFLog.run),InstallFrom,ToSpec,,yes,no,no
		$DisplayLine (DoneMsg)
		$DisplayLine
		$DisplayLine('Creating RAF Target User Profile, RAF Script,')
		$DisplayLine('   RAFQuery Target ID, RAF Query Video Update Interval,')
		$DisplayLine('   RAF Change Video Update Interval, RAF Start Screen Recording,')
		$Display('   and RAF Stop Screen Recording 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>RAFTarget>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 tppackage
	
	$Displayline('Removing old commands Change Video Update Interval,')
	$Displayline('  Deinstall PGS, Deinstall RAF Bridge, Deinstall RAFT,')
	$Displayline('  Deinstall RS232 Target Interface, Install PGS,')
	$Displayline('  Install RAF Bridge, Install RS232 Target Interface,')
	$Display	('  Install RAFT and Query Video Update Interval ...')
	$Command 'Remove Command',('Change Video Update Interval', 'Deinstall PGS', 'Deinstall RAF Bridge', 'Deinstall RAFT', 'Deinstall RS232 Target Interface', 'Install PGS', 'Install RAF Bridge', 'Install RS232 Target Interface', 'Install RAFT', 'Query Video Update Interval'),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,')
	$Displayline('        MPTerm.run, 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>RAFTarget>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>RAFTarget>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>RAFTarget>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>RAFTarget>3.2>Request.RAF.Sys'
		NewReqSysMP  = '[Sys]<installed>RAFTarget>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 (fRAFTgtInst > 0) AND (fMPInst > 0)
		$Displayline(NewReqSysMP,' and ',NewReqSysRAF)
		$Command List Request Set, (NewReqSysRAF,NewReqSysMP,ReqSysSpec),ReqTxtSpec
	$ELSE
		$IF (fRAFTgtInst > 0)
			$Displayline(NewReqSysRAF)
			$Command List Request Set, (NewReqSysRAF,ReqSysSpec),ReqTxtSpec
		$ENDIF ;of IF (fRAFTgtInst > 0)
		$IF (fMPInst > 0)
			$Displayline(NewReqSysMP)
			$Command List Request Set, (NewReqSysMP,ReqSysSpec),ReqTxtSpec
		$ENDIF;of IF (fMPInst > 0)
	$ENDIF ;of IF (fRAFTgtInst > 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 Target installation')
	$DisplayLine('Status code ', ERC)
	$Cancel
$ENDIF
$RestartLabel

$End     ; end of file
$ENDIF   ; end of IF installtype = floppy
		$IF (InstallType = FromServer)  ; 