@DefineProject
	@Name = "PowerChute PLUS"
	@Version = "Version 4.2"
	@Immediate = 1
	@OutDrive = F
	@SubDir = "\\"
	@InDiskBell = 1
	@Verify
	@Requires @HardDisk
@EndProject

@Definevars
	@Integer                @TopColor = @RGB(255,0,0)
	@Integer                @BottomColor = @RGB(0,0,0)
	@Qstring                @SerName = ""
	@Qstring                @VolName = ""
	@Integer                @OptNum = 0
	@Qstring                @InputPath = "SYS:\\PWRCHUTE"
	@QString                @PromptString = ""
	@Dir                    @InstPath = "\\PWRCHUTE\\"
	@Dir                    @OldPath = "\\PWRCHUTE\\"
	@Qstring                @UPStype = "Smart-UPS"
	@Qstring                @HexStr = "3F8"
	@Integer                @Comm = 0
	@Integer                @Adr = 0
	@Integer                @Irq = 0
	@Qstring                @CommDriver = "COMM port"
	@Integer                @MessageDelay = 5
	@Integer                @MessageInterval = 30
	@Integer                @ShutdownDelay = 300
	@Integer                @REDO = 0
	@Qstring                @DispComm = ""
	@Qstring                @DispShut = ""
	@Integer                @AIO = 0
	@Integer                @ListSize = 0
	@Integer                @Rights = 0
@Endvars

INITIALIZATION:
@BackgroundMode(3,@TopColor,@BottomColor)
@OutDrive = @NWGetSysDrive

@IF (!@DriveRemote(@OutDrive))
	@GetOutDrive
	@Suppress( 0, 8)
		PowerChute PLUS network drive
_____________________________________________________________________________
	Which drive do you want to install 
	@Name?

	@LocalWindow( 14, 14)
	@EndOutDrive
@Endif

CHECK_FOR_NETWORK:
@If (!@NetWare)
	@Display
		@CLS
		Cannot find Novell NetWare network
_____________________________________________________________________________

	In order to install @Name, the installation program must be 
	run upon a network workstation.

	Please run the installation on a network workstation.
@Pause
@EndDisplay
@Abort
@Endif

CHECK_IF_LOGGED_ON:
@If (!@NWCheckLoggedOn)
@Display
@CLS
		You are not logged onto a server
_____________________________________________________________________________

	In order to install @Name, you must be logged onto the 
	file server on which you want to install @Name.

	Please log onto the server on which you wish to install 
	@Name and restart the installation.
@Pause
@EndDisplay
@Abort
@EndIf

@If (@NWGetVersion == 2)
@Display
@CLS
		Please run the NetWare 2.X install
_____________________________________________________________________________

	Your primary connection is to a NetWare 2.X server.
	This installation is for NetWare servers with 3.X and greater.
	Please run the INSTALL.EXE in the NETWARE.2X directory on the 
	@Name NetWare 2.X distribution diskette.

	If you wich to install to a server running NetWare 3.X or greater,
	please log into that server BEFORE attaching other servers.
@Pause
@EndDisplay
@Abort
@EndIf

EXPALIN_METHODS:
@Display
@CLS
		@Name Installation
_____________________________________________________________________________

	During this installation, you will be prompted for options 
	for @Name.

	Select or enter the appropriate values for each option.

	You will be able to review your choices and edit those values 
	if needed BEFORE the installation is completed.

@Pause
@EndDisplay

GET_SERVER_NAME:
PROMPT_SERVER:
	@ClearOption(11)
	@ClearOption(12)
	@ClearOption(13)
	@ClearOption(14)
	@ClearOption(15)
	@ClearOption(16)
	@ClearOption(13)
	@ClearOption(18)
	@ListSize = @NWConnListSize
@GetOption
	@Cls
		@Name Installation
 ____________________________________________________________________________

	Select the server you wish to install @Name onto from
	the list of attached servers.
	
	@LocalWindow( 9, 13)
	@Option 11 = "@NWGetConnServer(0)"
	@If (@ListSize > 1)
		@Option 12 = "@NWGetConnServer(1)"
	@EndIf
	@If (@ListSize > 2)
		@Option 13 = "@NWGetConnServer(2)"
	@EndIf
	@If (@ListSize > 3)
		@Option 14 = "@NWGetConnServer(3)"
	@EndIf
	@If (@ListSize > 4)
		@Option 15 = "@NWGetConnServer(4)"
	@EndIf
	@If (@ListSize > 5)
		@Option 16 = "@NWGetConnServer(5)"
	@EndIf
	@If (@ListSize > 6)
		@Option 17 = "@NWGetConnServer(6)"
	@EndIf
	@If (@ListSize > 7)
		@Option 18 = "@NWGetConnServer(7)"
	@EndIf
