util

package
v6.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const GitChangeIsSelf = true
View Source
const GitChangeNotSelf = false
View Source
const OneWeek = 604800

Variables

This section is empty.

Functions

func CheckUser

func CheckUser(cfg config.Cfg) bool

func CleanTmpDir

func CleanTmpDir(cfg config.Cfg) bool

func DirectoryExists

func DirectoryExists(dir string) (bool, os.FileInfo)

func EnsureConfigDirIsGitRepo

func EnsureConfigDirIsGitRepo(cfg config.Cfg) error

func ExecCommand

func ExecCommand(fullCommand string, arg ...string) ([]byte, int, error)

func FileExists

func FileExists(fn string) (bool, os.FileInfo)

func MakeGitCommitAll

func MakeGitCommitAll(cfg config.Cfg, self bool, success bool) error

makeGitCommitAll makes a git commit of all changes in cfg.TsConfigDir, including untracked files.

func MkDir

func MkDir(name string, cfg config.Cfg) bool

func MkDirAll

func MkDirAll(name string, cfg config.Cfg) bool

func MkDirWithOwner

func MkDirWithOwner(name string, cfg config.Cfg, uid *int, gid *int) bool

func PackageAction

func PackageAction(cmdstr string, name string) (bool, error)

func PackageInfo

func PackageInfo(cmdstr string, name string) ([]string, error)

runs the rpm command. if the return code from rpm == 0, then a valid package list is returned.

if the return code is 1, the the 'name' queried for is not part of a

package or is not installed.

otherwise, if the return code is not 0 or 1 and error is set, a general rpm command execution error is assumed and the error is returned.

func RandomDuration

func RandomDuration(max time.Duration) time.Duration

func ReadFile

func ReadFile(fn string) ([]byte, error)

func ServiceStart

func ServiceStart(service string, cmd string) (bool, error)

start or restart the service 'service'. cmd is 'start | restart'

func Touch

func Touch(fn string) error

func UpdateMaxmind

func UpdateMaxmind(cfg config.Cfg) bool

func WriteFileWithOwner

func WriteFileWithOwner(fn string, data []byte, uid *int, gid *int, perm os.FileMode) (int, error)

Types

type FileLock

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

func (*FileLock) GetLock

func (f *FileLock) GetLock(lockFile string) bool

Try to get a file lock, non-blocking.

func (*FileLock) UnlockAndExit

func (f *FileLock) UnlockAndExit(code int)

Releases a file lock and exits with the given status code.

type ServiceStatus

type ServiceStatus int
const (
	SvcNotRunning ServiceStatus = 0
	SvcRunning    ServiceStatus = 1
	SvcUnknown    ServiceStatus = 2
)

func GetServiceStatus

func GetServiceStatus(name string) (ServiceStatus, int, error)

func (ServiceStatus) String

func (s ServiceStatus) String() string

Jump to

Keyboard shortcuts

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