Skip to content

Commit

Permalink
Use a script to setup environment
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Oct 28, 2021
1 parent 9aee9f8 commit 0033510
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/supervisor/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ packages:
type: docker
srcs:
- "supervisor-config.json"
- ssh-connect.sh
deps:
- :app
- components/supervisor/frontend:app
Expand Down
1 change: 1 addition & 0 deletions components/supervisor/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ COPY components-supervisor--app/supervisor \
WORKDIR "/.supervisor/ssh"
COPY components-supervisor-openssh--app/usr/sbin/sshd .
COPY components-supervisor-openssh--app/usr/bin/ssh-keygen .
COPY ssh-connect.sh .

ENTRYPOINT ["/.supervisor/supervisor"]
3 changes: 3 additions & 0 deletions components/supervisor/pkg/supervisor/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (s *sshServer) handleConn(ctx context.Context, conn net.Conn) {
return
}

connectCommand := filepath.Join(filepath.Dir(bin), "ssh", "ssh-connect.sh")

args := []string{
"-iedD", "-f/dev/null",
"-oProtocol 2",
Expand All @@ -92,6 +94,7 @@ func (s *sshServer) handleConn(ctx context.Context, conn net.Conn) {
"-oPidFile /dev/null",
"-oUseDNS no", // Disable DNS lookups.
"-oSubsystem sftp internal-sftp",
"-oForceCommand " + connectCommand,
}

if os.Getenv("SUPERVISOR_DEBUG_ENABLE") != "" {
Expand Down
16 changes: 16 additions & 0 deletions components/supervisor/ssh-connect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Copyright (c) 2021 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.


if [ -f "${HOME}/.profile" ]; then
# shellcheck disable=SC1090
source ~/.profile
fi;

if [ -z "$SSH_ORIGINAL_COMMAND" ]; then
$SHELL --login
else
eval "${SSH_ORIGINAL_COMMAND}"
fi

0 comments on commit 0033510

Please sign in to comment.