@EndOption
@If ( 11 [= @Option )
	@NWSetServer("@NWGetConnServer(0)")
@EndIf
@If ( 12 [= @Option )
	@NWSetServer("@NWGetConnServer(1)")
@EndIf
@If ( 13 [= @Option )
	@NWSetServer("@NWGetConnServer(2)")
@EndIf
@If ( 14 [= @Option )
	@NWSetServer("@NWGetConnServer(3)")
@EndIf
@If ( 15 [= @Option )
	@NWSetServer("@NWGetConnServer(4)")
@EndIf
@If ( 16 [= @Option )
	@NWSetServer("@NWGetConnServer(5)")
@EndIf
@If ( 17 [= @Option )
	@NWSetServer("@NWGetConnServer(6)")
@EndIf
@If ( 18 [= @Option )
	@NWSetServer("@NWGetConnServer(7)")
@EndIf

@SerName = @NWGetServer
@VolName = @NWGetVolume
@InputPath = @NWGetPathFromAutoexec 
@OldPath = @NWSetPath("@InputPath")
@SubDir = @OldPath

GET_INSTALL_DIRECTORY:
@PromptString = ""
PROMPT_PATH:
@GetString @InputPath
	@CLS
		@Name Installation
 ____________________________________________________________________________

	@MoveCStr(4,7,28,"@PromptString")
	@Name will be installed in the directory given.  
	Edit the name to change installation directory.

	Target server:  @SerName
	Directory:      @InputPath

	@LocalWindow( 12, 16)
	@Prompt = "@Name: Installation Directory"
@EndString
@If (!@NWValidPath("@InputPath") )
	@PromptString = "The path you have entered is invalid."
	@Goto PROMPT_PATH
@EndIf
@InputPath =@StrUpr("@InputPath")
@SubDir = @NWSetPath("@SerName\\@InputPath")
@SubDir = @StrUpr("@SubDir")
@OutDrive = @NWGetSysDrive
@IF (!@DriveRemote(@OutDrive))
	@Display
	@CLS
		No Drive is mapped to target server
		Target server:  @SerName
 ____________________________________________________________________________
	To install @Name on @SerName there needs to be a drive
	mapped to the server and volume you wish to install on.

	Please map a drive to @SerName and restart the installation.
	@Pause
	@EndDisplay
	@Abort
@EndIf
@SerName = @NWGetServer
@VolName = @NWGetVolume


CHECK_FOR_PRIVILEDGE:
@Rights = @NWCheckLoginEquiv("@InputPath")
@If (@Rights == -1) 
	@PromptString = "The path you have entered is invalid."
	@Goto PROMPT_PATH 
@EndIf
@PromptString = ""
@If (@Rights == -2)
@Display
@CLS
		You cannot install from this account
 ____________________________________________________________________________

	The account you are using does not have sufficent priviledge
	to install the software into the specified directory or
	modify the SYS:SYSTEM\AUTOEXEC.NCF.

	In order to install @Name, you must be logged onto the 
	file server as the supervisor OR with an user account whose 
	security equals supervisor priviledge.

	Please run the installation after you have logged onto the 
	server with an account of sufficent priviledge.
	@Pause
	@EndDisplay
	@Abort
@EndIf

@If (@NWCheckInstalled)
	@InputPath = @NWGetPathFromAutoexec
	@OldPath = @NWSetPath("@InputPath")
	@Display
		@CLS
		PowerChute is already installed
 ____________________________________________________________________________

	@Name is installed on this server already.  
	The previous installation will be backed up on the server
	into the current installation directory.

	@Pause
	@EndDisplay
@EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

GET_UPS_TYPE:
@If (@REDO)
	@ClearOption(21)
	@ClearOption(22)
	@ClearOption(23)
@EndIf
@GetOption
	@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Please select the UPS model type which you are using with 
	@Name.

	@LocalWindow( 10, 14)
	@Prompt = "@Name: UPS Model"
	@Option 22 = "Smart-UPS"
	@Option 21 = "Back-UPS"
	@Option 23 = "Matrix"
@EndOption
@If ( 21 [= @Option )
	@UPStype = "Back-UPS"
@ElseIf ( 22 [= @Option )
	@UPStype = "Smart-UPS"
@Elseif ( 23 [= @Option )
	@UPStype = "Matrix"
@EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

GET_COMM:
@If (@REDO)
	@ClearOption(31)
	@ClearOption(32)
	@ClearOption(33)
	@ClearOption(34)
	@ClearOption(35)
@EndIf

@GetOption
	@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Please select the communications device the @UPStype will 
	use to connect with the server.

	@LocalWindow( 11, 15)
	@Prompt = "@Name: Communications Driver"
	@Option 31 = "COM1"
	@Option 32 = "COM2"
	@Option 33 = "WNIM card"
	@Option 34 = "Artic card"
	@Option 35 = "Other"
@EndOption
@If ( 31 [= @Option ) 
	@CommDriver = "1" 
	@Adr = 0
	@Irq = 0
	@DispComm = "COM1"
@ElseIf ( 32 [= @Option )
	@CommDriver = "1"
	@Adr = 1
	@Irq = 0
	@DispComm = "COM2"
@ElseIf ( 33 [= @Option ) @CommDriver = "WNIM CARD" @DispComm = "WNIM card"
@ElseIf ( 34 [= @Option ) @CommDriver = "ARTIC CARD" @DispComm = "Artic card"
@ElseIf ( 35 [= @Option ) 
GET_OTHER_DRIVER:
	@Comm = 4
	@GetInteger @Comm
		@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Please enter the NUMBER associated with the hardware device 
	type used with the @UPStype to connect with the server.

	@LocalWindow( 9, 16)
	@Prompt = "@Name: Hardware device type"
	@EndInteger
	@If (@Comm < 0) @Goto GET_OTHER_DRIVER @EndIf
	@CommDriver = "@Comm"
	@DispComm = "Hardware Type @Comm"
@EndIf
@If ((@REDO) && ("@CommDriver" == "1")) @Goto PROMPT_CHANGES @EndIf
@If ("@CommDriver" == "1") @Goto GET_SHUTDOWN_DELAY @EndIf

GET_BOARD_NUM:
@GetInteger @Adr
	@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Please enter the BOARD number of the communications hardware
	used with the @UPStype to connect with the server.

	@LocalWindow( 9, 16)
	@Prompt = "@Name: Communications Board #"
@EndInteger
@If (@Adr < 0) @Goto GET_BOARD_NUM @EndIf

GET_PORT_NUM:
@GetInteger @Irq
	@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Please enter the PORT number of the communications hardware
	used with the @UPStype to connect with the server.

	@LocalWindow( 9, 16)
	@Prompt = "@Name: Communications Port #"
@EndInteger
@If (@Irq < 0) @Goto GET_PORT_NUM @EndIf
@If ("@CommDriver" != "1") @DispComm = "@DispComm Board @Adr Port @Irq" @EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

GET_SHUTDOWN_DELAY:
@GetInteger @ShutdownDelay
@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Enter how long the system runs on battery before @Name 
	shuts down the server.

	If you wish the operating system to run until a low battery 
	signal from the UPS,  enter 0 for the time.
		
	@LocalWindow( 12, 16)
	@Prompt = "@Name: Shutdown Delay in Seconds"
@EndInteger
@If (@ShutdownDelay < 0) @Goto GET_SHUTDOWN_DELAY @EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

GET_MESSAGE_DELAY:
@GetInteger @MessageDelay
@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Enter the time that @Name waits before broadcasting 
	messages to the users.

	@LocalWindow( 9, 16)
	@Prompt = "@Name: Message Delay in seconds"
@EndInteger
@If (@MessageDelay < 0) @Goto GET_MESSAGE_DELAY @EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

GET_MESSAGE_INTERVAL:
@GetInteger @MessageInterval
@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ____________________________________________________________________________

	Enter the time that @Name waits between sending broadcast 
	messages to the users.

	@LocalWindow( 9, 16)
	@Prompt = "@Name: Message Interval in seconds"
@EndInteger
@If (@MessageInterval < 0) @Goto GET_MESSAGE_INTERVAL @EndIf
@If (@REDO) @goto PROMPT_CHANGES @EndIf

@REDO = 1
PROMPT_CHANGES:
@ClearOption(0)
@ClearOption(1)
@ClearOption(2)
@ClearOption(3)
@ClearOption(4)
@ClearOption(5)
@ClearOption(6)
@If (@ShutdownDelay ==0) 
	@DispShut = "No limit, wait until low battery"
@Else
	@DispShut = "@ShutdownDelay seconds"
@EndIf
@GetOption
@CLS
		Target server:  @SerName
		Directory:      @VolName:@SubDir
 ___________________________________________________________________________

	UPS Model Type:         @UPStype
	Communications:         @DispComm
	Shutdown Delay:         @DispShut
	Message Delay:          @MessageDelay seconds
	Message Interval:       @MessageInterval seconds

	@LocalWindow( 17, 16)
	@Option 0 = "ACCEPT ALL VALUES"
	@Option 1 = "Change installation directory"
	@Option 2 = "Change UPS model type"
	@Option 3 = "Change communications parameters"
	@Option 4 = "Change shutdown delay"
	@Option 5 = "Change message delay"
	@Option 6 = "Change message interval"
	@LocalWindow( 15, 16)
@EndOption

@If (0 [=@Option)
	@goto CLEAN_UP_OLD_INSTALLS
@ElseIf (1 [= @Option)
	@goto GET_INSTALL_DIRECTORY
@ElseIf (2 [= @Option)
	@goto GET_UPS_TYPE
@ElseIf (3 [= @Option)
	@goto GET_COMM
@ElseIf (4 [= @Option)
	@goto GET_SHUTDOWN_DELAY
@ElseIf (5 [= @Option)
	@goto GET_MESSAGE_DELAY
@ElseIf (6 [= @Option)
	@goto GET_MESSAGE_INTERVAL
@EndIf

CLEAN_UP_OLD_INSTALLS:
@If (!@EXISTS("@OutDrive:\\SubDir"))
	@MKDIR("@OutDrive:\\@SubDir")
@EndIf

@If (@EXISTS("@OutDrive:\\SYSTEM\\PWRCHUTE.NLM"))
	@FileAttr("@OutDrive:\\SYSTEM\\PWRCHUTE.NLM", "r-")
	@Copy("@OutDrive:\\SYSTEM\\PWRCHUTE.NLM","@OutDrive:\\@SubDir\\PWRCHUTE.NL~")
	@Delete("@OutDrive:\\SYSTEM\\PWRCHUTE.NLM")
@EndIf

@If (@EXISTS("@OutDrive:\\SYSTEM\\APC_QNCF.NLM"))
	@FileAttr("@OutDrive:\\SYSTEM\\APC_QNCF.NLM","r-")
	@Copy("@OutDrive:\\SYSTEM\\APC_QNCF.NLM","@OutDrive:\\@SubDir\\APC_QNCF.NL~")
	@Delete("@OutDrive:\\SYSTEM\\APC_QNCF.NLM")
@EndIf

@If (@EXISTS("@OutDrive:\\SYSTEM\\APCPAGER.NLM"))
	@FileAttr("@OutDrive:\\SYSTEM\\APCPAGER.NLM","r-")
	@Copy("@OutDrive:\\SYSTEM\\APCPAGER.NLM","@OutDrive:\\@SubDir\\APCPAGER.NL~")
	@Delete("@OutDrive:\\SYSTEM\\APCPAGER.NLM")
@EndIf

@If (@EXISTS("@OutDrive:\\SYSTEM\\APCPAGER.INI"))
	@FileAttr("@OutDrive:\\SYSTEM\\APCPAGER.INI","r-")
	@Copy("@OutDrive:\\SYSTEM\\APCPAGER.INI","@OutDrive:\\@SubDir\\APCPAGER.IN~")
	@Delete("@OutDrive:\\SYSTEM\\APCPAGER.INI")
@EndIf

@If (@EXISTS("@OutDrive:\\SYSTEM\\PWRCHUTE.NCF"))
	@FileAttr("@OutDrive:\\SYSTEM\\PWRCHUTE.NCF","r-")
	@Copy("@OutDrive:\\SYSTEM\\PWRCHUTE.NCF","@OutDrive:\\@SubDir\\PWRCHUTE.NC~")
	@Delete("@OutDrive:\\SYSTEM\\PWRCHUTE.NCF")
@EndIf

DISTRIBUTION_DISK:
@DefineDisk
	@Label = "DOS: INSTALL.EXE - Disk 1"
	@BeginLib DISTLIB.001
		@File C_PCHUTE.FRL @Size 17351
		@File C_PCHUTE.HLP @Size 82374
		@File PWRCHUTE.INI @Size 6559
		@File NWCALLS.DLL @Size 146544
		@File PWRCHUTE.EXE @Size 1093995
		@File XWI320TE.DLL @Size 58891
		@File XWI320.DLL @Size 208837
		@File PWRCHUTE.HLP @Size 82374
		@File NWIPXSPX.DLL @Size 38544
		@File WINCHUTE.EXE @Size 345760
		@File PWRCHUTE.NLM @Size 289714
	@EndLib
@EndDisk

@DefineDisk
	@Label = "Utilities Disk"
	@File AIO.NLM
	@File AIOCOMX.NLM
	@File AIOINFO.NLM
	@File APCCPQ.NLM
	@File APCRDOWN.NLM
	@File COPY.NLM
	@File SHUTNOTE.NLM
@EndDisk

@BackgroundMode(3,@TopColor,@BottomColor)

@If (@FileDate("SYS:SYSTEM\\CLIB.NLM") < 724520004)
	@Display
	@CLS
		Target Server:  @SerName
		Posible CLIB NLM Incompatibility
_____________________________________________________________________________
	The @Name installation has found that your version of the
	CLIB NLM might be out of date.

	The @Name NLM will work with the CLIB NLM version 3.11d
	and newer versions.  Please contact Novell or APC technical
	support for an upgrade to your CLIB NLM if required.

	@Pause
	@EndDisplay
@EndIf

@ClearOption(1)
@ClearOption(2)
@GetOption
@CLS
		Target Server:  @SerName
		Directory:      @VolName:@SubDir
_____________________________________________________________________________

	@Name needs to change the SYS:SYSTEM\AUTOEXEC.NCF for
	@Name work work properly.

	@LocalWindow( 10, 16)
	@Option 1 = "Change AUTOEXEC.NCF, create .BAK"
	@Option 2 = "Create AUTOEXEC.NEW from .NCF"
@EndOption

@Display
	Make sure the communications driver used to connect with 
	the UPS is loaded BEFORE the PWRCHUTE.NLM is loaded in 
	the AUTOEXEC.NCF.  @Name will NOT run correctly without 
	this change.

	The AIO and AIOCOMX drivers have been provided with this
	distribution and are installed in the @VolName:@SubDir 
	directory.
@Pause
@EndDisplay

@NWMakeUser
@If ("@UPSType" == "Back-UPS")
	@UPSType = "Simple"
@Else
	@UPSType = "Smart"
@EndIf

@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Ups", "SignallingType", "@UPSType")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Ups", "HardwareType", "@CommDriver")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Ups", "BoardNumber", "@Adr")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Ups", "PortNumber", "@Irq")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Modem", "HardwareType", "@CommDriver")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Modem", "BoardNumber", "@Eval(@Adr+1)")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "Modem", "PortNumber", "@Irq")

@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "LineFail", "NotifyDelay", "@MessageDelay")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "LineFail", "NotifyInterval", "@MessageInterval")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "LineFail", "ShutdownDelay", "@ShutdownDelay")
@If (@ShutdownDelay == 0)
	@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "LineFail", "Actions", "LU")
@else
	@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "LineFail", "Actions", "LUS")
@endif
	
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "EventLogging", "EventLogName", "@VolName:@SubDir\\PWRCHUTE.LOG")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "DataLogging", "DataLogName", "@VolName:@SubDir\\PWRCHUTE.DAT")
@NWUpdateIniFile("@OutDrive:@SubDir\\PWRCHUTE.INI", "ErrorLogging","ErrorLogName","@VolName:@SubDir\\PWRCHUTE.ERR")

@FileAttr("SYS:\\SYSTEM\\AUTOEXEC.NCF", "r-")
@FileAttr("SYS:\\SYSTEM\\AUTOEXEC.BAK", "r-")
@FileAttr("SYS:\\SYSTEM\\AUTOEXEC.NEW", "r-")
@If ( 31 [= @Option )
	@AIO = 1
@ElseIf ( 32 [= @Option )
	@AIO = 2
@EndIf
@SerName = @StrDel("@SubDir", 0, 1)
@If ( 1 [= @Option)
	@Delete("SYS:\\SYSTEM\\AUTOEXEC.BAK")
	@Copy("SYS:\\SYSTEM\\AUTOEXEC.NCF", "SYS:\\SYSTEM\\AUTOEXEC.BAK")
	@NWUpdateNCF("SYS:\\SYSTEM\\AUTOEXEC.BAK", "@VolName:@SerName", "SYS:\\SYSTEM\\AUTOEXEC.NCF", @AIO)
@Else
	@Delete("SYS:\\SYSTEM\\AUTOEXEC.NEW")
	@NWUpdateNCF("SYS:\\SYSTEM\\AUTOEXEC.NCF", "@VolName:@SerName", "SYS:\\SYSTEM\\AUTOEXEC.NEW", @AIO)
@EndIf

@BackgroundMode(3,@BottomColor,@BottomColor)
@Finish
	@CLS
	@Name Installation Succeeded!
_____________________________________________________________________________

	Please be sure to send in the registration information for 
	@Name so that we may keep you updated on new versions 
	and APC product information.
@Pause
@EndFinish
