package templates import "converge/pkg/models" templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInputs UsageInputs) {

Downloading and running the agent

This is what you run on a remote server, typically in your continuous integration job.

if shells[BASH] {
{`
        `}curl http{access.Secure}://{access.HostPort}/static/agent > agent{`
        chmod 755 agent
        `}./agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{`
        rm -f agent
        `}
} if shells[CMD] || shells[POWERSHELL] {
{`
        `}curl http{access.Secure}://{access.HostPort}/static/agent.exe > agent.exe{`
        `}agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{`
        del agent.exe
        `}
}

The agent has more command-line options than shown here. Download the agent and run it without arguments to see all options.

Tip: Run the above command locally in a similar shell (for instance in a docker container) then try to connect to the shell using the commands below. If that works, then you are all set.

Connecting to the agent

{`
          `}ssh -oServerAliveInterval=10 -oProxyCommand="wsproxy ws{access.Secure}://{access.HostPort}/client/{usageInputs.Id}"  { access.Username }{"@localhost"}   {`
          `}sftp -oServerAliveInterval=10 -oProxyCommand="wsproxy ws{access.Secure}://{access.HostPort}/client/{usageInputs.Id}" { access.Username }{"@localhost"}   {`
          `}

Working with the agent

if shells[BASH] {
{`
        # cd back to the agent directory
        cd $agentdir

        # prevent logout when last user exits
        touch $agentdir/.hold
       `}
} if shells[CMD] {
{`
        # cd back to the agent directory
        cd %agentdir%

        # prevent logout when last user exits
        echo > %agentdir%\.hold
        `}
} if shells[POWERSHELL] {
{`
        # cd back to the agent directory
        cd $env:agentdir

        # prevent logout when last user exits
        $null > $env:agentdir\.hold
        `}
} if shells[CMD] || shells[POWERSHELL] {

windows

NOTE: When running the agent on windows, an exit of the remote session using exit in powershell or command prompt does not terminate the shell completely. To terminate the client ssh session must be killed by closing the terminal. Cleanup of remote processes on the agent appears to work properly despite this problem. It is just that exit of the windows shell (powershell or command prompt) is not detected properly.

}
} templ LocalShellUsage(access models.ConvergeAccess, shells map[string]bool, usageInput UsageInputs) {
if shells[BASH] {

bash

} if shells[CMD] {

cmd

} if shells[POWERSHELL] {

powershell

}
} templ ShellUsage(access models.ConvergeAccess, usageInputs UsageInputs) {
@AgentUsage(access, usageInputs.RemoteShells, usageInputs)
@LocalShellUsage(access, usageInputs.LocalShells, usageInputs) } templ Usage(access models.ConvergeAccess) {

Usage

                                         {`
          `}# linux                                                 {`
          `}echo "ssh-rsa dkddkdkkk a@b.c" > .authorized_keys       {`
          `}echo "ssh-rsa adfadjfdf d@e.f" >> .authorized_keys      {`
          `}                                                        {`
          `}# windows                                               {`
          `}echo ssh-rsa dkddkdkkk a@b.c > .authorized_keys         {`
          `}echo ssh-rsa adfadjfdf d@e.f >> .authorized_keys
                      

Note that on windows you should not used quotes.

} templ UsageTab(access models.ConvergeAccess) { @BasePage(2) { @Usage(access) } }