units

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package units generates the systemd user units for the stack: a rig-control service and an optional modem per rig (template units, one instance per rig) and a single Pat service.

The units hold no device paths or ports. Each runs `hamstack run <kind> <rig>`, which reads the saved configuration and resolves the radio's serial port and sound card at the moment the service starts, so replugging a radio, using another USB port, or moving to another site needs no new units.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir is the systemd user unit directory.

func DirewolfConfig

func DirewolfConfig(rig config.Rig, prof profile.Profile, st config.Station, audioDevice, ptt string) string

DirewolfConfig returns the direwolf.conf for one rig. audioDevice is the ALSA device resolved right now ("" selects ALSA's null device, so Direwolf runs with no sound card); ptt is DirewolfPTT's line.

func DirewolfConfigWith

func DirewolfConfigWith(rig config.Rig, prof profile.Profile, st config.Station, audioDevice, ptt, extra string) string

DirewolfConfigWith is DirewolfConfig with the user's own extra lines (the contents of the rig's direwolf.extra) added at the end, where they can override anything above them.

func DirewolfPTT

func DirewolfPTT(mode, device string, rigPort int) (string, error)

DirewolfPTT is the PTT line of a Direwolf config. mode is the profile's packet PTT method; device is the serial port for rts/dtr; rigPort is the rig's rigctld port for "rig". It returns "" when the radio is keyed some other way (VOX), and an error for a mode it cannot honour.

func Generate

func Generate(p Plan) map[string]string

Generate returns the unit files keyed by file name.

func Install

func Install(p Plan) ([]string, error)

Install writes the unit files and returns the paths written.

func Installed

func Installed() ([]string, error)

Installed lists the hamstack unit files on disk (including ones from before rigs existed).

func LegacyUnit

func LegacyUnit(name string) bool

LegacyUnit reports whether a unit file name is one of the fixed single-radio units.

func MercuryConfig

func MercuryConfig(cfg config.Config, rig config.Rig, prof profile.Profile, st config.Station, audioDevice, stateDir string) string

MercuryConfig returns the mercury.ini for one rig. audioDevice is the ALSA device resolved right now ("" for none, which selects Mercury's null audio).

func Remove

func Remove() ([]string, error)

Remove deletes every hamstack unit file.

func RemoveFiles

func RemoveFiles(names []string) ([]string, error)

RemoveFiles deletes the named unit files from the unit directory.

func Stale

func Stale(p Plan) ([]string, error)

Stale returns installed unit files that p would not generate: a template no rig uses any more, or the fixed units of the single-radio versions (hamstack-rigctld.service and so on).

Types

type Plan

type Plan struct {
	Config   config.Config
	Rigs     []RigPlan      // active rigs
	Station  config.Station // the active station
	StateDir string         // hamstack's own log directory
	Pat      string         // absolute path of Pat
	Hamstack string         // absolute path of this program (the units run it)
}

Plan is everything needed to generate the units.

type RigPlan

type RigPlan struct {
	Rig     config.Rig
	Profile profile.Profile
}

RigPlan is one active rig with its radio model.

type Service

type Service struct {
	Kind string // config.RigCtld, config.Mercury or config.Pat
	Rig  string // rig id; empty for Pat
}

Service is one running thing: rig control or a modem for one rig, or Pat.

func ParseName

func ParseName(name string) (Service, bool)

ParseName reads "kind@rig" or "pat".

func Resolve

func Resolve(c config.Config, arg string) ([]Service, error)

Resolve turns a command-line word into services: "all", an exact "mercury@hf", a kind ("mercury": every Mercury), or a rig id ("hf": everything of that rig).

func ServicesFor

func ServicesFor(c config.Config) []Service

ServicesFor lists the services of a configuration in start order: for each active rig its rig control and then its modem, and finally Pat.

func (Service) Name

func (s Service) Name() string

Name is how the service is written on the command line: "mercury@hf", or "pat".

func (Service) Unit

func (s Service) Unit() string

Unit is the systemd unit name.

Jump to

Keyboard shortcuts

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