fixed issue in usage page where local shell was not used at all.

This commit is contained in:
Erik Brakkee 2024-08-03 21:18:44 +02:00
parent d3f9c9fd5a
commit a6bbafe593

View File

@ -3,7 +3,7 @@ package templates
import "converge/pkg/models" import "converge/pkg/models"
templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInputs UsageInputs) { templ AgentUsage(access models.ConvergeAccess, usageInputs UsageInputs) {
<div> <div>
<h2>Downloading and running the agent</h2> <h2>Downloading and running the agent</h2>
@ -11,7 +11,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
This is what you run on a remote server, typically in your continuous integration job. This is what you run on a remote server, typically in your continuous integration job.
</p> </p>
if shells[BASH] { if usageInputs.RemoteShells[BASH] {
<pre>{addSshKeys(BASH, usageInputs.SshKeys)} <pre>{addSshKeys(BASH, usageInputs.SshKeys)}
curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent > agent{` curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent > agent{`
chmod 755 agent chmod 755 agent
@ -19,14 +19,14 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
rm -f agent rm -f agent
`}</pre> `}</pre>
} }
if shells[CMD] { if usageInputs.RemoteShells[CMD] {
<pre>{addSshKeys(CMD, usageInputs.SshKeys)} <pre>{addSshKeys(CMD, usageInputs.SshKeys)}
curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent.exe > agent.exe{` curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent.exe > agent.exe{`
`}agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{` `}agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{`
del agent.exe del agent.exe
`}</pre> `}</pre>
} }
if shells[POWERSHELL] { if usageInputs.RemoteShells[POWERSHELL] {
<pre>{addSshKeys(POWERSHELL, usageInputs.SshKeys)} <pre>{addSshKeys(POWERSHELL, usageInputs.SshKeys)}
curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent.exe > agent.exe{` curl --fail-with-body http{access.Secure}://{access.HostPort}/downloads/agent.exe > agent.exe{`
`}agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{` `}agent --id {usageInputs.Id} ws{access.Secure}://{access.HostPort}{`
@ -85,7 +85,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
<h2>Working with the agent</h2> <h2>Working with the agent</h2>
if shells[BASH] { if usageInputs.RemoteShells[BASH] {
<pre>{` <pre>{`
# cd back to the agent directory # cd back to the agent directory
cd $agentdir cd $agentdir
@ -95,7 +95,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
`}</pre> `}</pre>
} }
if shells[CMD] { if usageInputs.RemoteShells[CMD] {
<pre>{` <pre>{`
# cd back to the agent directory # cd back to the agent directory
cd %agentdir% cd %agentdir%
@ -104,7 +104,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
echo > %agentdir%\.hold echo > %agentdir%\.hold
`}</pre> `}</pre>
} }
if shells[POWERSHELL] { if usageInputs.RemoteShells[POWERSHELL] {
<pre>{` <pre>{`
# cd back to the agent directory # cd back to the agent directory
cd $env:agentdir cd $env:agentdir
@ -113,8 +113,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
$null > $env:agentdir\.hold $null > $env:agentdir\.hold
`}</pre> `}</pre>
} }
if shells[CMD] || shells[POWERSHELL] { if usageInputs.RemoteShells[CMD] || usageInputs.RemoteShells[POWERSHELL] {
<p>windows</p>
<p> <p>
NOTE: When running the agent on windows, an exit of the remote session using 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. exit in powershell or command prompt does not terminate the shell completely.
@ -130,7 +129,7 @@ templ AgentUsage(access models.ConvergeAccess, shells map[string]bool, usageInpu
templ ShellUsage(access models.ConvergeAccess, usageInputs UsageInputs) { templ ShellUsage(access models.ConvergeAccess, usageInputs UsageInputs) {
<div> <div>
@AgentUsage(access, usageInputs.RemoteShells, usageInputs) @AgentUsage(access, usageInputs)
</div> </div>
} }
@ -173,14 +172,14 @@ templ Usage(access models.ConvergeAccess) {
<input id="remote-shell-2" name="remote-shell" type="radio" value={POWERSHELL}> <label for="remote-shell-2">power shell</label> <input id="remote-shell-2" name="remote-shell" type="radio" value={POWERSHELL}> <label for="remote-shell-2">power shell</label>
</td> </td>
</tr> </tr>
<tr> <!--tr>
<td class="minimal-width"><label for="local-shell">local environment</label></td> <td class="minimal-width"><label for="local-shell">local environment</label></td>
<td> <td>
<input id="checked local-shell-0" name="local-shell" type="radio" value={BASH}> <label for="local-shell-0">*.sh</label> <input id="checked local-shell-0" name="local-shell" type="radio" value={BASH}> <label for="local-shell-0">*.sh</label>
<input id="local-shell-1" name="local-shell" type="radio" value={CMD}> <label for="local-shell-1">command prompt</label> <input id="local-shell-1" name="local-shell" type="radio" value={CMD}> <label for="local-shell-1">command prompt</label>
<input id="local-shell-2" name="local-shell" type="radio" value={POWERSHELL}> <label for="local-shell-2">powershell</label> <input id="local-shell-2" name="local-shell" type="radio" value={POWERSHELL}> <label for="local-shell-2">powershell</label>
</td> </td>
</tr> </tr -->
</table> </table>
</form> </form>