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
- func AddCronJob(cronJob string) error
- func AddNewUser(name string) (string, error)
- func AddUserIfNotExist(name string) (string, error)
- func BytesToString(b uint64) string
- func CopyFileToDestination(srcFile, destFile string) error
- func CreateDirIfNotExist(dir string) error
- func CreateFileWithPath(path string) (*os.File, error)
- func CreateRandom(n int) string
- func DeleteUser(name string) error
- func DeleteUserIfExist(name string) error
- func GenerateBashScript(outputPath string, commands ...string) error
- func GetArch() (string, error)
- func GetCPU() (int, error)
- func GetDiskSpace() (uint64, error)
- func GetDiskSpaceForPath(path string) (uint64, error)
- func GetDistro() (string, error)
- func GetOS() (string, error)
- func GetRAM() (uint64, error)
- func Install(packages ...string) error
- func IsArch(expected string) error
- func IsArchAMD64() (bool, error)
- func IsArchIn(expected []string) error
- func IsCPUEnough(minCPUs int) error
- func IsCurlOK(url string) bool
- func IsDiskSpaceEnough(minSpace uint64) error
- func IsDiskSpaceEnoughForPath(path string, minSpace uint64) error
- func IsOs(expected string) error
- func IsRAMEnough(minRAM uint64) error
- func IsSSHOK(ip string) bool
- func IsSupportedDistro(platform, version string) error
- func IsTelnetOK(address string) bool
- func ReadEtcPasswd() (list []string)
- func RestartSystemdService(serviceName string, verbose bool) error
- func StringToBytes(s string) (uint64, error)
- func Update() error
- func Upgrade() error
Constants ¶
const (
BinSH = "/bin/sh"
)
Variables ¶
This section is empty.
Functions ¶
func AddCronJob ¶
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 ¶
AddNewUser is created by executing shell command useradd
func AddUserIfNotExist ¶
AddUserIfNotExist check if user exist on the host
func BytesToString ¶ added in v0.1.6
func CopyFileToDestination ¶
func CreateDirIfNotExist ¶
func CreateFileWithPath ¶
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 DeleteUser ¶
DeleteUser is created by executing shell command userdel
func DeleteUserIfExist ¶
DeleteUserIfExist check if user exist on the host
func GenerateBashScript ¶
GenerateBashScript creates a bash script file with the given commands. It returns the path of the created script or an error.
func GetDiskSpace ¶ added in v0.1.6
func GetDiskSpaceForPath ¶ added in v0.1.6
func IsArchAMD64 ¶ added in v0.1.6
func IsCPUEnough ¶ added in v0.1.6
func IsDiskSpaceEnough ¶ added in v0.1.6
func IsDiskSpaceEnoughForPath ¶ added in v0.1.6
func IsRAMEnough ¶ added in v0.1.6
func IsSupportedDistro ¶ added in v0.1.6
func IsTelnetOK ¶ added in v0.1.6
func ReadEtcPasswd ¶
func ReadEtcPasswd() (list []string)
ReadEtcPasswd file /etc/passwd and return slice of users
func RestartSystemdService ¶
func StringToBytes ¶ added in v0.1.6
Types ¶
This section is empty.