From 457f60f8157fa15192ed8e817dcaeb277f741158 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Sun, 31 Dec 2017 16:31:25 +0100 Subject: [PATCH] Use `sshportal server` instead of `sshportal` to start a new server --- CHANGELOG.md | 4 ++ Dockerfile | 1 + examples/mysql/docker-compose.yml | 2 +- main.go | 76 +++++++++++++++++-------------- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f419916..33108d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +Breaking changes: +* Use `sshportal server` instead of `sshportal` to start a new server (nothing to change if using the docker image) + +Changes: * Fix connection failure when sending too many environment variables (fix [#22](https://github.com/moul/sshportal/issues/22)) * Fix panic when entering empty command (fix [#13](https://github.com/moul/sshportal/issues/13)) diff --git a/Dockerfile b/Dockerfile index 00ac0fa..5a29c40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,3 +8,4 @@ RUN make _docker_install FROM scratch COPY --from=builder /go/bin/sshportal /bin/sshportal ENTRYPOINT ["/bin/sshportal"] +CMD ["server"] diff --git a/examples/mysql/docker-compose.yml b/examples/mysql/docker-compose.yml index 94c78b5..e7f2e1a 100644 --- a/examples/mysql/docker-compose.yml +++ b/examples/mysql/docker-compose.yml @@ -9,7 +9,7 @@ services: condition: service_healthy links: - mysql - command: --db-driver=mysql --debug --db-conn="root:root@tcp(mysql:3306)/db?charset=utf8&parseTime=true&loc=Local" + command: server --db-driver=mysql --debug --db-conn="root:root@tcp(mysql:3306)/db?charset=utf8&parseTime=true&loc=Local" ports: - 2222:2222 diff --git a/main.go b/main.go index 5b6c21c..f8e3030 100644 --- a/main.go +++ b/main.go @@ -45,43 +45,49 @@ func main() { app.Author = "Manfred Touron" app.Version = Version + " (" + GitSha + ")" app.Email = "https://github.com/moul/sshportal" - app.Flags = []cli.Flag{ - cli.StringFlag{ - Name: "bind-address, b", - EnvVar: "SSHPORTAL_BIND", - Value: ":2222", - Usage: "SSH server bind address", - }, - cli.StringFlag{ - Name: "db-driver", - Value: "sqlite3", - Usage: "GORM driver (sqlite3)", - }, - cli.StringFlag{ - Name: "db-conn", - Value: "./sshportal.db", - Usage: "GORM connection string", - }, - cli.BoolFlag{ - Name: "debug, D", - Usage: "Display debug information", - }, - cli.StringFlag{ - Name: "config-user", - Usage: "SSH user that spawns a configuration shell", - Value: "admin", - }, - cli.StringFlag{ - Name: "healthcheck-user", - Usage: "SSH user that returns healthcheck status without checking the SSH key", - Value: "healthcheck", - }, - cli.StringFlag{ - Name: "aes-key", - Usage: "Encrypt sensitive data in database (length: 16, 24 or 32)", + app.Commands = []cli.Command{ + { + Name: "server", + Usage: "Start sshportal server", + Action: server, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "bind-address, b", + EnvVar: "SSHPORTAL_BIND", + Value: ":2222", + Usage: "SSH server bind address", + }, + cli.StringFlag{ + Name: "db-driver", + Value: "sqlite3", + Usage: "GORM driver (sqlite3)", + }, + cli.StringFlag{ + Name: "db-conn", + Value: "./sshportal.db", + Usage: "GORM connection string", + }, + cli.BoolFlag{ + Name: "debug, D", + Usage: "Display debug information", + }, + cli.StringFlag{ + Name: "config-user", + Usage: "SSH user that spawns a configuration shell", + Value: "admin", + }, + cli.StringFlag{ + Name: "healthcheck-user", + Usage: "SSH user that returns healthcheck status without checking the SSH key", + Value: "healthcheck", + }, + cli.StringFlag{ + Name: "aes-key", + Usage: "Encrypt sensitive data in database (length: 16, 24 or 32)", + }, + }, }, } - app.Action = server if err := app.Run(os.Args); err != nil { log.Fatalf("error: %v", err) }