Documentation
¶
Index ¶
- Constants
- func ExecuteCommand(command string) (output string, err error)
- func ExecuteCommandAndWait(command string) (output string, err error)
- func FindMountPoint(path string) (string, error)
- func GetDefaultIP() (string, error)
- func GetFileNameDest(fileNameSource, dirDest string) string
- func GetPathDirMapLocal(dirName, rootPath string) (map[string]string, error)
- func GetPidFromPidFile(pidFile string) (int, error)
- func HandleSignalsWithPidFile(pidFile string)
- func IsDir(path string) (isDir bool, err error)
- func IsEmptyDir(dirName string) (isEmpty bool, err error)
- func IsRunningWithPid(pid int) (bool, error)
- func IsRunningWithPidFile(pidFile string) (bool, error)
- func KillServer(pid int, opts ...string) (err error)
- func MatchMountPoint(path string, mountPoints []string) (string, error)
- func PathExists(path string) (bool, error)
- func Readdir(dirName string) (fileInfoList []os.FileInfo, err error)
- func RemovePidFile(pidFile string) error
- func SavePid(pid int, pidFile string, fileMode os.FileMode) error
- func SendSignal(pid int, sig syscall.Signal, opts ...string) (err error)
- func ShutdownServer(pid int, opts ...string) (err error)
- func SyscallMode(fileMode os.FileMode) (fileModeSys uint32)
- func TailN(fileName string, n int) (lines []string, err error)
- type MyConn
- type MySSHConn
- func (conn *MySSHConn) Close() error
- func (conn *MySSHConn) CopyDirFromRemote(dirNameSource, dirNameDest string) error
- func (conn *MySSHConn) CopyDirToRemote(dirNameSource, dirNameDest string) error
- func (conn *MySSHConn) CopyFile(fileSource io.Reader, fileDest io.Writer, bufferSize int) error
- func (conn *MySSHConn) CopyFileListFromRemote(fileListSource []string, FileDirDest string) error
- func (conn *MySSHConn) CopyFileListFromRemoteWithNewName(fileListSource []string, fileListDest []string) (err error)
- func (conn *MySSHConn) CopyFromRemote(pathSource, pathDest string) (err error)
- func (conn *MySSHConn) CopySingleFileFromRemote(fileNameSource string, fileNameDest string) error
- func (conn *MySSHConn) CopySingleFileToRemote(fileNameSource string, fileNameDest string) error
- func (conn *MySSHConn) CopyToRemote(pathSource, pathDest string) (err error)
- func (conn *MySSHConn) ExecuteCommand(cmd string) (string, error)
- func (conn *MySSHConn) GetHostName() (string, error)
- func (conn *MySSHConn) GetPathDirMapRemote(dirName, rootPath string) (map[string]string, error)
- func (conn *MySSHConn) IsDir(path string) (bool, error)
- func (conn *MySSHConn) IsEmptyDir(dirName string) (bool, error)
- func (conn *MySSHConn) ListPath(path string) ([]string, error)
- func (conn *MySSHConn) PathExists(path string) (bool, error)
- func (conn *MySSHConn) ReadDir(dirName string) ([]os.FileInfo, error)
- func (conn *MySSHConn) RemoveAll(path string) error
Constants ¶
const ( HostNameCommand = "hostname" LsCommand = "ls" DefaultEstimateLineSize = 1024 MinStartPosition = 0 )
const ( DefaultSplitStr = "\n" DefaultSuccessReturnValue = 0 DefaultFailedReturnValue = 1 DefaultSSHTimeout = 10 * time.Second DefaultSSHPortNum = 22 DefaultSSHUserName = "root" DefaultSSHUserPass = "root" DefaultByteBufferSize = 1024 * 1024 // 1MB )
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommand ¶ added in v0.1.4
ExecuteCommand is an alias of ExecuteCommandAndWait
func ExecuteCommandAndWait ¶ added in v0.1.20
ExecuteCommandAndWait executes shell command and wait for it to complete
func FindMountPoint ¶ added in v0.3.10
FindMountPoint returns the mount point of the given path, note that this function only works on unix-like system
func GetDefaultIP ¶
GetDefaultIP gets the default non-local ip, if there are more than one ips, it will return the first one
func GetFileNameDest ¶ added in v0.1.4
GetFileNameDest returns the destination file name
func GetPathDirMapLocal ¶ added in v0.1.5
GetPathDirMapLocal reads all subdirectories and files of given directory and calculate the relative path of rootPath, then map the absolute path of subdirectory names and file names as keys, relative paths as values to fileDirMap
func GetPidFromPidFile ¶ added in v0.1.17
GetPidFromPidFile reads pid file and returns pid
func HandleSignalsWithPidFile ¶ added in v0.1.15
func HandleSignalsWithPidFile(pidFile string)
HandleSignalsWithPidFile handles operating system signals
func IsEmptyDir ¶ added in v0.1.4
IsEmptyDir returns if given directory is empty or not
func IsRunningWithPid ¶ added in v0.1.15
IsRunningWithPid returns if given pid is running
func IsRunningWithPidFile ¶ added in v0.1.15
IsRunningWithPidFile returns if process of which pid was saved in given pid file is running
func KillServer ¶ added in v0.1.18
KillServer kills server with given pid, it acts like shell command "kill -9", it will also remove pid file if pid file path is specified as opts
func MatchMountPoint ¶ added in v0.3.11
MatchMountPoint matches mount point of given path in the mount point slice, if nothing matched, it returns "/" as default mount point
func PathExists ¶ added in v0.1.5
PathExists returns if given path exists
func Readdir ¶ added in v0.1.4
Readdir returns subdirectories and files of given directory on the remote host, it returns a slice of os.FileInfo
func RemovePidFile ¶ added in v0.1.19
func SendSignal ¶ added in v0.2.19
SendSignal sends signal to given pid, it will also remove pid file if pid file path is specified as opts
func ShutdownServer ¶ added in v0.2.19
ShutdownServer kills server with given pid, it acts like shell command "kill -15", it will also remove pid file if pid file path is specified as opts
func SyscallMode ¶ added in v0.1.4
SyscallMode returns file mode which could be used at syscall
Types ¶
type MyConn ¶ added in v0.1.4
func NewMyConnWithDefaultValue ¶ added in v0.1.4
type MySSHConn ¶ added in v0.1.4
func NewMySSHConn ¶ added in v0.1.4
NewMySSHConn returns *MySSHConn and error
func NewMySSHConnWithOptionalArgs ¶ added in v0.1.4
NewMySSHConnWithOptionalArgs returns *MySSHConn and error, first argument is mandatory which presents host ip, and the 3 flowing optional arguments which should be in exact order of port number, user name and user password
func (*MySSHConn) CopyDirFromRemote ¶ added in v0.1.4
CopyDirFromRemote copies a directory with all subdirectories and files from remote to local
func (*MySSHConn) CopyDirToRemote ¶ added in v0.1.4
CopyDirToRemote copies a directory with all subdirectories and files from local to remote
func (*MySSHConn) CopyFile ¶ added in v0.1.4
CopyFile copy file content from source to destination, it doesn't care about which one is local or remote
func (*MySSHConn) CopyFileListFromRemote ¶ added in v0.1.4
CopyFileListFromRemote copies given files from remote to local
func (*MySSHConn) CopyFileListFromRemoteWithNewName ¶ added in v0.1.4
func (conn *MySSHConn) CopyFileListFromRemoteWithNewName(fileListSource []string, fileListDest []string) (err error)
CopyFileListFromRemoteWithNewName copies file from remote to local, it copies file contents and rename files to given file names
func (*MySSHConn) CopyFromRemote ¶ added in v0.1.4
CopyFromRemote copies no matter a directory or a file from remote to local
func (*MySSHConn) CopySingleFileFromRemote ¶ added in v0.1.4
CopySingleFileFromRemote copies one single file from remote to local
func (*MySSHConn) CopySingleFileToRemote ¶ added in v0.1.4
CopySingleFileToRemote copies one single file from local to remote
func (*MySSHConn) CopyToRemote ¶ added in v0.1.4
CopyToRemote copies no matter a directory or a file from local to remote
func (*MySSHConn) ExecuteCommand ¶ added in v0.1.4
ExecuteCommand executes shell command on the remote host
func (*MySSHConn) GetHostName ¶ added in v0.1.4
GetHostName returns hostname of remote host
func (*MySSHConn) GetPathDirMapRemote ¶ added in v0.1.5
GetPathDirMapRemote reads all subdirectories and files of given directory on the remote host and calculate the relative path of rootPath, then map the absolute path of subdirectory names and file names as keys, relative paths as values to fileDirMap
func (*MySSHConn) IsDir ¶ added in v0.1.4
IsDir returns if given path on the remote host is a directory or not
func (*MySSHConn) IsEmptyDir ¶ added in v0.1.4
IsEmptyDir returns if given directory is empty or not
func (*MySSHConn) ListPath ¶ added in v0.1.4
ListPath returns subdirectories and files of given path on the remote host, it returns a slice of sub paths
func (*MySSHConn) PathExists ¶ added in v0.1.5
PathExists returns if given path exists