Skip to content

Commit

Permalink
Merge branch 'master' into r7s/tab-host
Browse files Browse the repository at this point in the history
  • Loading branch information
ravicious authored Jun 19, 2024
2 parents a25b1f8 + f5cdc23 commit f2a9b14
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 39 deletions.
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/aws/files/system/teleport-acm.service
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ ExecStart=/usr/local/bin/teleport start --config=/etc/teleport.yaml --diag-addr=
ExecReload=/bin/sh -c "exec pkill -HUP -L -F /run/teleport/teleport.pid"
PIDFile=/run/teleport/teleport.pid
LimitNOFILE=524288

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion examples/chart/event-handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This chart sets up and configures a Deployment for the Event Handler plugin.

## Installation

See the [Access Requests with Slack guide](https://goteleport.com/docs/access-controls/access-request-plugins/ssh-approval-slack/).
See the [Export Events with FluentD Guide](https://goteleport.com/docs/management/export-audit-events/fluentd/).

## Settings

Expand Down
23 changes: 10 additions & 13 deletions lib/web/scripts/oneoff/oneoff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ cdnBaseURL='{{.CDNBaseURL}}'
teleportVersion='{{.TeleportVersion}}'
teleportFlavor='{{.TeleportFlavor}}' # teleport or teleport-ent
successMessage='{{.SuccessMessage}}'
teleportArgs='{{.TeleportArgs}}'

# shellcheck disable=all
tempDir=$({{.BinMktemp}} -d)
# Use $HOME or / as base dir
tempDir=$({{.BinMktemp}} -d -p ${HOME:-}/)
OS=$({{.BinUname}} -s)
ARCH=$({{.BinUname}} -m)
# shellcheck enable=all

teleportArgs='{{.TeleportArgs}}'
trap 'rm -rf -- "$tempDir"' EXIT

teleportTarballName() {
if [ ${OS} = "Darwin" ]; then
Expand All @@ -36,19 +38,14 @@ teleportTarballName() {
}

main() {
cd $tempDir

tarballName=$(teleportTarballName)
curl --show-error --fail --location --remote-name ${cdnBaseURL}/${tarballName}
echo "Extracting teleport to $tempDir ..."
tar -xzf ${tarballName}

mkdir -p ./bin
mv ./${teleportFlavor}/teleport ./bin/teleport
echo "> ./bin/teleport ${teleportArgs} $@"
./bin/teleport ${teleportArgs} $@ && echo $successMessage
echo "Downloading from ${cdnBaseURL}/${tarballName} and extracting teleport to ${tempDir} ..."
curl --show-error --fail --location ${cdnBaseURL}/${tarballName} | tar xzf - -C ${tempDir} ${teleportFlavor}/teleport

cd -
mkdir -p ${tempDir}/bin
mv ${tempDir}/${teleportFlavor}/teleport ${tempDir}/bin/teleport
echo "> ${tempDir}/bin/teleport ${teleportArgs} $@"
${tempDir}/bin/teleport ${teleportArgs} $@ && echo $successMessage
}

main $@
26 changes: 18 additions & 8 deletions lib/web/scripts/oneoff/oneoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func TestOneOffScript(t *testing.T) {
teleportVersionOutput := "Teleport v13.1.0 git:api/v13.1.0-0-gd83ec74 go1.20.4"
scriptName := "oneoff.sh"

homeDir, err := os.UserHomeDir()
require.NoError(t, err)
homeDir = homeDir + "/"

unameMock, err := bintest.NewMock("uname")
require.NoError(t, err)
defer func() {
Expand Down Expand Up @@ -96,7 +100,7 @@ func TestOneOffScript(t *testing.T) {

unameMock.Expect("-s").AndWriteToStdout("Linux")
unameMock.Expect("-m").AndWriteToStdout("x86_64")
mktempMock.Expect("-d").AndWriteToStdout(testWorkingDir)
mktempMock.Expect("-d", "-p", homeDir).AndWriteToStdout(testWorkingDir)
teleportMock.Expect("version").AndWriteToStdout(teleportVersionOutput)

err = os.WriteFile(scriptLocation, []byte(script), 0700)
Expand All @@ -112,9 +116,12 @@ func TestOneOffScript(t *testing.T) {
require.True(t, mktempMock.Check(t))
require.True(t, teleportMock.Check(t))

require.Contains(t, string(out), "> ./bin/teleport version")
require.Contains(t, string(out), "teleport version")
require.Contains(t, string(out), teleportVersionOutput)
require.Contains(t, string(out), "Test was a success.")

// Script should remove the temporary directory.
require.NoDirExists(t, testWorkingDir)
})

t.Run("command can be executed with extra arguments", func(t *testing.T) {
Expand Down Expand Up @@ -151,7 +158,7 @@ func TestOneOffScript(t *testing.T) {

unameMock.Expect("-s").AndWriteToStdout("Linux")
unameMock.Expect("-m").AndWriteToStdout("x86_64")
mktempMock.Expect("-d").AndWriteToStdout(testWorkingDir)
mktempMock.Expect("-d", "-p", homeDir).AndWriteToStdout(testWorkingDir)
teleportMock.Expect("help", "start").AndWriteToStdout(teleportHelpStart)

err = os.WriteFile(scriptLocation, []byte(script), 0700)
Expand All @@ -167,9 +174,12 @@ func TestOneOffScript(t *testing.T) {
require.True(t, mktempMock.Check(t))
require.True(t, teleportMock.Check(t))

require.Contains(t, string(out), "> ./bin/teleport help start")
require.Contains(t, string(out), "/bin/teleport help start")
require.Contains(t, string(out), teleportHelpStart)
require.Contains(t, string(out), "Test was a success.")

// Script should remove the temporary directory.
require.NoDirExists(t, testWorkingDir)
})

t.Run("invalid OS", func(t *testing.T) {
Expand All @@ -179,7 +189,7 @@ func TestOneOffScript(t *testing.T) {

unameMock.Expect("-s").AndWriteToStdout("Windows")
unameMock.Expect("-m").AndWriteToStdout("x86_64")
mktempMock.Expect("-d").AndWriteToStdout(testWorkingDir)
mktempMock.Expect("-d", "-p", homeDir).AndWriteToStdout(testWorkingDir)

err = os.WriteFile(scriptLocation, []byte(script), 0700)
require.NoError(t, err)
Expand All @@ -199,7 +209,7 @@ func TestOneOffScript(t *testing.T) {

unameMock.Expect("-s").AndWriteToStdout("Linux")
unameMock.Expect("-m").AndWriteToStdout("apple-silicon")
mktempMock.Expect("-d").AndWriteToStdout(testWorkingDir)
mktempMock.Expect("-d", "-p", homeDir).AndWriteToStdout(testWorkingDir)

err = os.WriteFile(scriptLocation, []byte(script), 0700)
require.NoError(t, err)
Expand Down Expand Up @@ -261,7 +271,7 @@ func TestOneOffScript(t *testing.T) {

unameMock.Expect("-s").AndWriteToStdout("Linux")
unameMock.Expect("-m").AndWriteToStdout("x86_64")
mktempMock.Expect("-d").AndWriteToStdout(testWorkingDir)
mktempMock.Expect("-d", "-p", homeDir).AndWriteToStdout(testWorkingDir)
teleportMock.Expect("version").AndWriteToStdout(teleportVersionOutput)

err = os.WriteFile(scriptLocation, []byte(script), 0700)
Expand All @@ -277,7 +287,7 @@ func TestOneOffScript(t *testing.T) {
require.True(t, mktempMock.Check(t))
require.True(t, teleportMock.Check(t))

require.Contains(t, string(out), "> ./bin/teleport version")
require.Contains(t, string(out), "/bin/teleport version")
require.Contains(t, string(out), teleportVersionOutput)
require.Contains(t, string(out), "Test was a success.")
})
Expand Down
23 changes: 15 additions & 8 deletions web/packages/teleterm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ docs](https://goteleport.com/docs/connect-your-client/teleport-connect/).

## Building and packaging

**Note: At the moment, the OSS build of Connect is broken. Please refer to
[#17706](https://github.com/gravitational/teleport/issues/17706) for a temporary workaround.**

Teleport Connect consists of two main components: the `tsh` tool and the Electron app.

To get started, first we need to build `tsh`.
Expand Down Expand Up @@ -48,16 +45,26 @@ To launch `teleterm` in development mode:

```sh
cd teleport
# By default, the dev version assumes that the tsh binary is at build/tsh.
yarn start-term

# By default, the dev version assumes that the tsh binary is at build/tsh.
# You can provide a different absolute path to a tsh binary though the CONNECT_TSH_BIN_PATH env var.
# You can provide a different absolute path to the tsh binary though the CONNECT_TSH_BIN_PATH env var.
CONNECT_TSH_BIN_PATH=$PWD/build/tsh yarn start-term
```

For a quick restart which restarts the Electron app and the tsh daemon, press `F6` while the
Electron window is open. If you recompiled tsh, this is going to pick up any new changes as well as
any changes introduced to the main process of the Electron app.
To automatically restart the app when tsh gets rebuilt or
[when the main process or preload scripts change](https://electron-vite.org/guide/hot-reloading),
use [watchexec](https://github.com/watchexec/watchexec):

```sh
watchexec --restart --watch build --filter tsh --no-project-ignore -- yarn start-term -w
```

This can be combined with a tool like [gow](https://github.com/mitranim/gow) to automatically rebuild tsh:

```sh
gow -s -S '✅\n' -g make build/tsh
```

### Development-only tools

Expand Down

0 comments on commit f2a9b14

Please sign in to comment.