📜 ⬆️ ⬇️

Automate the installation of Powerchute Business Edition

Foreword


Recently, my manager set the task to automate the installation and configuration of the Powerchute Business Edition product on a large number of servers, with various interfaces for connecting UPS, USB, COM. Previously engaged in the automation of the installation of various software, but with the type of configuration files that this product uses for the first time. The thing is that java binaries are used as a configuration file, which can be modified by the utility with the GIU interface, it is not suitable for solving the problem.

Powerchute Business Edition from the inside


Let us consider in more detail the product, it is possible to get it on the official APC website in the downloads section. After downloading, we get the pcbesetup.exe file with the help of it, it is possible to install three components, agent, server, console. The agent installs the driver on the UPS and is responsible for automatically shutting down the server in the event of a power failure. The server connects to the agent, reads the status of the UPS, in case of problems it can send an alert to the mail. Console, GUI interface for server and agent settings. Component three but one, in order to get them separately we will use the usual WinRAR , open the downloaded file, move to the bin folder. We see three of our components, but four folders, more on that later.



Automation of component installation


Since inhaler files are made in InstallShield, it is possible to create an answer file, which is written on the manufacturer’s website. From the beginning, you must put all the unzipping files for example in the following path C: \ APC , then install the components from the command line in the specified order:
')
1. C: \ APC \ agent-upslink \ setup.exe -r agent version 9.0.3 installation
2. C: \ APC \ agent \ setup.exe -r update agent to version 9.1.1
3. C: \ APC \ server \ setup.exe -r install server version 9.1.1
4. C: \ APC \ console \ setup.exe -r install console 9.1.1

After each installation, a response file C: \ Windows \ setup.iss will be created, which must be copied to the directory with the installer. It is important that when installing the UPS detection agent passed automatically, this will further provide an opportunity to install the agent with various USB, COM interfaces, it will detect the UPS itself. Now we’ll check that the answer files are working, remove the installed components, reinstall with the s key.

1. C: \ APC \ agent-upslink \ setup.exe -s
2. C: \ APC \ agent \ setup.exe -s
3. C: \ APC \ server \ setup.exe -s
4. C: \ APC \ console \ setup.exe -s

As you can see the installation was successful:



The components are installed, now they need to be configured. The agent is configured at the time of installation, a login and password is set, which is saved in the file C: \ Windows \ setup.iss , we have already configured it before we created the answer file. Now comes the most interesting setting up a server with a binary java file. Open the console and remove the previously configured UPS.



after adding a new client, it is important to specify 127.0.0. * in the search range, this is necessary for automation, since there will be different agent addresses on different servers, and we will not edit the configuration file manually.



We are setting up sending notifications by mail, in the Tools> Chenge Configuration Profile section, I will not describe each field and everything is clear.



Everything you need for automation is copied to the server settings files, in the following path C: \ Program Files (x86) \ APC \ PowerChute Business Edition \ server, files m11.bak, m11.cfg. in the C: \ APC \ server \ directory, remove all previously installed PowerChute components, and install them using the PowerShell script, listing below. The script logic is as follows, go to the directory where the script file is located, install and update the agent, install the server, stop the server service, change the configuration files, start the server service, install the console.

function InstallPowerShute{ .\APC\agent-upslink\setup.exe -s | Out-Null .\APC\agent\setup.exe -s | Out-Null $PowerChuteServerFolder= ${env:ProgramFiles(x86)} + "\APC\PowerChute Business Edition\server" $PowerChuteServerFile1= $PowerChuteServerFolder + "\m11.bak" $PowerChuteServerFile2= $PowerChuteServerFolder + "\m11.cfg" .\APC\server\setup.exe -s | Out-Null Stop-Service APCPBEServer -Force | Out-Null remove-item -path $PowerChuteServerFile1 -force remove-item -path $PowerChuteServerFile2 -force Copy-Item ".\APC\server\m11.bak" -Destination $PowerChuteServerFolder Copy-Item ".\APC\server\m11.cfg" -Destination $PowerChuteServerFolder Start-Service APCPBEServer | Out-Null .\APC\console\setup.exe -s | Out-Null } function Get-ScriptPath{ Split-Path -Path $MyInvocation.ScriptName } $path = Get-ScriptPath cd $path InstallPowerShute 


I hope you will succeed.

Thank you for your attention.

Source: https://habr.com/ru/post/235177/


All Articles