util

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause-Clear Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToSudoers

func AddToSudoers(user string) (result bool)

AddToSudoers adds a user to the sudoers file.

func AllGroups

func AllGroups() (g []string)

AllGroups gets a list of all groups on the system.

func AsString

func AsString(b []byte) string

AsString converts bytes from CLI output to a string & trims the trailing newline.

func Check

func Check(m string, e error, format ...interface{})

Check checks an error, and if present, logs an error message to the console & exits.

func CheckSSHKeys

func CheckSSHKeys()

CheckSSHKeys ensures SSH keys exist and have the correct permissions.

func CopyFile

func CopyFile(src string, dst string)

CopyFile copies a file from src to dst and OVERWRITES.

func Critical

func Critical(m string, f ...interface{})

Critical logs a red message to the console.

func CurrentUser

func CurrentUser() *user.User

CurrentUser gets the current user object.

func Debug

func Debug(m string, f ...interface{})

Debug logs a blue message to the console.

func Dependencies

func Dependencies()

Dependencies installs system dependencies.

func FileExists

func FileExists(f string) (e bool)

FileExists checks if a file exists.

func GetUserGroups

func GetUserGroups(user string) (groups []string)

GetUserGroups gets the current list of groups for which a user is a member.

func Info

func Info(m string, f ...interface{})

Info logs a blue message to the console.

func IsInstalled

func IsInstalled(pkg string) (i bool)

IsInstalled determines if a package is installed by checking to see if it is in $PATH

func IsRoot

func IsRoot() (r bool)

IsRoot determines if this package is being run as root.

func Logger

func Logger(t color.Attribute, m string, f ...interface{})

Logger is a base logger utility to conveniently format console output.

func NewGroup

func NewGroup(group string)

NewGroup adds a new group.

func ResetRoot

func ResetRoot()

ResetRoot sets the running user back to 0.

func RunAs

func RunAs(u string, f func()) func()

RunAs runs a function with lower privileges.

func ScaffoldRoot added in v0.0.4

func ScaffoldRoot()

ScaffoldRoot creates the required system directory structure.

func ScaffoldUser added in v0.0.4

func ScaffoldUser()

ScaffoldUser creates the required directory structure for the non-root user.

func SetHostname

func SetHostname(hostname string)

SetHostname sets the hostname of this node.

func SetTimezone

func SetTimezone()

SetTimezone sets the timezone of this node.

func Success

func Success(m string, f ...interface{})

Success logs a green message to the console.

func UserCommand

func UserCommand(base string, args ...string) ([]byte, error)

UserCommand runs a command with environment variables set for the user.

func UserToGroup

func UserToGroup(user string, group string)

UserToGroup adds a user to a group that is assumed to exist.

func Warning

func Warning(m string, f ...interface{})

Warning logs a yellow message to the console.

Types

This section is empty.

Jump to

Keyboard shortcuts

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