grub

package
v1.4.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package grub provides the interface to the GRUB bootloader: config management, installation, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootLabel

type BootLabel string

BootLabel represents a boot label, e.g. A or B.

const (
	// BootA is a bootloader label.
	BootA BootLabel = "A"

	// BootB is a bootloader label.
	BootB BootLabel = "B"

	// ConfigPath is the path to the grub config.
	ConfigPath = constants.BootMountPoint + "/grub/grub.cfg"
)

func FlipBootLabel

func FlipBootLabel(e BootLabel) (BootLabel, error)

FlipBootLabel flips the boot entry, e.g. A -> B, B -> A.

func ParseBootLabel

func ParseBootLabel(name string) (BootLabel, error)

ParseBootLabel parses the given human-readable boot label to a grub.BootLabel.

type Config

type Config struct {
	Default  BootLabel
	Fallback BootLabel
	Entries  map[BootLabel]MenuEntry
}

Config represents a grub configuration file (grub.cfg).

func Decode

func Decode(c []byte) (*Config, error)

Decode parses the grub configuration from the given bytes.

func NewConfig

func NewConfig(cmdline string) *Config

NewConfig creates a new grub configuration (nothing is written to disk).

func Read

func Read(path string) (*Config, error)

Read reads the grub configuration from the disk.

func (*Config) Encode

func (c *Config) Encode(wr io.Writer) error

Encode writes the grub configuration to the given writer.

func (*Config) Install

func (c *Config) Install(bootDisk, arch string) error

Install validates the grub configuration and writes it to the disk.

func (*Config) Put

func (c *Config) Put(entry BootLabel, cmdline string) error

Put puts a new menu entry to the grub config (nothing is written to disk).

func (*Config) Write

func (c *Config) Write(path string) error

Write the grub configuration to the given file.

type MenuEntry struct {
	Name    string
	Linux   string
	Cmdline string
	Initrd  string
}

MenuEntry represents a grub menu entry in the grub config file.

Jump to

Keyboard shortcuts

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