loginshell

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdRet

type CmdRet struct {
	Cmd     string
	Output  string
	RC      int
	Elapsed time.Duration
}

CmdRet - a command execution result.

func (*CmdRet) AssertMatches

func (c *CmdRet) AssertMatches(match, msg string)

AssertMatches - regexp 'match' is not found in string 'msg'

func (*CmdRet) Error

func (c *CmdRet) Error() error

func (*CmdRet) ErrorRC

func (c *CmdRet) ErrorRC(rc int) error

ErrorRC - return a CmdRet mentioning expected rc and actual.

func (*CmdRet) Matches

func (c *CmdRet) Matches(match string) bool

Matches - return a regexp.MatchString on c.Output

func (*CmdRet) String

func (c *CmdRet) String() string

func (*CmdRet) StringIndent

func (c *CmdRet) StringIndent(indent string) string

StringIndent - get a cmdRet String with indentation.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell - A login shell, set to execute comands.

func Login

func Login(c *goexpect.GExpect, user string, password string) (*Shell, error)

Login - Login at a 'login:' prompt with user and password.

func (*Shell) CheckOnly

func (l *Shell) CheckOnly(cmd string) error

CheckOnly - execute cmd and return error or nil.

func (*Shell) CheckRCTimeout

func (l *Shell) CheckRCTimeout(cmd string, rc int, timeout time.Duration) (CmdRet, error)

CheckRCTimeout - execute cmd, return a CmdRet, and error if rc != cmdR.RC

func (*Shell) Logout

func (l *Shell) Logout() error

Logout - log the current login out.

func (*Shell) Poweroff

func (l *Shell) Poweroff() error

Poweroff - just power off the machine and wait for the final "Power down" message. This is its own helper because you could not use RunBash for the obvious reason.

func (*Shell) Reboot

func (l *Shell) Reboot() error

Reboot - send a reboot command.

func (*Shell) Run

func (l *Shell) Run(cmd string) CmdRet

Run - execute cmd, expect result in defaultTimeout

func (*Shell) RunTimeout

func (l *Shell) RunTimeout(cmd string, timeout time.Duration) CmdRet

RunTimeout - pass 'cmd' to bash.

Fatalf on command execution error or timeout.
return error if CmdRet.RC != 0

func (*Shell) WaitForBooted

func (l *Shell) WaitForBooted() error

WaitForBooted - after system is logged in, wait until systemd says it is ready.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL