BUILD: add a build makefile target
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
efd26e1c35
commit
665c244522
|
@ -9,3 +9,4 @@ example-splash/example-splash
|
|||
example-ssh/ssh-client
|
||||
example-ssh/ssh-ed25519
|
||||
example-ssh/with-passwd
|
||||
example-expect/example-expect
|
||||
|
|
10
Makefile
10
Makefile
|
@ -10,6 +10,16 @@ GO111MODULE=on
|
|||
|
||||
run:
|
||||
|
||||
build:
|
||||
# shell things
|
||||
cd example-expect; go install # traditional 'expect' shell automation
|
||||
cd example-shell; go install # a tty wrapper
|
||||
|
||||
# GUI things
|
||||
cd example-splash; go install # an example GUI with drop down menus, etc
|
||||
cd example-systray; go install # an example systray menu (cross platform)
|
||||
cd example-controlgallery; go install # an example GUI with drop down menus, etc
|
||||
|
||||
debug:
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}' -X main.VERSION=${VERSION}"
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ be sub-par verses the Linux and Macintosh versions
|
|||
# build
|
||||
|
||||
```
|
||||
go get -v -t -u git.wit.org/wit/control-panel-tests
|
||||
cd ~/go/src/git.wit.org/wit/control-panel-tests
|
||||
make
|
||||
go get -v -t -u git.wit.org/jcarr/golang-examples
|
||||
cd ~/go/src/git.wit.org/jcarr/golang-examples
|
||||
make build
|
||||
```
|
||||
|
||||
# screenshots
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
all:
|
||||
go get -v -t -u .
|
||||
go install
|
|
@ -1,6 +1,5 @@
|
|||
// 12 august 2018
|
||||
|
||||
// +build OMIT
|
||||
|
||||
package main
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
|
||||
"github.com/google/goexpect"
|
||||
"github.com/google/goterm/term"
|
||||
)
|
||||
|
||||
const (
|
||||
timeout = 10 * time.Minute
|
||||
)
|
||||
|
||||
var (
|
||||
addr = flag.String("address", "", "address of telnet server")
|
||||
user = flag.String("user", "user", "username to use")
|
||||
pass1 = flag.String("pass1", "pass1", "password to use")
|
||||
pass2 = flag.String("pass2", "pass2", "alternate password to use")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fmt.Println(term.Bluef("SSH Example"))
|
||||
|
||||
sshClt, err := ssh.Dial("tcp", *addr, &ssh.ClientConfig{
|
||||
User: *user,
|
||||
Auth: []ssh.AuthMethod{ssh.Password(*pass1)},
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("ssh.Dial(%q) failed: %v", *addr, err)
|
||||
}
|
||||
defer sshClt.Close()
|
||||
|
||||
e, _, err := expect.SpawnSSH(sshClt, timeout)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer e.Close()
|
||||
|
||||
e.ExpectBatch([]expect.Batcher{
|
||||
&expect.BCas{[]expect.Caser{
|
||||
&expect.Case{R: regexp.MustCompile(`router#`), T: expect.OK()},
|
||||
&expect.Case{R: regexp.MustCompile(`Login: `), S: *user,
|
||||
T: expect.Continue(expect.NewStatus(codes.PermissionDenied, "wrong username")), Rt: 3},
|
||||
&expect.Case{R: regexp.MustCompile(`Password: `), S: *pass1, T: expect.Next(), Rt: 1},
|
||||
&expect.Case{R: regexp.MustCompile(`Password: `), S: *pass2,
|
||||
T: expect.Continue(expect.NewStatus(codes.PermissionDenied, "wrong password")), Rt: 1},
|
||||
}},
|
||||
}, timeout)
|
||||
|
||||
fmt.Println(term.Greenf("All done"))
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
package main
|
||||
// +build ignore
|
||||
|
||||
package ls
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
|
Loading…
Reference in New Issue