os

package
v0.0.0-...-0325488 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: AGPL-3.0 Imports: 12 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedOS = errors.New("os not supported yet")

ErrUnsupportedOS is an error that gets returned when the command is not supported in the OS

Functions

This section is empty.

Types

type Arch

type Arch int

Arch is the architecture of a CPU

const (
	// ArchUnknown is a not known architecture
	ArchUnknown Arch = iota
	// ArchAmd64 is the x86_64 architecture
	ArchAmd64
)

func ArchFromString

func ArchFromString(s string) Arch

ArchFromString returns an Arch based on a string

func DetectArch

func DetectArch(c client.Client) (Arch, error)

DetectArch returns the architecture of the OS

type OS

type OS int

OS is an Operative System

const (
	// Unknown is a not known OS
	Unknown OS = iota
	// Linux is a Linux OS
	Linux
	// Windows is a Microsoft Windows OS
	Windows
	// Darwin is a macOS OS
	Darwin
	// AIX is an IBM AIX OS
	AIX
	// Dragonfly is a Dragonfly BSD OS
	Dragonfly
	// FreeBSD is a FreeBSD OS
	FreeBSD
	// NetBSD is a NetBSD OS
	NetBSD
	// OpenBSD is an OpenBSD OS
	OpenBSD
	// Plan9 is a Plan9 OS
	Plan9
	// Solaris is a Solaris OS
	Solaris
)

func DetectOS

func DetectOS(c client.Client) (OS, error)

DetectOS detects the OS the Client is running

func FromString

func FromString(s string) OS

FromString returns an OS based on a string

func (OS) CmdFSHome

func (os OS) CmdFSHome(c client.Client, usr string) (string, error)

CmdFSHome returns the home directory of an user Heavily inspired (aka mostly copied) from github.com/mitchellh/go-homedir

func (OS) CmdFSTempDir

func (os OS) CmdFSTempDir() string

CmdFSTempDir returns the absolute path of the tmp dir

func (OS) CmdPkgInstallBinary

func (os OS) CmdPkgInstallBinary(c client.Client, usr, name string, b []byte) error

CmdPkgInstallBinary installs a binary in a system

func (OS) CmdPkgWriteConfig

func (os OS) CmdPkgWriteConfig(c client.Client, usr, name string, b []byte) error

CmdPkgWriteConfig writes the configuration of a DRLM program

func (OS) CmdSSHCopyID

func (os OS) CmdSSHCopyID(c client.Client, usr string, key []byte) error

CmdSSHCopyID copies the key to the OS

func (OS) CmdSSHGenerateKeyPair

func (os OS) CmdSSHGenerateKeyPair(c client.Client, path string) error

CmdSSHGenerateKeyPair generates an RSA 4096 key pair and saves them to the path as `id_rsa` and `id_rsa.pub`

func (OS) CmdSSHGetHostKeys

func (os OS) CmdSSHGetHostKeys(c client.Client, host string, port int) ([]string, error)

CmdSSHGetHostKeys returns the public SSH keys of a host

func (OS) CmdSSHGetKeysPath

func (os OS) CmdSSHGetKeysPath(c client.Client, usr string) (string, error)

CmdSSHGetKeysPath returns the SSH keys directory

func (OS) CmdUserChangePasswd

func (os OS) CmdUserChangePasswd(c client.Client, usr, pwd string) error

CmdUserChangePasswd changes the password of an user

func (OS) CmdUserCreate

func (os OS) CmdUserCreate(c client.Client, name, pwd string) error

CmdUserCreate creates a new user in the OS

func (OS) CmdUserDisable

func (os OS) CmdUserDisable(c client.Client, usr string) error

CmdUserDisable disables an user

func (OS) CmdUserGID

func (os OS) CmdUserGID(c client.Client, usr string) (int, error)

CmdUserGID returns the gid of an user

func (OS) CmdUserMakeAdmin

func (os OS) CmdUserMakeAdmin(c client.Client, usr string) error

CmdUserMakeAdmin makes an user administrator

func (OS) CmdUserUID

func (os OS) CmdUserUID(c client.Client, usr string) (int, error)

CmdUserUID returns the uid of an user

func (OS) DetectDistro

func (os OS) DetectDistro(c client.Client) (string, string, error)

DetectDistro returns the OS distro and distro version (or the OS equivalent)

func (OS) DetectVersion

func (os OS) DetectVersion(c client.Client) (string, error)

DetectVersion returns the OS version

func (OS) IsUnix

func (os OS) IsUnix() bool

IsUnix returns whether the OS is an Unix-like OS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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