executil

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AptGet

func AptGet() func(context.Context) *exec.Cmd

AptGet returns a command factory for apt-get with DEBIAN_FRONTEND=noninteractive.

func Dnf added in v0.1.18

func Dnf() func(context.Context) *exec.Cmd

Dnf returns a command factory for dnf.

func Ip

func Ip() func(context.Context) *exec.Cmd

Ip returns a command factory for the ip networking utility.

func IsTextFileBusy added in v0.2.4

func IsTextFileBusy(err error) bool

IsTextFileBusy reports whether an error is the transient ETXTBSY described above, so callers doing their own exec can make the same allowance.

func MachineRun

func MachineRun(ctx context.Context, log *slog.Logger, machine string, args ...string) (string, error)

MachineRun executes a command inside the named nspawn machine using systemd-run --machine=<machine> --pipe --wait. It streams stdout at Debug and stderr at Error, and returns the captured stdout.

func Machinectl

func Machinectl() func(context.Context) *exec.Cmd

Machinectl returns a command factory for machinectl.

func Mountpoint added in v0.1.11

func Mountpoint() func(context.Context) *exec.Cmd

Mountpoint returns a command factory for mountpoint.

func OutputCmd

func OutputCmd(ctx context.Context, logger *slog.Logger, name string, args ...string) (string, error)

OutputCmd runs the command specified by name and args, streams stdout at Debug and stderr at Info, and returns the captured stdout as a string. Unlike RunCmd it does not require a command factory - just a binary path.

func OutputCmdAt

func OutputCmdAt(ctx context.Context, logger *slog.Logger, stderrLevel slog.Level, name string, args ...string) (string, error)

OutputCmdAt is like OutputCmd but streams stderr at stderrLevel instead of Info. Use a lower level (e.g. Debug) when stderr output is known to be benign or an error exit is expected and already handled by the caller.

func RetryWhileTextFileBusy added in v0.2.4

func RetryWhileTextFileBusy(ctx context.Context, logger *slog.Logger, attempt func() error) error

RetryWhileTextFileBusy runs attempt until it does not fail with ETXTBSY.

attempt must build everything it needs each time it is called, including the exec.Cmd: an exec.Cmd cannot be reused once started, and any pipes it created must be released before the next attempt. Nothing outside attempt constructs a command, so a caller-supplied command factory is invoked exactly once per attempt and never merely to inspect it.

The path of the binary is deliberately not a parameter. Every error this can return already names it, because a failed start is wrapped with the command path and the underlying os.PathError carries it as well.

func RunCmd

func RunCmd(ctx context.Context, logger *slog.Logger, newCmd func(context.Context) *exec.Cmd, args ...string) error

RunCmd creates a command from the given factory, appends args, streams stdout at Debug and stderr at Info, and waits for it to finish.

func RunCmdAt

func RunCmdAt(ctx context.Context, logger *slog.Logger, stderrLevel slog.Level, newCmd func(context.Context) *exec.Cmd, args ...string) error

RunCmdAt is like RunCmd but streams stderr at stderrLevel instead of Info. Use a lower level (e.g. Debug) when stderr output is known to be benign or when a failure is expected and already handled by the caller.

func Sysctl

func Sysctl() func(context.Context) *exec.Cmd

Sysctl returns a command factory for sysctl.

func Systemctl

func Systemctl() func(context.Context) *exec.Cmd

Systemctl returns a command factory for systemctl.

func Tdnf added in v0.1.18

func Tdnf() func(context.Context) *exec.Cmd

Tdnf returns a command factory for tdnf.

func Umount added in v0.1.11

func Umount() func(context.Context) *exec.Cmd

Umount returns a command factory for umount.

Types

This section is empty.

Jump to

Keyboard shortcuts

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