firstboot

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package firstboot provides a service that runs scripts once on first boot. You can easily test this with:

mkdir /tmp/mgmt-firstboot/ ; echo 'echo hello' > /tmp/mgmt-firstboot/foo.sh ./mgmt firstboot start --lock-file-path=/tmp/flock.lock \ --scripts-dir=/tmp/mgmt-firstboot/ --logging-dir=/tmp/

Index

Constants

View Source
const (
	// LockFilePath is where we store a lock file to prevent more than one
	// copy of this service running at the same time.
	// TODO: Is there a better place to put this?
	LockFilePath string = "/var/lib/mgmt/firstboot.lock"

	// ScriptsDir is the directory where firstboot scripts can be found. You
	// can put binaries in here too. Contents must be executable.
	ScriptsDir string = "/var/lib/mgmt/firstboot/"

	// StyleSuffix is what we append to executables to specify a style file.
	StyleSuffix = ".yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	// Main runs everything for this setup item.
	Main(context.Context) error
}

API is the simple interface we expect for any setup items.

type Config

type Config struct {
}

Config is a struct of all the configuration values which are shared by all of the setup utilities. By including this as a separate struct, it can be used as part of the API if we want.

type Start

type Start struct {
	*cliUtil.FirstbootStartArgs // embedded config
	Config                      // embedded Config

	// Program is the name of this program, usually set at compile time.
	Program string

	// Version is the version of this program, usually set at compile time.
	Version string

	// Debug represents if we're running in debug mode or not.
	Debug bool

	// Logf is a logger which should be used.
	Logf func(format string, v ...interface{})
}

Start is the standalone entry program for the firstboot start component.

func (*Start) Main

func (obj *Start) Main(ctx context.Context) error

Main runs everything for this setup item.

func (*Start) Run

func (obj *Start) Run(ctx context.Context) error

Run performs the desired actions. This runs a list of scripts and then removes them. This is useful for a "firstboot" service. If there exists a file with the same name as an executable script or binary, but which has a .yaml extension, that will be parsed to look for command modifiers.

func (*Start) Validate

func (obj *Start) Validate() error

Validate verifies that the structure has acceptable data stored within.

type Style

type Style struct {

	// DoneDir specifies the dir to move files to instead of deleting them.
	DoneDir string `yaml:"done-dir"`

	// KeepOnFail should be true to preserve the script if it fails. This
	// means it will likely run again the next time the service runs.
	KeepOnFail bool `yaml:"keep-on-fail"`

	// NoLog should be true to skip logging the output of this command.
	NoLog bool `yaml:"no-log"`
	// contains filtered or unexported fields
}

Style are some values that are used to specify how each command runs.

Jump to

Keyboard shortcuts

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