execs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package execs contains external executables.

Index

Constants

This section is empty.

Variables

View Source
var (
	IP         = "ip"
	Nft        = "nft"
	Resolvectl = "resolvectl"
	Sysctl     = "sysctl"
)

default values.

View Source
var RunCmd = func(ctx context.Context, cmd string, s string, arg ...string) (stdout, stderr []byte, err error) {
	c := exec.CommandContext(ctx, cmd, arg...)
	if s != "" {
		c.Stdin = bytes.NewBufferString(s)
	}
	var outbuf, errbuf bytes.Buffer
	c.Stdout = &outbuf
	c.Stderr = &errbuf
	err = c.Run()
	stdout = outbuf.Bytes()
	stderr = errbuf.Bytes()
	return
}

RunCmd runs the cmd with args and sets stdin to s, returns stdout and stderr.

Functions

func RunIP

func RunIP(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIP runs the "ip" command with args.

func RunIP4Route

func RunIP4Route(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIP4Route runs the "ip -4 route" command with args.

func RunIP4Rule

func RunIP4Rule(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIP4Rule runs the "ip -4 rule" command with args.

func RunIP6Route

func RunIP6Route(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIP6Route runs the "ip -6 route" command with args.

func RunIP6Rule

func RunIP6Rule(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIP6Rule runs the "ip -6 rule" command with args.

func RunIPAddress

func RunIPAddress(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIPAddress runs the "ip address" command with args.

func RunIPLink(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunIPLink runs the "ip link" command with args.

func RunNft

func RunNft(ctx context.Context, s string) (stdout, stderr []byte, err error)

RunNft runs the "nft -f -" command and sets stdin to s.

func RunResolvectl

func RunResolvectl(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunResolvectl runs the "resolvectl" command with args.

func RunSysctl

func RunSysctl(ctx context.Context, arg ...string) (stdout, stderr []byte, err error)

RunSysctl runs the "sysctl" command with args.

func SetExecutables

func SetExecutables(config *Config)

SetExecutables configures all executables from config.

Types

type Config

type Config struct {
	IP         string
	Nft        string
	Resolvectl string
	Sysctl     string
}

Config is executables configuration.

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config.

func (*Config) CheckExecutables

func (c *Config) CheckExecutables() error

CheckExecutables checks whether executables in config exist in the file system and are executable.

func (*Config) Valid

func (c *Config) Valid() bool

Valid returns whether config is valid.

Jump to

Keyboard shortcuts

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