Files
unitdore/systemd/backend.go
T
warkanum df9b226c7e feat: OpenRC and runit init backends behind an Init interface
Extract init-neutral unit resolution into service/, add initsys.Init with systemd, openrc and runit backends, selected by 'init:' config or autodetect. OpenRC and runit are root only; rootless units run as system services as that user. Add docs and generated examples for all three.
2026-10-12 20:19:58 +02:00

38 lines
1.5 KiB
Go

package systemd
import "github.com/warkanum/unitdore/config"
// Backend is the systemd implementation of the init interface.
type Backend struct{}
func (Backend) Name() string { return "systemd" }
func (Backend) ServiceName(u config.Unit, prefix, suffix string) string {
return ServiceName(u, prefix, suffix)
}
func (Backend) UnitPath(u config.Unit, prefix, suffix string) (string, error) {
return UnitPath(u, prefix, suffix)
}
func (Backend) Generate(u config.Unit, prefix, suffix string) (string, error) {
return Generate(u, prefix, suffix)
}
func (Backend) Install(u config.Unit, prefix, suffix string) error { return Install(u, prefix, suffix) }
func (Backend) Uninstall(u config.Unit, prefix, suffix string) error {
return Uninstall(u, prefix, suffix)
}
func (Backend) Enable(u config.Unit, prefix, suffix string) error { return Enable(u, prefix, suffix) }
func (Backend) Disable(u config.Unit, prefix, suffix string) error { return Disable(u, prefix, suffix) }
func (Backend) Start(u config.Unit, prefix, suffix string) error { return Start(u, prefix, suffix) }
func (Backend) Stop(u config.Unit, prefix, suffix string) error { return Stop(u, prefix, suffix) }
func (Backend) Status(u config.Unit, prefix, suffix string) string { return Status(u, prefix, suffix) }
func (Backend) IsInstalled(u config.Unit, prefix, suffix string) bool {
return IsInstalled(u, prefix, suffix)
}
// SupportsLinger reports that user units need loginctl linger to start at boot.
func (Backend) SupportsLinger() bool { return true }