os

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package os provides a set of functions to interact with the operating system.

Copyright © 2023 zcubbs https://github.com/zcubbs

Package os provides a set of functions to interact with the operating system.

Copyright © 2023 zcubbs https://github.com/zcubbs

Package os provides a set of functions to interact with the operating system.

Copyright © 2023 zcubbs https://github.com/zcubbs

Package os provides a set of functions to interact with the operating system.

Copyright © 2023 zcubbs https://github.com/zcubbs

Index

Constants

View Source
const (
	BinSH = "/bin/sh"
)

Variables

This section is empty.

Functions

func AddCronJob

func AddCronJob(cronJob string) error

AddCronJob adds a new cron job to the current user's crontab. The cronJob parameter should be the full string of the cron job, e.g., "* * * * * /path/to/script.sh".

func AddNewUser

func AddNewUser(name string) (string, error)

AddNewUser is created by executing shell command useradd

func AddUserIfNotExist

func AddUserIfNotExist(name string) (string, error)

AddUserIfNotExist check if user exist on the host

func BytesToString added in v0.1.6

func BytesToString(b uint64) string

func CopyFileToDestination

func CopyFileToDestination(srcFile, destFile string) error

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

func CreateFileWithPath

func CreateFileWithPath(path string) (*os.File, error)

CreateFileWithPath creates a file with the specified path. It will create any required directories in the path if they don't exist.

func CreateRandom

func CreateRandom(n int) string

func DeleteUser

func DeleteUser(name string) error

DeleteUser is created by executing shell command userdel

func DeleteUserIfExist

func DeleteUserIfExist(name string) error

DeleteUserIfExist check if user exist on the host

func GenerateBashScript

func GenerateBashScript(outputPath string, commands ...string) error

GenerateBashScript creates a bash script file with the given commands. It returns the path of the created script or an error.

func GetArch added in v0.1.6

func GetArch() (string, error)

func GetCPU added in v0.1.6

func GetCPU() (int, error)

func GetDiskSpace added in v0.1.6

func GetDiskSpace() (uint64, error)

func GetDiskSpaceForPath added in v0.1.6

func GetDiskSpaceForPath(path string) (uint64, error)

func GetDistro added in v0.1.6

func GetDistro() (string, error)

func GetOS added in v0.1.6

func GetOS() (string, error)

func GetRAM added in v0.1.6

func GetRAM() (uint64, error)

func Install

func Install(packages ...string) error

func IsArch added in v0.1.6

func IsArch(expected string) error

func IsArchAMD64 added in v0.1.6

func IsArchAMD64() (bool, error)

func IsArchIn added in v0.1.6

func IsArchIn(expected []string) error

func IsCPUEnough added in v0.1.6

func IsCPUEnough(minCPUs int) error

func IsCurlOK added in v0.1.6

func IsCurlOK(url string) bool

func IsDiskSpaceEnough added in v0.1.6

func IsDiskSpaceEnough(minSpace uint64) error

func IsDiskSpaceEnoughForPath added in v0.1.6

func IsDiskSpaceEnoughForPath(path string, minSpace uint64) error

func IsOs added in v0.1.6

func IsOs(expected string) error

func IsRAMEnough added in v0.1.6

func IsRAMEnough(minRAM uint64) error

func IsSSHOK added in v0.1.6

func IsSSHOK(ip string) bool

func IsSupportedDistro added in v0.1.6

func IsSupportedDistro(platform, version string) error

func IsTelnetOK added in v0.1.6

func IsTelnetOK(address string) bool

func ReadEtcPasswd

func ReadEtcPasswd() (list []string)

ReadEtcPasswd file /etc/passwd and return slice of users

func RestartSystemdService

func RestartSystemdService(serviceName string, verbose bool) error

func StringToBytes added in v0.1.6

func StringToBytes(s string) (uint64, error)

func Update

func Update() error

func Upgrade

func Upgrade() error

Types

This section is empty.

Jump to

Keyboard shortcuts

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