utils

package
v0.0.0-...-e40cc08 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfPathExist

func CheckIfPathExist(path string) bool

func CheckIfServiceIsActive

func CheckIfServiceIsActive(serv string) (bool, error)

CheckIfServiceIsActive checks if a service is active or running

func CheckIfServiceIsInstalled

func CheckIfServiceIsInstalled(serv string) (bool, error)

CheckIfServiceIsInstalled checks if a service is installed

func CreateLinuxService

func CreateLinuxService(serviceName string, execStart string) error

func CreateLogger

func CreateLogger(filename string) *logger.Logger

CreateLogger returns a single instance of a Logger configured to save logs to a rotating file.

func CreatePathIfNotExist

func CreatePathIfNotExist(path string) error

CreatePathIfNotExist creates a specific path if not exist

func DetectLinuxFamily

func DetectLinuxFamily() (string, error)

func Execute

func Execute(c string, dir string, arg ...string) error

func ExecuteWithResult

func ExecuteWithResult(c string, dir string, arg ...string) (string, bool)

func FindLatestLog

func FindLatestLog(path string, pattern *regexp.Regexp) (string, error)

func GenerateCerts

func GenerateCerts(folder string) error

func GenerateFromTemplate

func GenerateFromTemplate(data interface{}, tfile string, cfile string) error

func GenerateKey

func GenerateKey(REPALCE_KEY string) ([]byte, error)

func GenerateKeyByUUID

func GenerateKeyByUUID(REPLACE_KEY string, uuid string) ([]byte, error)

func GetHostAliases

func GetHostAliases(hostname string) ([]string, error)

func GetIPAddress

func GetIPAddress() (string, error)

func GetMyPath

func GetMyPath() (string, error)

GetMyPath returns the directory path where the currently running executable is located. Returns a string representing the directory path, and an error if any error occurs during the process.

func IncrementReconnectDelay

func IncrementReconnectDelay(delay time.Duration, maxReconnectDelay time.Duration) time.Duration

func IncrementReconnectTime

func IncrementReconnectTime(currentTime time.Duration, delay time.Duration, maxReconnectTime time.Duration) time.Duration

func IsDirEmpty

func IsDirEmpty(path string) (bool, error)

func IsPortUsed

func IsPortUsed(proto string, port string) bool

func LoadTLSCredentials

func LoadTLSCredentials(crtName string) (credentials.TransportCredentials, error)

func ReadFileLines

func ReadFileLines(path string) ([]string, error)

func ReadJson

func ReadJson(fileName string, data interface{}) error

func ReadYAML

func ReadYAML(path string, result interface{}) error

ReadYAML reads the YAML data from the specified file URL and deserializes it into the provided result interface{}. Returns an error if any error occurs during the process.

func RestartService

func RestartService(serv string) error

RestartService restarts a service

func SentLog

func SentLog(msg string) error

func StopService

func StopService(name string) error

func TailLogFile

func TailLogFile(filePath string, logLinesChan chan []string, stopChan chan bool, batchCapacity int, h *logger.Logger)

func UninstallService

func UninstallService(name string) error

func WatchFolder

func WatchFolder(logType string, logsPath string, logLinesChan chan []string, batchCapacity int, h *logger.Logger)

func WriteJSON

func WriteJSON(path string, data interface{}) error

func WriteYAML

func WriteYAML(url string, data interface{}) error

Types

type OSInfo

type OSInfo struct {
	Hostname       string
	OsType         string
	Platform       string
	Version        string
	CurrentUser    string
	Mac            string
	OsMajorVersion string
	OsMinorVersion string
	Aliases        string
	Addresses      string
}

func GetOsInfo

func GetOsInfo() (*OSInfo, error)

Jump to

Keyboard shortcuts

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