Skip to content

Commit

Permalink
tools: install tsshd to ~/.local/bin
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Jul 20, 2024
1 parent 301064f commit de399f8
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 62 deletions.
3 changes: 3 additions & 0 deletions tssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ type sshArgs struct {
NewHost bool `arg:"--new-host" help:"[tools] add new host to configuration"`
EncSecret bool `arg:"--enc-secret" help:"[tools] encode secret for configuration"`
InstallTrzsz bool `arg:"--install-trzsz" help:"[tools] install trzsz to the remote server"`
InstallTsshd bool `arg:"--install-tsshd" help:"[tools] install tsshd to the remote server"`
InstallPath string `arg:"--install-path" placeholder:"path" help:"[tools] install path, default: '~/.local/bin/'"`
TrzszVersion string `arg:"--trzsz-version" placeholder:"x.x.x" help:"[tools] install the specified version of trzsz"`
TrzszBinPath string `arg:"--trzsz-bin-path" placeholder:"path" help:"[tools] trzsz binary installation package path"`
TsshdVersion string `arg:"--tsshd-version" placeholder:"x.x.x" help:"[tools] install the specified version of tsshd"`
TsshdBinPath string `arg:"--tsshd-bin-path" placeholder:"path" help:"[tools] tsshd binary installation package path"`
originalDest string
}

Expand Down
4 changes: 4 additions & 0 deletions tssh/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ func TestSshArgs(t *testing.T) {
assertArgsEqual("--new-host", sshArgs{NewHost: true})
assertArgsEqual("--enc-secret", sshArgs{EncSecret: true})
assertArgsEqual("--install-trzsz", sshArgs{InstallTrzsz: true})
assertArgsEqual("--install-tsshd", sshArgs{InstallTsshd: true})
assertArgsEqual("--install-trzsz --install-path /bin", sshArgs{InstallTrzsz: true, InstallPath: "/bin"})
assertArgsEqual("--install-trzsz --trzsz-version 1.1.6", sshArgs{InstallTrzsz: true, TrzszVersion: "1.1.6"})
assertArgsEqual("--install-trzsz --trzsz-bin-path a.tgz", sshArgs{InstallTrzsz: true, TrzszBinPath: "a.tgz"})
assertArgsEqual("--install-tsshd --install-path /bin", sshArgs{InstallTsshd: true, InstallPath: "/bin"})
assertArgsEqual("--install-tsshd --tsshd-version 0.1.2", sshArgs{InstallTsshd: true, TsshdVersion: "0.1.2"})
assertArgsEqual("--install-tsshd --tsshd-bin-path b.tgz", sshArgs{InstallTsshd: true, TsshdBinPath: "b.tgz"})

assertArgsEqual("dest", sshArgs{Destination: "dest"})
assertArgsEqual("dest cmd", sshArgs{Destination: "dest", Command: "cmd"})
Expand Down
6 changes: 4 additions & 2 deletions tssh/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,10 @@ func execLocalTools(argv []string, args *sshArgs) (int, bool) {

// execRemoteTools execute remote tools if necessary
func execRemoteTools(args *sshArgs, client SshClient) {
switch {
case args.InstallTrzsz:
if args.InstallTrzsz {
execInstallTrzsz(args, client)
}
if args.InstallTsshd {
execInstallTsshd(args, client)
}
}
Loading

0 comments on commit de399f8

Please sign in to comment.