From 8e6cbe38f02e6d30cf54508c9aa3039ba23e9d64 Mon Sep 17 00:00:00 2001 From: dcorral Date: Thu, 6 Nov 2025 14:45:15 +0100 Subject: [PATCH] Add COMMAND env variable support for shell command --- {.github => .gitea}/workflows/build-and-push.yml | 0 Dockerfile | 2 ++ docker-compose.yml | 11 ----------- main.go | 6 +++++- 4 files changed, 7 insertions(+), 12 deletions(-) rename {.github => .gitea}/workflows/build-and-push.yml (100%) delete mode 100644 docker-compose.yml diff --git a/.github/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml similarity index 100% rename from .github/workflows/build-and-push.yml rename to .gitea/workflows/build-and-push.yml diff --git a/Dockerfile b/Dockerfile index 75b8f21..7d67453 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ RUN apk add --no-cache ca-certificates COPY --from=builder /app/sshserver /usr/local/bin/sshserver +ENV COMMAND /app/tui + EXPOSE 22 CMD ["/usr/local/bin/sshserver"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index ca42381..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - ssh-server: - image: ssh-server - build: . - ports: - - "22:22" - volumes: - - ../tui:/app/tui:ro - cap_add: - - SYS_CHROOT - restart: unless-stopped diff --git a/main.go b/main.go index bc17c3d..4862a0d 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,11 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) { req.Reply(true, nil) case "shell": req.Reply(true, nil) - cmd := exec.Command("/app/tui") + command := os.Getenv("COMMAND") + if command == "" { + command = "/app/tui" + } + cmd := exec.Command(command) cmd.Env = []string{"PATH=/bin"} cmd.Dir = "/" var err error