internal

package
v0.0.0-...-9c0138c Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDevices

func CreateDevices() error

func DHCPClient

func DHCPClient(ifname string) (*dhclient.Client, error)

func ErrInvalidCfgFile

func ErrInvalidCfgFile(cfgFile string) error

func ErrNotExists

func ErrNotExists(fieldName string) error

func Gettys

func Gettys(ctx context.Context, n int, persist bool)

Gettys spawn the n number of getty processes on tty(s) If persist is true, they'll be respawned if they die.

func InterfaceUp

func InterfaceUp(ifname string) error

func Mkdev

func Mkdev(major, minor int) int

Mkdev is used to build the value of linux devices (in /dev/) which specifies major and minor number of the newly created device special file. Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, then the top 12 bits of the minor.

func Mknod

func Mknod(path string, mode uint32, dev int) error

Mknod creates a filesystem node (file, device special file or named pipe) named path with attributes specified by mode and dev.

func NewSSHServer

func NewSSHServer(bind, keys string, opts ...option) (*server, error)

func ParseServiceConfigs

func ParseServiceConfigs(dir string) (map[ServiceType][]*Service, error)

Parses all the config in directory dir return a map of providers of ServiceTypes from that directory.

func ScanDevices

func ScanDevices(ctx context.Context) error

ScanDevices scans /sys for devices and populate /dev

func SetupNetworkInterfaces

func SetupNetworkInterfaces() error

func StartSSHServer

func StartSSHServer(ctx context.Context)

func StartServices

func StartServices(services map[ServiceType][]*Service)

func WatchDevices

func WatchDevices(ctx context.Context) error

WatchDevices watches /sys for devices and populates /dev

func WithHostKeyFile

func WithHostKeyFile(fn string) option

Types

type Command

type Command string

func (Command) String

func (c Command) String() string

type Config

type Config struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(filename string) *Config

func (*Config) Load

func (cfg *Config) Load() error

func (*Config) ReadInt

func (cfg *Config) ReadInt(k string, def int) (int, error)

func (*Config) ReadString

func (cfg *Config) ReadString(k string, def string) (string, error)

func (*Config) Save

func (cfg *Config) Save() error

func (*Config) WriteInt

func (cfg *Config) WriteInt(k string, val int)

func (*Config) WriteString

func (cfg *Config) WriteString(k string, val string)

type MountOption

type MountOption struct {
	Source string
	Target string
	Type   string
	Flag   uintptr
	Option string
}

type Service

type Service struct {
	Name     ServiceName
	Startup  Command
	Shutdown Command
	Provides []ServiceType
	Needs    []ServiceType
	// contains filtered or unexported fields
}

func ParseConfig

func ParseConfig(r io.Reader) (Service, error)

Parses a single config file into the services it provides

func (Service) NeedsSatisfied

func (s Service) NeedsSatisfied(started map[ServiceType]bool, mu *sync.RWMutex) bool

Checks if all of s's needs are satified by the passed list of provided types

func (*Service) Start

func (s *Service) Start() error

Starts the Service(s)

func (*Service) Stop

func (s *Service) Stop() error

type ServiceName

type ServiceName string

type ServiceType

type ServiceType string

type Unmounter

type Unmounter func() error

func Mount

func Mount(mountOpts ...MountOption) (Unmounter, error)

Mount mounts list of mountOptions and returns a function to unmount them.

Jump to

Keyboard shortcuts

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