Name
C:\tmp\Install-JS7Agent.ps1
SYNOPSIS
Installs, updates or patches a JS7 Agent
SYNTAX
C:\tmp\Install-JS7Agent.ps1 [-HomeDir] <String> [[-Data] <String>] [[-Config] <String>] [[-Logs] <String>] [[-Work] <String>] [[-User] <String>] [[-Release] <String>] [[-Tarball] <String>] [[-Patch] <String>] [[-InstanceScript] <String>] [[-BackupDir] <String>] [[-LogDir] <String>] [[-ExecStart] <String>] [[-ExecStop] <String>] [[-ReturnValues] <String>] [[-DeployDir] <String[]>] [[-AgentConf] <String>] [[-PrivateConf] <String>] [[-ControllerId] <String>] [[-HttpPort] <String>] [[-HttpsPort] <String>] [[-PidFileDir] <String>] [[-PidFileName] <String>] [[-ControllerPrimaryCert] <String>] [[-ControllerSecondaryCert] <String>] [[-Keystore] <String>] [[-KeystorePassword] <String>] [[-KeystoreAlias] <String>] [[-Truststore] <String>] [[-TruststorePassword] <String>] [[-JavaHome] <String>] [[-JavaOptions] <String>] [[-ServiceDir] <String>] [[-ServiceFile] <String>] [[-ServiceName] <String>] [-ShowLogs] [-MakeDirs] [-MakeService] [-MoveLibs] [-RemoveJournal] [-Restart] [-Abort] [-Kill] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
The Agent Installer Script can be used to automate installing, updating and patching Agents.
The script offers the typical installation options and configuration options available from the Agent's graphical installer.
PARAMETERS
HomeDir
-HomeDir <String>
Specifies the directory in which the Agent should be installed
Required? | true |
Position? | 1 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Data
-Data <String>
Specifies the directory in which Agent data such as configuration files should be stored.
By default the <home>/var_<http-port> directory is used, see -HomeDir and -HttpPort parameters.
Required? | false |
Position? | 2 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Config
-Config <String>
Specifies the directory from which the Agent reads configuration files.
By default the <data>/config directory is used, see -Data parameter.
Required? | false |
Position? | 3 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Logs
-Logs <String>
Specifies the directory to which the Agent stores log files.
By default the <data>/logs directory is used, see -Data parameter.
Required? | false |
Position? | 4 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Work
-Work <String>
Specifies the working directory of the Agent.
By default the <data> directory is used, see -Data parameter.
Required? | false |
Position? | 5 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
User
-User <String>
Specifies the user account for the Agent daemon.
By default the account of the user running the Agent Installer Script is used.
Required? | false |
Position? | 6 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Release
-Release <String>
Specifies a release number such as 2.3.1 for download from the SOS web site if the -Tarball parameter is not used.
Required? | false |
Position? | 7 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Tarball
-Tarball <String>
Optionally specifies the path to a .zip or .tar.gz file that holds the Agent installation files.
If this parameter is not used the installer tarball will be downloaded from the SOS web site for the release indicated with the -Release parameter.
Download is performed with curl that considers http_proxy and https_proxy environment variables and respective settings from a .curlrc file.
Users can check if the connection to a specific URL is bypassed or is using a proxy with a command such as:
([System.Net.WebRequest]::GetSystemWebproxy()).IsBypassed("https://download.sos-berlin.com")
For use with PowerShell 7 users can specify environment variables to authenticate with a proxy:
* HTTP_PROXY - proxy for HTTP requests
* HTTPS_PROXY - proxy for HTTPS requests
* ALL_PROXY - proxy for both HTTP and HTTPS
* NO_PROXY - proxy exclusion address list
Required? | false |
Position? | 8 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Patch
-Patch <String>
A patch is identified by an issue key in the Change Management System, for example JS-1984.
Patches are downloaded from the SOS web site if the -Tarball parameter is not used.
Patches are added to the Agent's <home>/lib/patches directory. Note that the patches sub-directory will be emptied when updating a Controller installation later on.
If a backup directory is specified then an Agent's existing installation directory will be added to a .tar.gz backup file in this directory.
Required? | false |
Position? | 9 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
InstanceScript
-InstanceScript <String>
Specifies the path to an Instance Start Script that acts as a template and that is copied to the bin directory.
Typically the name agent_<http-port>.sh|.cmd. is used. Users are free to choose any name for the Instance Start Script.
The script has to be executable for the Agent daemon or Windows Service, see -User parameter.
Permissions of the script are not changed by the Agent Installer Script.
The Agent Installer Script will perform replacements in the Instance Start Script template for known placeholders such as <JS7_AGENT_USER>,
for details see ./bin/agent_instance.sh-example and .\bin\agent_instance.cmd-example.
Required? | false |
Position? | 10 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
BackupDir
-BackupDir <String>
If a backup directory is specified then an Agent's existing installation directory will be added to a backup file in this directory.
The backup file type will be .tar.gz for Unix and .zip for Windows.
File names are created according to the pattern: backup_js7_agent.<hostname>.<release>.<yyyy>-<MM>-<dd>T<hh>-<mm>-<ss>.tar.gz|.zip
For example: backup_js7_agent.centostest_primary.2.3.1.2022-03-19T20-50-45.tar.gz
Required? | false |
Position? | 11 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
LogDir
-LogDir <String>
If a log directory is specified then the installer script will log information about processing steps to a log file in this directory.
File names are created according to the pattern: install_js7_agent.<hostname>.<yyyy>-<MM>-<dd>T<hh>-<mm>-<ss>.log
For example: install_js7_agent.centostest_primary.2022-03-19T20-50-45.log
Required? | false |
Position? | 12 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ExecStart
-ExecStart <String>
This parameter can be used should the Agent be started after installation. For example, when using systemd for Unix then the
-ExecStart "StartService" parameter value will start the Agent service provided that the related systemd service has been created manually or by use of the -MakeService switch.
When using Windows then the -ExecStart "StartService" parameter value will start the Windows Service.
Alternatively users can specify individual commands, for example -ExecStart "sudo systemctl start js7_agent_4445".
For systemd service files see the JS7 - systemd Service Files for automated Startup and Shutdown with Unix Systems article.
This parameter is an alternative to the use of the -Restart switch which will start the Agent from its Instance Start Script.
If specified this parameter overrules the -Restart switch.
Required? | false |
Position? | 13 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ExecStop
-ExecStop <String>
This parameter can be used should the Agent be stopped before installation. For example, when using systemd then
the -ExecStop "StopService" will stop the Agent service provided that the related systemd service has been created manually or by use of the -MakeService switch.
When using Windows then the -ExecStop "StopService" parameter value will stop the Windows Service.
Alternatively users can specify individual commands, for example -ExecStop "sudo systemctl stop js7_agent_4445".
This parameter is an alternative to the use of the -Restart switch which stops the Agent from its Instance Start Script.
If specified this parameter overrules the -Restart switch.
Required? | false |
Position? | 14 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ReturnValues
-ReturnValues <String>
Optionally specifies the path to a file to which return values will be added in the format <name>=<key>. For example:
log_file=install_js7_agent.centostest_primary.2022-03-20T04-54-31.log
backup_file=backup_js7_agent.centostest_primary.2.3.1.2022-03-20T04-54-31.tar.gz
An existing file will be overwritten. It is recommended to use a unique file name such as /tmp/return.$PID.properties.
A value from the file can be retrieved like this:
* Unix
** backup=$(cat /tmp/return.$$.properties | grep "backup_file" | cut -d'=' -f2)
* Windows
** $backup = ( Get-Content /tmp/return.$PID.properties | Select-String "^backup_file[ ]*=[ ]*(.*)" ).Matches.Groups[1].value
Required? | false |
Position? | 15 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
DeployDir
-DeployDir <String[]>
Specifies the path to a deployment directory that holds configuration files and sub-directories that will be copied to the <config> folder.
A deployment directory allows to manage central copies of configuration files such as agent.conf, private.conf, log4j2.xml etc.
Use of a deployment directory has lower precedence as files can be overwritten by individual parameters such as -AgentConf, -PrivateConf etc.
Required? | false |
Position? | 16 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
AgentConf
-AgentConf <String>
Specifies the path to a configuration file for global Agent configuration items. The file will be copied to the <config>/agent.conf file.
Any path to a file can be used as a value of this parameter, however, the target file name agent.conf will be used.
Required? | false |
Position? | 17 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
PrivateConf
-PrivateConf <String>
Specifies the path to a configuration file for private Agent configuration items. The file will be copied to the <config>/private/private.conf file.
Any path to a file can be used as a value of this parameter, however, the target file name private.conf will be used.
Required? | false |
Position? | 18 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ControllerId
-ControllerId <String>
Specifies the Controller ID, a unique identifier of the Controller installation. Agents will be dedicated to the Controller with the given Controller ID.
The Controller ID is used in the Agent's private.conf file to specify which Controller can access a given Agent.
Required? | false |
Position? | 19 |
Default value | controller |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
HttpPort
-HttpPort <String>
Specifies the HTTP port that the Agent is operated for. The default value is 4445.
The Agent by default makes use of a configuration directory ./var_<http-port> that will be excluded from a backup taken with the -BackupDir paraemeter.
In addition the HTTP port is used to identify the Agent Instance Start Script typically available from the ./bin/agent_<http-port>.sh|.cmd script
and to specify the value of the JS7_AGENT_HTTP_PORT environment variable in the script.
The port can be prefixed by the network interface, for example localhost:4445.
When used with the -Restart switch the HTTP port is used to identify if the Agent is running.
Required? | false |
Position? | 20 |
Default value | 4445 |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
HttpsPort
-HttpsPort <String>
Specifies the HTTPS port that the Agent is operated for. The HTTPS port is specified in the Agent Instance Start Script typically available
from the ./bin/agent_<http-port>.sh|.cmd script with the environment variable JS7_AGENT_HTTPS_PORT.
Use of HTTPS requires a keystore and truststore to be present, see -Keystore and -Truststore parameters.
The port can be prefixed by the network interface, for example batch.example.com:4445.
Required? | false |
Position? | 21 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
PidFileDir
-PidFileDir <String>
Specifies the directory to which the Agent stores its PID file in Unix environments. By default the <data>/logs directory is used.
When using SELinux then it is recommended to specify the /var/run directory, see JS7 - How to install for SELinux.
Required? | false |
Position? | 22 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
PidFileName
-PidFileName <String>
Specifies the name of the PID file in Unix environments. By default the file name agent.pid is used.
The PID file is created in the directory specified by the -PidFileDir parameter.
Required? | false |
Position? | 23 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ControllerPrimaryCert
-ControllerPrimaryCert <String>
Specifies the path to the SSL/TLS certificate of the Primary Controller Instance.
The Agent Installer Script extracts the distinguished name from the given certificate and adds it to the Agent's private.conf file
to allow HTTPS connections from the given Controller using mutual authentication without the need for passwords.
Required? | false |
Position? | 24 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ControllerSecondaryCert
-ControllerSecondaryCert <String>
Corresponds to the -ControllerPrimaryCert parameter and is used for the Secondary Controller Instance.
Required? | false |
Position? | 25 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Keystore
-Keystore <String>
Specifies the path to a PKCS12 keystore file that holds the private key and certificate for HTTPS connections to the Agent.
Users are free to specify any file name, typically the name https-keystore.p12 is used. The keystore file will be copied to the <config>/private directory.
If a keystore file is made available then the Agent's <config>/private/private.conf file has to hold a reference to the keystore location and optionally the keystore password.
It is therefore recommended to use the -PrivateConf parameter to deploy an individual private.conf file that holds settings related to a keystore.
For automating the creation of keystores see JS7 - How to add SSL TLS Certificates to Keystore and Truststore.
Required? | false |
Position? | 26 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
KeystorePassword
-KeystorePassword <String>
Specifies the password for access to the keystore. Use of a keystore password is required.
Required? | false |
Position? | 27 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
KeystoreAlias
-KeystoreAlias <String>
If a keystore holds more than one private key, for example if separate pairs of private keys/certificates for server authentication and client authentication
exist, then it is not determined which private key/certificate will be used. The alias name of a given private key/certificate is specified
when the entry is added to the keystore. The alias name allows to indicate a specific private key/certificate to be used.
Required? | false |
Position? | 28 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Truststore
-Truststore <String>
Specifies the path to a PKCS12 truststore file that holds the certificate(s) for HTTPS connections to the Agent using mutual authentication .
Users are free to specify any file name, typically the name https-truststore.p12 is used. The truststore file will be copied to the <config>/private directory.
If a truststore file is made available then the Agent's <config>/private/private.conf file has to hold a reference to the truststore location and optionally the truststore password.
It is therefore recommended to use the -PrivateConf parameter to deploy an individual private.conf file that holds settings related to a truststore.
For automating the creation of truststores see JS7 - How to add SSL TLS Certificates to Keystore and Truststore.
Required? | false |
Position? | 29 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
TruststorePassword
-TruststorePassword <String>
Specifies the password for access to the truststore. Use of a password is recommended as it is not primarily intended to protect access to the truststore.
The password is intended to allow verification that truststore entries have been added using the same password.
Required? | false |
Position? | 30 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
JavaHome
-JavaHome <String>
Specifies the Java home directory that will be made available to the Agent from the JAVA_HOME environment variable
specified with the Agent Instance Start Script typically available from the ./bin/agent_<http-port>.sh|.cmd script.
Required? | false |
Position? | 31 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
JavaOptions
-JavaOptions <String>
Specifies the Java options that will be made available to the Agent from the JAVA_OPTIONS environment variable specified with the Agent Instance Start Script
typically available from the ./bin/agent_<http-port>.sh|.cmd script.
Java options can be used for example to specify Java heap space settings for the Agent.
If more than one Java option is used then the value has to be quoted, for example -JavaOptions "-Xms256m -Xmx512m".
Required? | false |
Position? | 32 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ServiceDir
-ServiceDir <String>
For Unix environments specifies the systemd service directory to which the Agent's service file will be copied if the -MakeService switch is used.
By default the a/usr/lib/systemd/system will be used. Users can specify an alternative location.
Required? | false |
Position? | 33 |
Default value | /usr/lib/systemd/system |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ServiceFile
-ServiceFile <String>
For Unix environments specifies the path to a systemd service file that acts as a template and that will be copied to the Agent's <home>/bin directory.
Users are free to choose any file name as a template for the service file. The resulting service file name will be agent_<http-port>.service.
The Agent Installer Script will perform replacements in the service file to update paths and the port to be used, for details see ./bin/agent.service-example.
Required? | false |
Position? | 34 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ServiceName
-ServiceName <String>
For Unix environments specifies the name of the systemd service that will be created if the -MakeService switch is used.
By default the service name js7_agent_<http-port> will be used.
Required? | false |
Position? | 35 |
Default value | |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
ShowLogs
-ShowLogs <SwitchParameter>
Displays the log output created by the script if the -LogDir parameter is used.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
MakeDirs
-MakeDirs <SwitchParameter>
If directories are missing that are indicated with the -HomeDir, -BackupDir or -LogDir parameters then they will be created.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
MakeService
-MakeService <SwitchParameter>
Specifies that for Unix environments a systemd service should be created, for Windows environments a Windows Service should be created.
The Unix environments the service will be created from the -ServiceName parameter or its default value.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
MoveLibs
-MoveLibs <SwitchParameter>
For an existing Agent installation the lib sub-directory includes .jar files that carry the release number in their file names.
If replaced by a newer version the lib directory has to be moved or removed.
This switch tries to move the directory to a previous version number as indicated from the .version file in the Agent's home directory,
for example to rename lib to lib.2.3.1.
Files in the lib/user_lib sub-directory are preserved.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
RemoveJournal
-RemoveJournal <SwitchParameter>
If Agents have been installed for the wrong operating mode (standalone, clustered) then the Agent's journal in the JS7_AGENT_DATA/state directory can be removed.
This operation removes any orders submitted to an Agent and requires the Agent to be re-registered to a Controller.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Restart
-Restart <SwitchParameter>
Stops a running Agent before installation and starts the Agent after installation using the Agent's Instance Start Script.
This switch can be used with the -Abort and -Kill switches to control the way how the Agent is terminated.
This switch is ignored if the -ExecStart or -ExecStop parameters are used.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Abort
-Abort <SwitchParameter>
Aborts a running Agent and kills any running tasks including child processes if used with the -Restart switch.
Aborting an Agent includes to terminate the Agent in an orderly manner that allows to close files consistently.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
Kill
-Kill <SwitchParameter>
Kills a running Agent and any running tasks if used with the -Restart switch.
This includes killing child processes of running tasks.
Required? | false |
Position? | named |
Default value | False |
Accept pipeline input? | true (ByPropertyName) |
Accept wildcard characters? | false |
WhatIf
-WhatIf <SwitchParameter>
Required? | false |
Position? | named |
Default value | |
Accept pipeline input? | false |
Accept wildcard characters? | false |
Confirm
-Confirm <SwitchParameter>
Required? | false |
Position? | named |
Default value | |
Accept pipeline input? | false |
Accept wildcard characters? | false |
EXAMPLES
-------------------------- EXAMPLE 1 --------------------------
PS > Install-JS7Agent.ps1 -HomeDir "C:\Program Files\sos-berlin.com\js7\agent2" -Data "C:\ProgramData\sos-berlin.com\js7\agent_4225" -Tarball /tmp/js7_agent_windows.2.5.1.zip -HttpPort 4225 -MakeDirs
-------------------------- EXAMPLE 2 --------------------------
PS > Install-JS7Agent.ps1 -HomeDir "C:\Program Files\sos-berlin.com\js7\agent2" -Data "C:\ProgramData\sos-berlin.com\js7\agent_4225" -Tarball /tmp/js7_agent_windows.2.5.1.zip -BackupDir /tmp/backups -LogDir /tmp/logs -HttpPort 4225 -MakeDirs
-------------------------- EXAMPLE 3 --------------------------
PS > Install-JS7Agent.ps1 -HomeDir "C:\Program Files\sos-berlin.com\js7\agent2" -Data "C:\ProgramData\sos-berlin.com\js7\agent_4225" -Tarball /tmp/js7_agent_windows.2.5.1.zip -HttpPort 4225 -MakeDirs
-------------------------- EXAMPLE 4 --------------------------
PS > Install-JS7Agent.ps1 -HomeDir "C:\Program Files\sos-berlin.com\js7\agent2" -Data "C:\ProgramData\sos-berlin.com\js7\agent_4225" -Tarball /tmp/js7_agent_windows.2.5.1.zip -HttpPort localhost:4225 -HttpsPort apmacwin:4325 -JavaHome "C:\Program Files\Java\jdk-11.0.12+7-jre" -JavaOptions "-Xms100m -Xmx256m" -MakeDirs