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:
+8
-4
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warkanum/unitdore/config"
|
||||
"github.com/warkanum/unitdore/systemd"
|
||||
"github.com/warkanum/unitdore/initsys"
|
||||
)
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
@@ -37,6 +37,10 @@ func runStatus(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
prefix, suffix := cfg.Prefix, cfg.Suffix
|
||||
ini, err := initsys.New(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(cfg.Units) == 0 {
|
||||
fmt.Println("No units configured. Run 'unitdore syncup' to discover containers.")
|
||||
@@ -65,13 +69,13 @@ func runStatus(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
installed := "yes"
|
||||
if !systemd.IsInstalled(u, prefix, suffix) {
|
||||
if !ini.IsInstalled(u, prefix, suffix) {
|
||||
installed = "no"
|
||||
}
|
||||
|
||||
state := "—"
|
||||
if systemd.IsInstalled(u, prefix, suffix) {
|
||||
state = systemd.Status(u, prefix, suffix)
|
||||
if ini.IsInstalled(u, prefix, suffix) {
|
||||
state = ini.Status(u, prefix, suffix)
|
||||
}
|
||||
|
||||
rows = append(rows, statusRow{
|
||||
|
||||
Reference in New Issue
Block a user