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.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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 }
|
||||
Reference in New Issue
Block a user