Documentation
¶
Overview ¶
Package packaging implements systemd service packaging for bare-metal Linux servers.
Index ¶
Constants ¶
const DefaultBinaryPath = "/usr/local/bin/plexd"
DefaultBinaryPath is the default path to install the plexd binary.
const DefaultConfigDir = "/etc/plexd"
DefaultConfigDir is the default configuration directory.
const DefaultDataDir = "/var/lib/plexd"
DefaultDataDir is the default data directory.
const DefaultRunDir = "/var/run/plexd"
DefaultRunDir is the default runtime directory.
const DefaultServiceName = "plexd"
DefaultServiceName is the default systemd service name.
const DefaultUnitFilePath = "/etc/systemd/system/plexd.service"
DefaultUnitFilePath is the default path for the systemd unit file.
Variables ¶
This section is empty.
Functions ¶
func GenerateDefaultConfig ¶
GenerateDefaultConfig produces a minimal default config.yaml for plexd. If apiBaseURL is empty, a placeholder comment is written instead.
func GenerateUnitFile ¶
func GenerateUnitFile(cfg InstallConfig) string
GenerateUnitFile produces a complete systemd unit file for the plexd service. It calls cfg.ApplyDefaults() to fill in zero-valued fields before generating the output.
Types ¶
type InstallConfig ¶
type InstallConfig struct {
// BinaryPath is the path to install the plexd binary.
// Default: /usr/local/bin/plexd
BinaryPath string
// ConfigDir is the configuration directory.
// Default: /etc/plexd
ConfigDir string
// DataDir is the data directory.
// Default: /var/lib/plexd
DataDir string
// RunDir is the runtime directory.
// Default: /var/run/plexd
RunDir string
// UnitFilePath is the path for the systemd unit file.
// Default: /etc/systemd/system/plexd.service
UnitFilePath string
// ServiceName is the systemd service name.
// Default: plexd
ServiceName string
// APIBaseURL is the control plane API URL (optional).
APIBaseURL string
// TokenValue is the bootstrap token value (optional).
TokenValue string
// TokenFile is the path to the token file to copy from (optional).
TokenFile string
}
InstallConfig holds the configuration for packaging and installing plexd as a systemd service. InstallConfig is passed as a constructor argument — no file I/O in this package.
func (*InstallConfig) ApplyDefaults ¶
func (c *InstallConfig) ApplyDefaults()
ApplyDefaults sets default values for zero-valued fields.
func (*InstallConfig) Validate ¶
func (c *InstallConfig) Validate() error
Validate checks that required fields are set.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer handles installing and uninstalling plexd as a systemd service.
func NewInstaller ¶
func NewInstaller(cfg InstallConfig, systemd SystemdController, root RootChecker, logger *slog.Logger) *Installer
NewInstaller creates a new Installer with defaults applied.
type RootChecker ¶
type RootChecker interface {
// IsRoot returns true if the current process has root privileges.
IsRoot() bool
}
RootChecker abstracts privilege checking for testability.
func NewRootChecker ¶
func NewRootChecker() RootChecker
NewRootChecker returns a RootChecker that checks the real process UID.
type SystemdController ¶
type SystemdController interface {
// IsAvailable returns true if systemd (systemctl) is available on the system.
IsAvailable() bool
// DaemonReload executes systemctl daemon-reload to reload unit file changes.
DaemonReload() error
// Enable enables the named service to start on boot.
Enable(service string) error
// Disable disables the named service from starting on boot.
Disable(service string) error
// Stop stops the named service. Returns nil if the service is not running.
Stop(service string) error
// IsActive returns true if the named service is currently running.
IsActive(service string) bool
}
SystemdController abstracts systemd service management for testability. All methods that modify state must be idempotent: repeating an operation that is already applied returns nil.
func NewSystemdController ¶
func NewSystemdController() SystemdController
NewSystemdController returns a SystemdController that calls the real systemctl binary.