os

package
v0.0.0-...-96bf70c Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT, MIT Imports: 15 Imported by: 0

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)

func AddUserIfNotExist

func AddUserIfNotExist(name string) (string, error)

AddUserIfNotExist check if user exist on the host

func BytesToString

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

func GetArch() (string, error)

func GetCPU

func GetCPU() (int, error)

func GetDiskSpace

func GetDiskSpace() (uint64, error)

func GetDiskSpaceForPath

func GetDiskSpaceForPath(path string) (uint64, error)

func GetDistro

func GetDistro() (string, error)

func GetOS

func GetOS() (string, error)

func GetRAM

func GetRAM() (uint64, error)

func Install

func Install(packages ...string) error

func IsArch

func IsArch(expected string) error

func IsArchAMD64

func IsArchAMD64() (bool, error)

func IsArchIn

func IsArchIn(expected []string) error

func IsCPUEnough

func IsCPUEnough(minCPUs int) error

func IsCurlOK

func IsCurlOK(url string) bool

func IsDiskSpaceEnough

func IsDiskSpaceEnough(minSpace uint64) error

func IsDiskSpaceEnoughForPath

func IsDiskSpaceEnoughForPath(path string, minSpace uint64) error

func IsOs

func IsOs(expected string) error

func IsRAMEnough

func IsRAMEnough(minRAM uint64) error

func IsSSHOK

func IsSSHOK(ip string) bool

func IsSupportedDistro

func IsSupportedDistro(platform, version string) error

func IsTelnetOK

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

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